?? wireless1.tcl
字號:
#------------------------------------------------------- # This ns script has been created by the nam editor.# If you edit it manually, the nam editor might not# be able to open it properly in the future.## EDITING BY HAND IS AT YOUR OWN RISK!#------------------------------------------------------- # Create a new simulator object.set ns [new Simulator]$ns set-address-format hierarchical 1 4 AddrParams set domain_num_ 1AddrParams set cluster_num_ 2AddrParams set nodes_num_ 4####################################################3############### $Node add-route <dst> <target>############### This procedure is used to add next-hop entries of a destination <dst> for a given <target>.############### $hiernode_ split-addrstr <str>############### This splits up a hierarchical adrress string (say a.b.c) into a list of the addresses at each level (i.e, ############### a,b and c).##########################################3# Create a nam trace datafile.set namfile [open /root/Desktop/wireless1.nam w]$ns namtrace-all $namfile# Create wired nodes.# ----- Setup wireless environment. ----set wireless_tracefile [open /root/Desktop/wireless1.trace w]set topography [new Topography]$ns trace-all $wireless_tracefile$ns namtrace-all-wireless $namfile 632.000000 639.562500$topography load_flatgrid 632.000000 639.562500## Create God#set god_ [create-god 9]#global node setting$ns node-config -adhocRouting DSR \ -llType LL \ -macType Mac/802_11 \ -ifqType Queue/DropTail/PriQueue \ -ifqLen 50 \ -antType Antenna/OmniAntenna \ -propType Propagation/TwoRayGround \ -phyType Phy/WirelessPhy \ -channel [new Channel/WirelessChannel] \ -topoInstance $topography \ -agentTrace ON \ -routerTrace ON \ -macTrace ON \ -energyModel "EnergyModel" \ -initialEnergy 3J \ -rxPower 1mW \ -txPower 1mW \ -idlePower 0.5mW \ -sleepPower 0.001mW # Create wireless nodes.set node(9) [$ns node]## node(9) at 612.000000,567.656250$node(9) set X_ 612.000000$node(9) set Y_ 567.656250$node(9) set Z_ 0.0$node(9) color "black"$ns initial_node_pos $node(9) 10.000000set node(8) [$ns node]## node(8) at 486.531219,516.437500$node(8) set X_ 486.531219$node(8) set Y_ 516.437500$node(8) set Z_ 0.0$node(8) color "black"$ns initial_node_pos $node(8) 10.000000set node(7) [$ns node]## node(7) at 522.625000,504.062469$node(7) set X_ 522.625000$node(7) set Y_ 504.062469$node(7) set Z_ 0.0$node(7) color "black"$ns initial_node_pos $node(7) 10.000000set node(6) [$ns node]## node(6) at 543.250000,541.875000$node(6) set X_ 543.250000$node(6) set Y_ 541.875000$node(6) set Z_ 0.0$node(6) color "black"$ns initial_node_pos $node(6) 10.000000set node(5) [$ns node]## node(5) at 488.937469,545.312500$node(5) set X_ 488.937469$node(5) set Y_ 545.312500$node(5) set Z_ 0.0$node(5) color "black"$ns initial_node_pos $node(5) 10.000000set node(4) [$ns node]## node(4) at 505.781219,574.187500$node(4) set X_ 505.781219$node(4) set Y_ 574.187500$node(4) set Z_ 0.0$node(4) color "black"$ns initial_node_pos $node(4) 10.000000set node(3) [$ns node]## node(3) at 539.468750,595.500000$node(3) set X_ 539.468750$node(3) set Y_ 595.500000$node(3) set Z_ 0.0$node(3) color "black"$ns initial_node_pos $node(3) 10.000000set node(2) [$ns node]## node(2) at 520.906250,619.562500$node(2) set X_ 520.906250$node(2) set Y_ 619.562500$node(2) set Z_ 0.0$node(2) color "black"$ns initial_node_pos $node(2) 10.000000set node(1) [$ns node]## node(1) at 485.499969,610.281250$node(1) set X_ 485.499969$node(1) set Y_ 610.281250$node(1) set Z_ 0.0$node(1) color "black"$ns initial_node_pos $node(1) 10.000000# Create links between nodes.# Add Link Loss Models# Create agents.set agent(9) [new Agent/Null]$ns attach-agent $node(9) $agent(9)set agent(8) [new Agent/UDP]$ns attach-agent $node(8) $agent(8)# Create traffic sources and add them to the agent.set traffic_source(8) [new Application/Traffic/CBR]$traffic_source(8) attach-agent $agent(8)$traffic_source(8) set interval_ 0.001950set agent(7) [new Agent/UDP]$ns attach-agent $node(7) $agent(7)# Create traffic sources and add them to the agent.set traffic_source(7) [new Application/Traffic/CBR]$traffic_source(7) attach-agent $agent(7)$traffic_source(7) set interval_ 0.001950set agent(6) [new Agent/UDP]$ns attach-agent $node(6) $agent(6)# Create traffic sources and add them to the agent.set traffic_source(6) [new Application/Traffic/CBR]$traffic_source(6) attach-agent $agent(6)$traffic_source(6) set interval_ 0.100000set agent(5) [new Agent/UDP]$ns attach-agent $node(5) $agent(5)# Create traffic sources and add them to the agent.set traffic_source(5) [new Application/Traffic/CBR]$traffic_source(5) attach-agent $agent(5)$traffic_source(5) set interval_ 0.001950set agent(4) [new Agent/UDP]$ns attach-agent $node(4) $agent(4)# Create traffic sources and add them to the agent.set traffic_source(4) [new Application/Traffic/CBR]$traffic_source(4) attach-agent $agent(4)$traffic_source(4) set interval_ 0.500000set agent(3) [new Agent/UDP]$ns attach-agent $node(3) $agent(3)# Create traffic sources and add them to the agent.set traffic_source(3) [new Application/Traffic/CBR]$traffic_source(3) attach-agent $agent(3)$traffic_source(3) set interval_ 0.050000set agent(2) [new Agent/UDP]$ns attach-agent $node(2) $agent(2)# Create traffic sources and add them to the agent.set traffic_source(2) [new Application/Traffic/CBR]$traffic_source(2) attach-agent $agent(2)$traffic_source(2) set interval_ 0.010000set agent(1) [new Agent/UDP]$ns attach-agent $node(1) $agent(1)# Create traffic sources and add them to the agent.set traffic_source(1) [new Application/Traffic/CBR]$traffic_source(1) attach-agent $agent(1)$traffic_source(1) set interval_ 0.100000####################################################$ns add-agent-trace $agent(9) Null$ns monitor-agent-trace $agent(9)$agent(9) tracevar cwnd_$agent(9) tracevar ssthresh_#####################################################Connect the traffic sources with the traffic sink$ns connect $agent(1) $agent(9) $ns connect $agent(6) $agent(9)$node(1) add-route $node(3) $node(9)################ add annotations ##########################$ns at 0.5 "$ns trace-annotate \"traffic_source(1) start\""$ns at 1.0 "$ns trace-annotate \"traffic_source(6) start\""$ns at 4.0 "$ns trace-annotate \"traffic_source(1) stop\""$ns at 4.5 "$ns trace-annotate \"traffic_source(6) stop\""############################################################Schedule events for the CBR agents$ns at 0.5 "$traffic_source(1) start"$ns at 1.0 "$traffic_source(6) start"$ns at 4.0 "$traffic_source(1) stop"$ns at 4.5 "$traffic_source(6) stop"# Connect agents.# Run the simulationproc finish {} { global ns namfile $ns flush-trace close $namfile exec nam -r 2000.000000us /root/Desktop/wireless1.nam & exit 0 }$ns at 60.000000 "finish"$ns run
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -