0% found this document useful (0 votes)
30 views5 pages

Exp 3 1

The document implements an Ethernet LAN simulation using NS-2 with multiple nodes and plots the congestion window for different source/destination pairs. It creates 5 nodes, connects them in a LAN with links of 50Mb and 100ms delay. Two FTP sources are attached to nodes n0 and n2 sending to sinks at n5 and n3 respectively. The congestion windows of the two connections are traced and plotted versus time.

Uploaded by

Dhanya Sharanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views5 pages

Exp 3 1

The document implements an Ethernet LAN simulation using NS-2 with multiple nodes and plots the congestion window for different source/destination pairs. It creates 5 nodes, connects them in a LAN with links of 50Mb and 100ms delay. Two FTP sources are attached to nodes n0 and n2 sending to sinks at n5 and n3 respectively. The congestion windows of the two connections are traced and plotted versus time.

Uploaded by

Dhanya Sharanya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

3.

Implement an Ethernet LAN using n nodes and set multiple traffic


nodes and plot congestion window for different source /destination.

#Make a NS simulator
set ns [new Simulator]
set tf [open lab3.tr w]
$ns trace-all $tf

set nf [open lab3.nam w]


$ns namtrace-all $nf

# Create the nodes,color and label


set n0 [$ns node]
$n0 color "magenta"
$n0 label "src1"
set n1 [$ns node]
$n1 color "red"
set n2 [$ns node]
$n2 color "magenta"
$n2 label "src2"
set n3 [$ns node]
$n3 color "blue"
$n3 label "dest2"
set n4 [$ns node]
$n4 shape square
set n5 [$ns node]
$n5 color "blue"
$n5 label "dest1"

KRISHNA GUDI, CSE DEPT, KSIT 1


#Creates a lan from a set of nodes given by <nodelist>. Bandwidth, delay
#characteristics along with the link-layer, Interface queue, Mac layer and
#channel type for the lan also needs to be defined.

$ns make-lan "$n0 $n1 $n2 $n3 $n4" 50Mb 100ms LL Queue/DropTail
Mac/802_3

# Create the link


$ns duplex-link $n4 $n5 1Mb 1ms DropTail
# Create the node position
$ns duplex-link-op $n4 $n5 orient right

# Add a TCP sending module to node n0


set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
# Setup a FTP traffic generator on "tcp0"
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ftp0 set packetSize_ 500
$ftp0 set interval_ 0.0001

# Add a TCP receiving module to node n5


set sink0 [new Agent/TCPSink]
$ns attach-agent $n5 $sink0
# Direct traffic from "tcp0" to "sink1"
$ns connect $tcp0 $sink0

# Add a TCP sending module to node n2


set tcp1 [new Agent/TCP]
$ns attach-agent $n2 $tcp1

KRISHNA GUDI, CSE DEPT, KSIT 2


# Setup a FTP traffic generator on "tcp1"
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ftp1 set packetSize_ 600
$ftp1 set interval_ 0.001

# Add a TCP receiving module to node n3


set sink1 [new Agent/TCPSink]
$ns attach-agent $n3 $sink1

# Direct traffic from "tcp1" to "sink1"


$ns connect $tcp1 $sink1
set file1 [open file1.tr w]
$tcp0 attach $file1
set file2 [open file2.tr w]
$tcp1 attach $file2
$tcp0 trace cwnd_
$tcp1 trace cwnd_

# Define a 'finish' procedure


proc finish { } {
global ns nf tf
$ns flush-trace
close $tf
close $nf
exec nam lab3.nam &
exit 0
}

KRISHNA GUDI, CSE DEPT, KSIT 3


# Schedule start/stop times
$ns at 0.1 "$ftp0 start"
$ns at 5 "$ftp0 stop"
$ns at 7 "$ftp0 start"
$ns at 0.2 "$ftp1 start"
$ns at 8 "$ftp1 stop"
$ns at 14 "$ftp0 stop"
$ns at 10 "$ftp1 start"
$ns at 15 "$ftp1 stop"

# Set simulation end time


$ns at 16 "finish"
$ns run

AWK:
BEGIN {
}
{
if($6=="cwnd_")
printf("%f\t%f\t\n",$1,$7);
}
END {
}

KRISHNA GUDI, CSE DEPT, KSIT 4


Topology:

Output: xgraph

KRISHNA GUDI, CSE DEPT, KSIT 5

You might also like