Created
November 12, 2019 17:32
-
-
Save devxpy/df786cfb7f1a9f737f37c4c50cad5779 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------- | |
# 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] | |
# Create a nam trace datafile. | |
set namfile [open /ns2/ns-2.35/test.nam w] | |
$ns namtrace-all $namfile | |
# Create wired nodes. | |
set node(3) [$ns node] | |
## node(3) at 553.734375,519.187500 | |
$node(3) set X_ 553.734375 | |
$node(3) set Y_ 519.187500 | |
$node(3) set Z_ 0.0 | |
$node(3) color "black" | |
set node(2) [$ns node] | |
## node(2) at 604.265625,589.312500 | |
$node(2) set X_ 604.265625 | |
$node(2) set Y_ 589.312500 | |
$node(2) set Z_ 0.0 | |
$node(2) color "black" | |
set node(1) [$ns node] | |
## node(1) at 499.078094,590.000000 | |
$node(1) set X_ 499.078094 | |
$node(1) set Y_ 590.000000 | |
$node(1) set Z_ 0.0 | |
$node(1) color "black" | |
# Create links between nodes. | |
$ns simplex-link $node(3) $node(1) 1.000000Mb 20.000000ms DropTail | |
$ns simplex-link-op $node(3) $node(1) queuePos 0.5 | |
$ns simplex-link-op $node(3) $node(1) color black | |
$ns simplex-link-op $node(3) $node(1) orient 127.7deg | |
# Set Queue Properties for link 3->1 | |
[[$ns link $node(3) $node(1)] queue] set limit_ 20 | |
$ns simplex-link $node(3) $node(2) 1.000000Mb 20.000000ms DropTail | |
$ns simplex-link-op $node(3) $node(2) queuePos 0.5 | |
$ns simplex-link-op $node(3) $node(2) color black | |
$ns simplex-link-op $node(3) $node(2) orient 54.2deg | |
# Set Queue Properties for link 3->2 | |
[[$ns link $node(3) $node(2)] queue] set limit_ 20 | |
$ns simplex-link $node(2) $node(3) 1.000000Mb 20.000000ms DropTail | |
$ns simplex-link-op $node(2) $node(3) queuePos 0.5 | |
$ns simplex-link-op $node(2) $node(3) color black | |
$ns simplex-link-op $node(2) $node(3) orient 234.2deg | |
# Set Queue Properties for link 2->3 | |
[[$ns link $node(2) $node(3)] queue] set limit_ 20 | |
$ns simplex-link $node(2) $node(1) 1.000000Mb 20.000000ms DropTail | |
$ns simplex-link-op $node(2) $node(1) queuePos 0.5 | |
$ns simplex-link-op $node(2) $node(1) color black | |
$ns simplex-link-op $node(2) $node(1) orient 179.6deg | |
# Set Queue Properties for link 2->1 | |
[[$ns link $node(2) $node(1)] queue] set limit_ 20 | |
$ns simplex-link $node(1) $node(3) 1.000000Mb 20.000000ms DropTail | |
$ns simplex-link-op $node(1) $node(3) queuePos 0.5 | |
$ns simplex-link-op $node(1) $node(3) color black | |
$ns simplex-link-op $node(1) $node(3) orient 307.7deg | |
# Set Queue Properties for link 1->3 | |
[[$ns link $node(1) $node(3)] queue] set limit_ 20 | |
$ns simplex-link $node(1) $node(2) 1.000000Mb 20.000000ms DropTail | |
$ns simplex-link-op $node(1) $node(2) queuePos 0.5 | |
$ns simplex-link-op $node(1) $node(2) color black | |
$ns simplex-link-op $node(1) $node(2) orient 359.6deg | |
# Set Queue Properties for link 1->2 | |
[[$ns link $node(1) $node(2)] queue] set limit_ 20 | |
# Add Link Loss Models | |
# Create agents. | |
set agent(3) [new Agent/TCPSink] | |
$ns attach-agent $node(3) $agent(3) | |
$agent(3) set packetSize_ 210 | |
set agent(2) [new Agent/TCP] | |
$ns attach-agent $node(2) $agent(2) | |
# Create traffic sources and add them to the agent. | |
set traffic_source(2) [new Application/FTP] | |
$traffic_source(2) attach-agent $agent(2) | |
$traffic_source(2) set maxpkts_ 256 | |
set agent(1) [new Agent/TCP] | |
$ns attach-agent $node(1) $agent(1) | |
$ns color 1 "black" | |
$agent(1) set fid_ 1 | |
$agent(1) set packetSize_ 210 | |
$agent(1) set window_ 20 | |
$agent(1) set windowInit_ 1 | |
$agent(1) set maxcwnd_ 0 | |
# Create traffic sources and add them to the agent. | |
set traffic_source(1) [new Application/FTP] | |
$traffic_source(1) attach-agent $agent(1) | |
$traffic_source(1) set maxpkts_ 256 | |
# Connect agents. | |
$ns connect $agent(1) $agent(3) | |
# Traffic Source actions. | |
$ns at 0.000000 "$traffic_source(1) start" | |
$ns at 60.000000 "$traffic_source(1) stop" | |
# Run the simulation | |
proc finish {} { | |
global ns namfile | |
$ns flush-trace | |
close $namfile | |
exec nam -r 2000.000000us /ns2/ns-2.35/test.nam & | |
exit 0 | |
} | |
$ns at 60.000000 "finish" | |
$ns run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment