0% found this document useful (0 votes)
67 views18 pages

Network Programs: Department of Computer Science and Engineering Malnad College of Engineering

This document describes a network simulation experiment to measure TCP and UDP bandwidth sharing over a dumbbell topology network. It involves setting up a TCP connection between nodes 0 and 6 and a UDP connection between nodes 1 and 7 that share a common bottleneck link between nodes 2 and 3. The experiment varies the rate of UDP traffic and observes its effect on the TCP throughput. It is found that when UDP rate is low, both protocols share bandwidth fairly, but as UDP rate increases, it occupies more of the bandwidth at the expense of TCP throughput.

Uploaded by

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

Network Programs: Department of Computer Science and Engineering Malnad College of Engineering

This document describes a network simulation experiment to measure TCP and UDP bandwidth sharing over a dumbbell topology network. It involves setting up a TCP connection between nodes 0 and 6 and a UDP connection between nodes 1 and 7 that share a common bottleneck link between nodes 2 and 3. The experiment varies the rate of UDP traffic and observes its effect on the TCP throughput. It is found that when UDP rate is low, both protocols share bandwidth fairly, but as UDP rate increases, it occupies more of the bandwidth at the expense of TCP throughput.

Uploaded by

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

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

Jnana Sangama, belagvi-59001

A NETWORK LAB ACTIVITY REPORT


On

NETWORK PROGRAMS
Submitted by:
Varsha C M -4MC19CS182

Submitted to:
MRS.KAVYASHREE
Assistant Professor

Department of Computer Science and Engineering


Malnad College of Engineering
Hassan – 573201, Karnataka, India
2022-23
Networks Laboratory Activity

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 :

set ns [new Simulator]


$ns rtproto LS
set node1 [$ns node] set
node2 [$ns node] set
node3 [$ns node] set
node4 [$ns node] set
node5 [$ns node] set
node6 [$ns node] set
node7 [$ns node] set tf
[open out.tr w]
$ns trace-all $tf
set nf [open out.nam w]
$ns namtrace-all $nf
$node1 label "node 1"
$node1 label "node 2"
$node1 label "node 3"
$node1 label "node 4"
$node1 label "node 5"
$node1 label "node 6"
$node1 label "node 7"
$node1 label-color blue
$node2 label-color red
$node3 label-color red
$node4 label-color blue
$node5 label-color blue
$node6 label-color blue
$node7 label-color blue
$ns duplex-link $node1 $node2 1.5Mb 10ms Drop
$ns duplex-link $node2 $node3 1.5Mb 10ms DropTail
$ns duplex-link $node3 $node4 1.5Mb 10ms DropTail
$ns duplex-link $node4 $node5 1.5Mb 10ms DropTail
$ns duplex-link $node5 $node6 1.5Mb 10ms DropTail
$ns duplex-link $node6 $node7 1.5Mb 10ms DropTail
$ns duplex-link $node7 $node1 1.5Mb 10ms DropTail
$ns duplex-link-op $node1 $node2 orient left-down
$ns duplex-link-op $node2 $node3 orient left-down
$ns duplex-link-op $node3 $node4 orient right-down
$ns duplex-link-op $node4 $node5 orient right
$ns duplex-link-op $node5 $node6 orient right-up
$ns duplex-link-op $node6 $node7 orient left-up
$ns duplex-link-op $node7 $node1 orient left-up set
tcp2 [new Agent/TCP]
$ns attach-agent $node1 $tcp2 set
sink2 [new Agent/TCPSink]
$ns attach-agent $node4 $sink2
$ns connect $tcp2 $sink2
set traffic_ftp2 [new Application/FTP]
$traffic_ftp2 attach-agent $tcp2
$ns at 0.5 "traffic_ftp2 start"
$ns rtmodel-at 1.0 down $node2 $node3
$ns rtmodel-at 2.0 up $node2 $node3
$ns at 3.0 "traffic_ftp2 start"
$ns at 4.0 "traffic_ftp2 stop"
$ns at 5.0 "finish"
$ns run

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.

The Dynamic Source Routing protocol (DSR) is a simple and efficient


routing protocol designed specifically for use in multi-hop wireless ad hoc
networks of mobile nodes. DSR allows the network to be completely self-
organizing and self-configuring, without the need for any existing network
infrastructure or administration
02.Measuring Network Performances - Bandwidth sharing between TCP and UDP

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:

set by [lindex Sargv 0 ]


set val(stop) 100.0; #time of simulation end
#Create a ns simulator
set ns [new Simulator]
$ns color 1 Blue
$ns color 2 Red

#Open the NS trace file


set tracefile [open p5.tr
w]
$ns trace-all $tracefile

#Open the NAM trace file


set namfile [open p5.nam w]
$ns namtrace-all $namfile

#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"

#Create links between nodes


$ns duplex-link $n2 sno 1.0Mb 10ms DropTail
$ns queue-limit $n2 Sno 5
$ns duplex-link $n2 $n3 ${bv) Mb 10ms DropTail
$ns queue-limit $n2 $n3 2
$ns duplex-link $n3 $n4 1.0Mb 10ms DropTail
$ns queue-limit $n3 $n4 5
$ns duplex-link $n3 $n5 1.0Mb 10ms DropTail
$ns queue-limit 5n3 $n5 5
$ns duplex-link $n5 Sn7 1.0Mb 10ms DropTail
$ns queue-limit $n5 5n7 5
$ns duplex-link $n4 Sn6 1.0Mb 10ms DropTail
$ns queue-limit $n4 $n6 5

#Give node position (for NAM)


$ns duplex-link-op $n2 $no orient left-up
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n2 5n3 orient right
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link-op $n3 Sn5 orient right-down
$ns duplex-link-op $n5 sn7 orient right
$ns duplex-link-op $n4 Sn6 orient right

#Setup a TCP connection

set tcp0 [new Agent/TCP]


$ns attach-agent $n0 $tcp0
set sink6 [new Agent/TCPSink]
$ns attach-agent $n6 $sink6
$ns connect $tcp0 $sink6
$tcp0 set packetSize_1500

#Setup a UDP connection

set udp1 [new Agent/UDP]


$ns attach-agent Sn1 $udpl
set null7 [new Agent/Null]
$ns attach-agent $n7 $null7
$ns connect Sudp1 $null7
$udp1 set packetSize_1500
$tcp0 set fid_1
$udpl set fid_2

#Setup a FTP Application over TCP

connection set ftp0 [new Application/FTP)


$ftp0 attach-agent $tcp0
$ns at 0.01 "ftp0 start"
$ns at 40:0 "$ftp0 stop"

#Setup a CBR Application over UDP connection

set cbr1 [new Application/Traffic/CBR]


$cbr1 attach-agent $udpl
$ns at 0.01 "$cbr1 start"
$ns at 40.0 "$cbr1 stop"

#Define a finish' procedure

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

 <number_of_pairs>: The number of sender-receiver pairs this link can support


in the dumbbell topology.
 <propagation_delay>: The propagation delay of link L.
 <bandwidth>: The bandwidth of link L. Due to some system limitations, the
relayer only supports up to a 50Mb/s link. For more accurate emulation results,
you should configure the link capacity to be less than 50Mb/s.
 <buffer_size>: The router1's buffer size. Packets from a sender to a receiver will
first wait in this buffer and then get transmitted on link L. When the buffer is
full, the router begins to discard packets using the FIFO policy. The buffer size is
usually configured to be the delay bandwidth product.
 <pair>: This section specifies the incoming IP/port numbers of a
sender/receiver, and the relaying ports. For instance, in Figure 1, the sender
A1 is running on linux21, port 10000, and the receiver A2 is running on linux 22,
port 20000. The relayer is running on linux25, using port 50001 to receive A 1's
packets. It may delay or discard A1's packets based on its available buffer space,
and then send these packets via port 50002 to the receiver A 2. Similarly, ACK
packets from A2 will be relayed via the relayer back to A1. Note that the relayer
will not drop acknowledgment's packets. You can modify the configuration in
this section to test different numbers of sender-receiver pairs.
 <CPU_frequency>: The CPU frequency on which this relayer is running. You can
type "cat /porc/cpuinfo" to find out this configuration. To achieve a high
emulation accuracy, the relayer is counting CPU cycles for timing.
 <enable_log>: 0 to disable packet log, and 1 to enable packet log. The relayer
uses fprintf(stderr, "...") to print out packet logs, including "buffer PKT", "drop
PKT", "transmit PKT" and "relay PKT". Logging is time consuming and may
interfere with packet transmissions.
DESCRIPTION :
This contain 6 nodes where one is of tcp and udp configured.
The dumbbell topology consists of a number of TCP senders (S), TCP receivers (R),
routers (X and Y) and several links.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy