Download as pdf
Download as pdf
You are on page 1of 4
Implement transmission of ping messages/trace route over a network topology consisting of 6 nodes and find the number of packets dropped due to congestion. Step: set ns [new Simulator] set nf [open prog3.nam w] Sns namtrace-all Snf set nd [open prog3.tr W] $ns trace-all $nd_ proc finish (} { global ns nf nd Sns flush-trace close Snf close Snd exee nam prog4.nam & exit } set nO [Sns node] set nt [Sns node] set n2 [Sns node] [Sns node] set n4 [Sns node] set n5 [Sns node] set n6 [Sns node] sel Sns duplex-link Sn Sn0 IMb 10ms DropTail ‘$ns duplex-link $n2 Sn0 IMb 10ms DropTail ‘ns duplex-link $n3 Sn0 1Mb 10ms DropTail $ns duplex-link $n4 $n0 1Mb 10ms DropTail $ns duplex-link $n5 $n0 1Mb 10ms DropTail $ns duplex-link $n6 $n0 1Mb 10ms DropTail Agent/Ping instproc recv (from rtt} [ Sself instvar node_ puts “node [Snode_ idl] recieved ping answer from \ Strom with round-trip-time Srut ms.” } set pl [new Agent/Ping] pen text editor, type the below program and save with extention cl (prog3.tel ) © scanned with OKEN Scanner set p2 [new Agent/Ping] set p3 [new Agent/Ping] set p4 [new Agent Ping] set pS [new Agent Ping] set p6 [new Agent/Ping]} Sns attach-agent Snt $pl Sn attach-agent Sn2 $p2 Sns attach-agent Sn3 $p3 $s attach-agent Sn4 $p4 Sns attach-agent Sn5 $p5 Sns attach-agent $n6 $6 Sns queue-Limit $n Sn4 3 limit Sn SnS 2 2 $ns connect $p1 Spa Sns connect $p2 $p5 Sns connect $p3 $p6 Sns at 0.2 "Spt seni Sns at 0.4 "Sp2 s Sns at 0.6 "$p3 send’ Sn at 1.0 "Sp send” Sns at 1.2 *SpS send” Sns at 1.4 "Sp6 send” Sns at 2.0 “finish” Sns run Open text editor, type the below program and save with extention awk (prog3.awk ) BEGIN { count=0; } ( event=S1; iffevent ( counts ) ) END | © scanned with OKEN Scanner printf("No of packets dropped : %d\n",count); 1 Step3: Run the simulation program [root @localhost~}# ns prog3.tel (Here “ns” indicates network simulator, We get the topology shown in the snapshot.) Oren ef FRERRRRRERERSERRERESERERR ERE =nn Step 4: Now press the play button in the simulation window and the simulation will begins, Step 5: After simulation is completed run awk file to see the output , [root @locathost~}# awk -f prog3.awk prog3.tr © scanned with OKEN Scanner aan tn 88 ara a es Step 6: To see the trace file contents open the file as [root @localhost~}# vi prog3.tr © scanned with OKEN Scanner

You might also like