You are on page 1of 14

ST.

JOSEPH ENGINEERING COLLEGE


Vamanjoor, Mangalore-575028

WMN Assignment

Submitted By: ANIL KUMAR BHAT USN: 4SO12LDS02 Semester:2nd SEM DECS Branch: E&C Course: MTECH

Department Of Electronics & Communication Engineering 2013

WMN Assignment Experiment 1:


AIM:
To Design and simulate a network that consists of four nodes [n0-n3]. Link existence between the nodes is as follows: n0-n2, n1-n2, and n2-n3. Nodes 'n0' and 'n1' are having some data to send to node 'n3' through 'n2'. Data rate for links n0-n2 and n1-n2 are different. Write Tcl script to observe the packet flow for the given network in NAM

PROGRAM:
set ns [new Simulator] $ns color 1 Blue $ns color 1 Red set nf [open out.nam w] $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0 } set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] $ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 10ms DropTail $ns duplex-link $n3 $n2 1Mb 10ms SFQ 2

WMN Assignment
$ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n3 $n2 orient right $ns duplex-link-op $n2 $n3 queuePos 0.5 set udp0 [new Agent/UDP] $udp0 set class_ 1 $ns attach-agent $n0 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set udp1 [new Agent/UDP] $udp0 set class_ 2 $ns attach-agent $n1 $udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 500 $cbr1 set interval_ 0.005 $cbr1 attach-agent $udp1 set null0 [new Agent/Null] $ns attach-agent $n3 $null0 $ns connect $udp0 $null0 $ns connect $udp1 $null0 $ns at 0.5 "$cbr0 start" $ns at 1.0 "$cbr1 start" $ns at 4.0 "$cbr0 stop" $ns at 4.5 "$cbr0 stop" $ns at 5.0 "finish" $ns run

WMN Assignment
RESULT:

WMN Assignment Experiment 2:


AIM:
To Design and simulate a network that consists of four nodes [n0-n3]. The duplex links between n0 and n2, and n1 and n2 have 1.8 Mbps of bandwidth and 10 ms of delay. The duplex link between n2 and n3 has 1.7 Mbps of bandwidth and 20 ms of delay. Each node uses a DropTail queue, of which the maximum size is 10. A "tcp" agent is attached to n0, and a connection is established to a tcp "sink" agent attached to n3. As default, the maximum size of a packet that a "tcp" agent can generate is 1 kb. A tcp "sink" agent generates and sends acknowledgment (ACK) packet to the sender (tcp agent) and frees the received packets. An "udp" agent that is attached to n1 is connected to a "null" agent attached to n3. a "null" agent just frees the packets received. An "ftp" and a "cbr" traffic generator are attached to "tcp" and "udp" agents, respectively, and the "cbr" is configured to generate 1 kb packets at therate of 1Mbps. the "cbr" is set to start at 0.1 s and stop at 4.5 s, and "ftp" is set to start at 1.0 s and stop at 4.0 s. write the Tcl script and observe the output in NAM for this network scenario.

PROGRAM:
set ns [new Simulator] $ns color 1 Blue $ns color 1 Red set nf [open out.nam w] $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0 } set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] 5

WMN Assignment
$ns duplex-link $n0 $n2 1.8Mb 10ms DropTail $ns duplex-link $n1 $n2 1.8Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail $ns queue-limit $n2 $n3 10 $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right $ns duplex-link-op $n2 $n3 queuePos 0.5 set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2 set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb

WMN Assignment
$cbr set random_ false $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop" $ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink" $ns at 5.0 "finish" puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]" $ns run

RESULT:

WMN Assignment Experiment 3:


AIM:
A network consists of four nodes (n0-n3) as shown in Fig. L2. the duplex links between n0 and n2, and n1 and n2 have 1.2 Mbps of bandwidth and 20 ms of delay. The duplex link between n2 and n3 has 1.9 Mbps of bandwidth and 10 ms of delay. Each node uses a DropTail queue, of which the maximum size is 20. A "tcp" agent is attached to n0, and a connection is established to a tcp "sink" agent attached to n3. As default, the maximum size of a packet that a "tcp" agent can generate is 1 kb. A tcp "sink" agent generates and sends ACK packets to the sender (tcp agent) and frees the received packets. An "udp" agent that is attached to n1 is connected to a "null" agent attached to n3. A "null" agent just frees the packets received. An "ftp" and a "cbr" traffic generator are attached to "tcp" and "udp" agents, respectively, and the "cbr" is configured to generate 1 kb packets at the rate of 1Mbps. The "cbr" is set to start at 0.1 s and stop at 4.5 s, and the "ftp" is set to start at 1.0 s and stop at 4.0 s. Write the Tcl script to observe the scenario in NAM and analyze the output in the trace file for this network scenario.

PROGRAM:
set ns [new Simulator] $ns color 1 Blue $ns color 1 Red set nf [open out.nam w] $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0 } set n0 [$ns node] 8

WMN Assignment
set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] $ns duplex-link $n0 $n2 1.2Mb 20ms DropTail $ns duplex-link $n1 $n2 1.2Mb 20ms DropTail $ns duplex-link $n2 $n3 1.9Mb 10ms DropTail $ns queue-limit $n2 $n3 20 $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right $ns duplex-link-op $n2 $n3 queuePos 0.5 set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2 set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp

WMN Assignment
$cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop" $ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink" $ns at 5.0 "finish" puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]" $ns run

RESULT:

10

WMN Assignment Experiment 4:


AIM:
A network consists of six nodes (n0-n5). Node "n0" is having some data to send to the node "n5." Initially the data transmission takes place through the route n0-n1-n4-n5. But after certain time, the link between n1 and n4 fails so the data transmission takes place through the route n0n1-n2-n3-n5 until the link between n1 and n4 is up. For this network scenario, write the Tcl script to observe the scenario in NAM and to analyze the trace file for link-up and down-time.

PROGRAM:
set ns [new Simulator] $ns color 1 Blue $ns color 2 Red set file1 [open out.tr w] $ns trace-all $file1 set file2 [open out.nam w] $ns namtrace-all $file2 proc finish {} { global ns file1 file2 $ns flush-trace close $file1 close $file2 exec nam out.nam & exit 0 } $ns rtproto DV set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] 11

WMN Assignment
$ns duplex-link $n0 $n1 0.3Mb 10ms DropTail $ns duplex-link $n1 $n2 0.3Mb 10ms DropTail $ns duplex-link $n2 $n3 0.3Mb 10ms DropTail $ns duplex-link $n1 $n4 0.3Mb 10ms DropTail $ns duplex-link $n3 $n5 0.5Mb 10ms DropTail $ns duplex-link $n4 $n5 0.5Mb 10ms DropTail $ns duplex-link-op $n0 $n1 orient right $ns duplex-link-op $n1 $n2 orient right $ns duplex-link-op $n2 $n3 orient up $ns duplex-link-op $n1 $n4 orient up-left $ns duplex-link-op $n3 $n5 orient left-up $ns duplex-link-op $n4 $n5 orient right-up set tcp [new Agent/TCP/Newreno] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n5 $sink $ns connect $tcp $sink $tcp set fid_ 1 set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP $ns rtmodel-at 1.0 down $n1 $n4 $ns rtmodel-at 4.5 up $n1 $n4 $ns at 0.1 "$ftp start" $ns at 6.0 "finish" $ns run

12

WMN Assignment
RESULT:

Figure 1: Initial data transmission

Figure 2: Link 1-4 breakage

13

WMN Assignment

Figure 3: Link between n1-n4 is up

14

You might also like