Transfer Data Between Two Nodes.
In the first tutorial we have created two nodes and now we will transfer data between them.
Add following lines to ist program
set udp0 [new Agent/UDP] #we have created udp agent. An agent is an NsObject which is responsible for creating and destroying packets.
$ns attach-agent $n0 $udp0 #attach udp to node 0
set cbr0 [new Application/Traffic/CBR] #create a Constant Bit Rate source and attach it to udp0
$cbr0 set packetSize 500.. #packet size 500
$cbr0 set interval .005.. #after .005 sec next packet will b send
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n1 $null0 #node 1 will act now sinck
$ns connect $udp0 $null0 #connect source and sink
$ns at .5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop "
In the first tutorial we have created two nodes and now we will transfer data between them.
Add following lines to ist program
set udp0 [new Agent/UDP] #we have created udp agent. An agent is an NsObject which is responsible for creating and destroying packets.
$ns attach-agent $n0 $udp0 #attach udp to node 0
set cbr0 [new Application/Traffic/CBR] #create a Constant Bit Rate source and attach it to udp0
$cbr0 set packetSize 500.. #packet size 500
$cbr0 set interval .005.. #after .005 sec next packet will b send
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n1 $null0 #node 1 will act now sinck
$ns connect $udp0 $null0 #connect source and sink
$ns at .5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop "

No comments:
Post a Comment