NS2 wireless network dsdv protocol

2 342 0
NS2  wireless network dsdv  protocol

Đang tải... (xem toàn văn)

Thông tin tài liệu

Danh gia hieu nang mang bang NS2, mo phong va viet kich ban mang khong day (wireless network, wireless sensor network). danh gia hieu nang, su thay doi vi tri nut mang. Kich ban danh gia mang khong day bang NS2. vi du va huong dan (Example) NS2.

#============================= #dungnq06 (dungnq06@yahoo.com.vn): Mo phong danh gia hieu nang mang Wireless network bang NS2 #Kich ban mang: danh gia giao thuc dsdv Mo phong voi truong hop so luong nut khac nhau, su thay doi vi tri nut khac #==================================================================== # Define options # ====================================================================== set opt(chan) Channel/WirelessChannel set opt(prop) Propagation/TwoRayGround set opt(netif) Phy/WirelessPhy set opt(mac) Mac/802_11 set opt(ifq) Queue/DropTail/PriQueue set opt(ll) LL set opt(ant) Antenna/OmniAntenna set opt(x) 1000 ;# X dimension of the topography set opt(y) 1000 ;# Y dimension of the topography set opt(ifqlen) 50ls ;# max packet in ifq set opt(seed) 0.0 set opt(tr) ex01_dsdv_50.tr ;# trace file set opt(nf) ex01_dsdv_50.nam ;#nam file set opt(adhocRouting) DSDV set opt(nn) 50 ;# how many nodes are simulated set opt(cp) "scenarios/scen-50-1000-1000"; #use setdest generation set opt(sc) "scenarios/cp_50"; #use cbrgen.tcl generation set opt(stop) 100.0 ;# simulation time #====================================================================== # Main Program # ====================================================================== # Initialize Global Variables # create simulator instance set ns_ [new Simulator] # set wireless channel, radio-model and topography objects set wtopo [new Topography] # create trace object for ns and nam set namtrace [open $opt(nf) w] $ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y) set tracefd [open $opt(tr) w] $ns_ trace-all $tracefd # use new trace file format $ns_ use-newtrace # define topology $wtopo load_flatgrid $opt(x) $opt(y) # Create God set god_ [create-god $opt(nn)] # define how node should be created #global node setting $ns_ node-config -adhocRouting $opt(adhocRouting) \ -llType $opt(ll) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -channelType $opt(chan) \ -topoInstance $wtopo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF # Create the specified number of nodes [$opt(nn)] and "attach" them # to the channel for {set i 0} {$i < $opt(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion ;# disable random motion } # Define node movement model #puts "Loading connection pattern " source $opt(cp) # Define traffic model puts "Loading scenario file " source $opt(sc) # Define node initial position in nam for {set i 0} {$i < $opt(nn)} {incr i} { # 20 defines the node size in nam, must adjust it according to your scenario # The function must be called after mobility model is defined $ns_ initial_node_pos $node_($i) 20 } # Next add informative headers for the CMUTrace file, just before the line "ns_ run" puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y) rp $opt(adhocRouting)" puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed $opt(seed)" puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)" # Tell nodes when the simulation ends for {set i 0} {$i < $opt(nn) } {incr i} { $ns_ at $opt(stop).000000001 "$node_($i) reset"; } # tell nam the simulation stop time #$ns_ at $opt(stop) "$ns_ nam-end-wireless $opt(stop)" $ns_ at $opt(stop) "stop" #$ns_ at 20.01 "puts \"end simulation\" ; $ns_ halt" puts "Starting Simulation " proc stop {} { global ns_ tracefd namtrace $ns_ flush-trace close $tracefd close $namtrace exec nam ex01_dsdv_50.nam & } $ns_ run ... $opt(stop).000000001 "$node_($i) reset"; } # tell nam the simulation stop time #$ns_ at $opt(stop) "$ns_ nam-end -wireless $opt(stop)" $ns_ at $opt(stop) "stop" #$ns_ at 20.01 "puts "end simulation" ; $ns_ halt"

Ngày đăng: 25/04/2017, 12:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan