Professional Documents
Culture Documents
Aryaman Kolhe
20BBS0122
Question 1
Simulate a four node point-to-point network with the links connected as follows: n0-n2, nl
n2 and n2-n3. Apply TCP agent between n0-n3 and UDP between nl-n3. Apply relevant
applications over TCP and UDP agents changing the parameter and determine the number of
packets sent by TCP/
UDP.
Code
proc finish {} {
# follow this spacing
global ns tracefile nf
$ns flush-trace
# flushes the previous outputs ?
close $nf
close $tracefile
exec nam out.nam &
exit 0
}
$ns run
# to execute the program
Output
The simulation starts at 0 seconds. From 1 second onwards, packets are sent from node 0 to
node 3 (blue) via the TCP protocol. Simultaneously, from 1 second onwards, packets are
sent from node 1 to node 3 (black).
At 1.1 seconds – (Packets are starting to be transferred)
The blue spec in the above image denotes the acknowledgement sent back to node 0 (via
TCP).
We also see some packet loss since they are colliding at node 2.
Question 2
Simulate a four node ring network. Apply relevant applications over TCP and UDP
agents changing the parameter.
Code
# What we are doing. From 1.0 to 2.5 seconds, we are transferring packets from node 0 to
node 2 via the TCP protocol.
# From 2.6 to 4.0 seconds, we are transferring packets from node 1 to node 0 via the UDP
protocol.
proc finish {} {
# follow this spacing
global ns tracefile nf
$ns flush-trace
# flushes the previous outputs ?
close $nf
close $tracefile
exec nam out.nam &
exit 0
}
$ns run
# to execute the program
Output
What we are doing. From 1.0 to 2.5 seconds, we are transferring packets from node 0 to
node 2 via the TCP protocol. From 2.6 to 4.0 seconds, we are transferring packets from node
1 to node 0 via the UDP protocol.
From node 0 to node 2 (TCP) at 1.22 seconds