# # trafgen.ns - template for traffic generation # # Precondition: Two nodes (here, called $sender and $reciver, but can be # called anything) have been created, and they have a valid route between # them. # # Note: To use make multiple streams of traffic, you need a seperate agent, # traffic source, and sink for each (though you can, of course, have more # than one agent or sink on the same node.) # # # Create a TCP agent and attach it to sender. You can use use UDP instead # by changing "Agent/TCP" to "Agent/UDP" (and, you'll probably want to rename # $tcp0 ) # set tcp0 [new Agent/TCP] $ns attach-agent $sender $tcp0 # # Create a CBR traffic source and attach it to tcp0. Specify traffic # in terms of packetSize and rate # set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 1024 $cbr0 set rate_ 100Mb $cbr0 attach-agent $tcp0 # # Create a sink for the agent, an put it on the reciver # set null0 [new Agent/Null] $ns attach-agent $receiver $null0 # # Connect the source to the sink # $ns connect $tcp0 $null0