manet.docx

Upload: tung-el-pulga

Post on 03-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 manet.docx

    1/4

    manet.tcl

    An example manet tcl file for ns-2. This is a modification of the aodv example from ns-2.34.

    Usage

    Code

    #------------------------------------------------------------------------------# Marco Fiore's Patch# ------------------------------------------------------------------------------#remove-all-packet-headers ;# removes all except common#add-packet-header IP LL Mac AODV AOMDV ATR DSDV DSR OLSR UDP TCP CBR FTP

    ;# needed headersMac/802_11 set CWMin_ 31Mac/802_11 set CWMax_ 1023Mac/802_11 set SlotTime_ 0.000020 ;# 20usMac/802_11 set SIFS_ 0.000010 ;# 10usMac/802_11 set PreambleLength_ 144 ;# 144 bitMac/802_11 set ShortPreambleLength_ 72 ;# 72 bitMac/802_11 set PreambleDataRate_ 1.0e6 ;# 1MbpsMac/802_11 set PLCPHeaderLength_ 48 ;# 48 bitsMac/802_11 set PLCPDataRate_ 1.0e6 ;# 1MbpsMac/802_11 set ShortPLCPDataRate_ 2.0e6 ;# 2MbpsMac/802_11 set RTSThreshold_ 3000 ;# bytesMac/802_11 set ShortRetryLimit_ 7 ;# retransmissions

    Mac/802_11 set LongRetryLimit_ 4 ;# retransmissionsMac/802_11 set newchipset_ false ;# use new chipset, allowing a more recentpacket to be correctly received in place of the first sensed packetMac/802_11 set dataRate_ 11Mb ;# 802.11 data transmission rateMac/802_11 set basicRate_ 1Mb ;# 802.11 basic transmission rateMac/802_11 set aarf_ false ;# 802.11 Auto Rate Fallback

    #------------------------------------------------------------------------------# Defining options# ------------------------------------------------------------------------------set val(chan) Channel/WirelessChannel ;# channel type

    set val(ant) Antenna/OmniAntenna ;# antenna typeset val(propagation) TwoRay ;# propagation modelset val(netif) Phy/WirelessPhy ;# network interface typeset val(ll) LL ;# link layer typeset val(ifq) Queue/DropTail/PriQueue ;# interface queue typeset val(ifqlen) 50 ;# max packet in ifqset val(mac) Mac/802_11 ;# MAC typeset val(rp) AOMDV ;# routing protocolset val(nn) 16.0 ;# node numberset val(stop) 600.0 ;# simulation time [s]set val(seed) 1 ;# general pseudo-random sequence generatorset val(x) 1000set val(y) 1000

    # -------------------------------------------------------------------------

  • 7/28/2019 manet.docx

    2/4

    -----# Fixing DSR bug# ------------------------------------------------------------------------------if {$val(rp) == "DSR"} {set val(ifq) CMUPriQueue

    }

    # ------------------------------------------------------------------------------# Channel model# ------------------------------------------------------------------------------Antenna/OmniAntenna set X_ 0Antenna/OmniAntenna set Y_ 0Antenna/OmniAntenna set Z_ 1.5Antenna/OmniAntenna set Gt_ 1 ;# transmitter antenna gainAntenna/OmniAntenna set Gr_ 1 ;# receiver antenna gainPhy/WirelessPhy set L_ 1.0 ;# system loss factor (mostly 1.0)

    if {$val(propagation) == "TwoRay"} { ;# range tx = 250mset val(prop) Propagation/TwoRayGroundset prop [new $val(prop)]Phy/WirelessPhy set CPThresh_ 10.0 ;# capture threshold in WattPhy/WirelessPhy set CSThresh_ 1.559e-11 ;# Carrier Sensing thresholdPhy/WirelessPhy set RXThresh_ 3.652e-10 ;# receiver signal thresholdPhy/WirelessPhy set freq_ 2.4e9 ;# channel frequency (Hz)Phy/WirelessPhy set Pt_ 0.28 ;# transmitter signal power (Watt)}if {$val(propagation) == "Shado"} {set val(prop) Propagation/Shadowingset prop [new $val(prop)]$prop set pathlossExp_ 3.8 ;# path loss exponent$prop set std_db_ 2.0 ;# shadowing deviation (dB)$prop set seed_ 1 ;# seed for RNG$prop set dist0_ 1.0 ;# reference distance (m)$prop set CPThresh_ 10.0 ;# capture threshold in Watt$prop set RXThresh_ 2.37e-13 ;# receiver signal threshold$prop set CSThresh_ [expr 2.37e-13 * 0.0427] ;# Carrier Sensing threshold$prop set freq_ 2.4e9 ;# channel frequency (Hz)Phy/WirelessPhy set Pt_ 0.28}

    proc getopt {argc argv} {global vallappend optlist nn seed mc rate type

    for {set i 0} {$i < $argc} {incr i} {set arg [lindex $argv $i]if {[string range $arg 0 0] != "-"} continue

    set name [string range $arg 1 end]set val($name) [lindex $argv [expr $i+1]]puts "$name $val($name)"}}

    getopt $argc $argv

    # -------------------------------------------------------------------------

  • 7/28/2019 manet.docx

    3/4

    -----# General definition# ------------------------------------------------------------------------------;#Instantiate the simulatorset ns_ [new Simulator]

    ;#Define topologyset topo [new Topography]$topo load_flatgrid $val(x) $val(y);#Create channelset chan [new $val(chan)]$prop topography $topocreate-god $val(nn)

    $ns_ node-config -adhocRouting $val(rp) \-llType $val(ll) \-macType $val(mac) \-ifqType $val(ifq) \-ifqLen $val(ifqlen) \

    -antType $val(ant) \-propInstance $prop \-phyType $val(netif) \-channel $chan \-topoInstance $topo \-agentTrace ON \-routerTrace ON \-macTrace OFF \-movementTrace OFF

    # ------------------------------------------------------------------------------# Trace file definition# ------------------------------------------------------------------------------

    #New format for wireless traces$ns_ use-newtrace

    #Create trace object for ns, nam, monitor and Inspectset nsTrc [open $val(log) w]$ns_ trace-all $nsTrc

    # ------------------------------------------------------------------------------# Nodes definition# ------------------------------------------------------------------------------;# Create the specified number of nodes [$val(nn)] and "attach" them to thechannel.for {set i 0} {$i < $val(nn) } {incr i} {set node_($i) [$ns_ node]$node_($i) random-motion 0 ;# disable random motion}

    # Define node movement modelsource $val(cp) ; # connection pattern

    # Define traffic model

    source $val(sc)

  • 7/28/2019 manet.docx

    4/4

    for {set i 0} {$i < $val(nn) } {incr i} {$ns_ at $val(stop) "$node_($i) reset";}

    $ns_ at $val(stop) "$ns_ halt"

    $ns_ run