Network Programs: Department of Computer Science and Engineering Malnad College of Engineering
Network Programs: Department of Computer Science and Engineering Malnad College of Engineering
NETWORK PROGRAMS
Submitted by:
Varsha C M -4MC19CS182
Submitted to:
MRS.KAVYASHREE
Assistant Professor
1. Write a TCL script to simulate the following scenario with ns2 simulator.
Consider six nodes, (as shown in the figure below) moving within a flat topology of 700m x 700m
The initial positions of nodes are 0 (150,300) ,1 (300,500),2 (500,500),3(300,100),4(500,100) and
5(650,300) respectively. A TCP connection is initiated between node 0 (source) and node 5
(destination) through node 3 and node 4 i.e., the route is 0-3-4-5. At time t = 3 seconds the FTP
application runs over it. After time t=4.0 sec, node 3 (300,100) moves towards node 1 (300,500)
with a speed of 5.0m/sec and after some time, the path break, then the data transmit with a new
path via node 1 and node 2 i.e., the new route 0-1-2-5. The simulation lasts for 60 secs. In the
above said case both the route has equal cost. Use DSR as the routing protocol and the IEEE
802.11 MAC protocol. Now Analyse the trace file and determine when the use of second route
commence and plot the number of packets received by each node over the entire time duration of
the simulation
PROGRAM :
OUTPUT:
in this we can distinguish among different network standards that are tcp and
and udp. These can distinguish among tcp1 and tcp 2
it emerges to the data rate upto number of bytes received per required upto
maximum extinct. The different color lines determines the datarate in the
graph.
Consider the dumbbell topology from our previous exercise: Node # 0 is a TCP source, and the
corresponding sink is at node # 6. Node # 1 is a UDP source (CBR traffic) with a null agent
attached to node # 7. These two traffic flows through the common link 2-3. The aim of this
exercise is to examine how TCP and UDP share the bandwidth between themselves when the
rate of CBR traffic is changed. Set the TCP packet size to 1460 B. The UDP and CBR packet
sizes are 1500 B. All the links in the network have same bandwidths (say, 4 Mb), delay and
queue types.
Part 1:
• Set the initial rate of CBR traffic to 0.5 Mb. Run the simulation, and plot the "Bytes
Received" by node #s 4 and 5 (sinks for TCP and UDP traffic)
• Now, increment the rate up to 4 Mb, the link bandwidth, in steps of 0.5 Mb. Run the
simulation and plot the graphs again. How does the graphs change after each run? What’s
the nature of the graphs when the rate of CBR traffic is 50% of the bandwidth?
Part 2: Behaviour of UDP
• Reduce the bandwidth of the link 2-3 to say, 2 Mb. Repeat the above steps and observe the
graphs in this case. From the graphs plotted observe how UDP occupies a larger portion of
the bandwidth. How does the behaviour change for other variations of TCP (New Reno,
Vegas)?
Program:
#Create 8 nodes
set no [$ns node]
$no label "ftp source"
$nl shape square
set nl [$ns node]
n1 label "cbr source"
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6[$ns node]
$n6 label "ftp
receiver" set n7 [$ns
node]
$n7 label "cbr receiver"
proc finish {} {
global ns tracefile namfile bv
$ns flush-trace
close $tracefile
close $namfile
exec nam p5.nam &
exec awk -f p5.awk -v var1=$bv p5.tr >> p51.tr &
exec awk -f p5 delay awk p5.tr| xgraph
exit 0
}
$ns at $val(stop) "finish"
$ns run
OUTPUT:
DUMBELL TOPOLOGY:
A1 sends file1 to A2. B1 sends file2 to B2. Both files, file1 and file2, can be generated
by the generator. These connections share the bottleneck link L, which is
emulated by the relayer code we provide. You are required to implement a
congestion control algorithm that efficiently and fairly utilizes L's capacity.
Packet format
There are two types of packets, Data packets and Ack-only packets. You can tell the
type of a packet by length. The length of a data packet varies from 16 to 1016 bytes,
and ACK packets are of 12 bytes
AWK 1 FILE:
BEGIN {
count=0;
time=0.01;
}
{
if ($1 == "R” && $3 == 2 && $4 == 3)
{
count += $6;
time=$2;
}
}
END {
printf("%lf\t %lf\n", var1,((count/time)*(8/1000000.0)));
}
OUTPUT:
AWK 2 FILE:
BEGIN{
hpid = 0;
}
{
e=$1;
t=$2;
fid=$8;
pid=$12:
d=$10:
if(pid > hpid)
hpid = pid:
if( st[pid] == 0)
st[pid]=t;
if(fid == 1 && e == "r" && s==0 && d==6)
{
et[pid]=t:
}
else {
et[pid]=0;
}
}
END {
for(pid=0: pid<=hpid: pid++) {
start = st[pid];
end = et[pid]);
packet duration = end-start;
if( start < end)
printf("%d %lf\n",pid,packet_duration);
}
}
a standard single dumbbell topology has been used As shown in the network topology, there
are n competing senders (S1; S2; S3; ?; Sn) send data synchronously to n receivers (D1; D2;
D3; ?; Dn) through a shared single bottleneck. All nodes of sources and destinations are
1
connected to bottleneck routers over LAN with 1 Gbps speed and 1 ms propagation delay.
While the bottleneck link is 1 Gbps speed with a propagation delay of 100 ms. Consequently,
the proper bandwidth of the shared bottleneck, which is needed by the concurrent senders, is
4 Gbps while the available is only 1 Gbps, this in order to simulate a real congested