Cs 261 - Computer Networks B. Tech CSE (V Semester) : Project Report
Cs 261 - Computer Networks B. Tech CSE (V Semester) : Project Report
Project Report
Group No.: 4
Section: S4-S5
Submitted By:
Kumari Renuka(U101115FCS111)
Rishabh Kumar Kandoi (U101115FCS283)
Shailesh Mohta (U101115FCS305)
Tanmay Patil (U101115FCS164)
…….
23 November 2017
TABLE OF CONTENTS
1. INTRODUCTION
2. PART A
Implement Congestion control in TCP
2.1 Introduction to Protocol
Explain Protocol features with diagram
2.2 Evaluation Features / Parameters
Explain the parameters with formula
2.3 Graphical Analysis of Protocol
Explain the graphs based on parameters.
3. PART B
TCP over a n nodes Ad-hoc network with DSDV routing protocol
2.1 Introduction to DSDV Protocol
Explain Protocol features with diagram
2.2 Evaluation Features / Parameters
Explain the parameters with formula
2.3 Graphical Analysis of DSDV Protocol
Explain the graphs based on parameters.
4. PART C
TCL script to create MIME traffic and analysis the same
2.1 Introduction to Protocol
Explain Protocol features with diagram
2.2 Evaluation Features / Parameters
Explain the parameters with formula
2.3 Graphical Analysis of Protocol
Explain the graphs based on parameters.
5. References
6. AWK codes for Part A, B and C.
INTRODUCTION
PART A
TOPIC: IMPLEMENTING CONGESTION CONTROL IN TCP
• Rishabh Kumar Kandoi
PART B
TOPIC: TCL/FTP OVER A N-NODES AD-HOC NETWORK WITH DSDV
ROUTING PROTOCOL
• Kumari Renuka
PART C
TOPIC: TCL SCRIPT TO CREATE MIME TRAFFIC AND ANALYSIS THE
SAME
• Shailesh Mohta
• Tanmay Patil
PART A
TOPIC: IMPLEMENTING CONGESTION CONTROL IN TCP
TCP is a transport layer protocol used by applications that require guaranteed delivery. It is a
sliding window protocol that provides:
1. Handling for both timeouts and retransmissions.
2. Communication service at an intermediate level between an application program and the
Internet Protocol.
3. Host-to-host connectivity at the Transport Layer of the Internet model.
4. Full duplex virtual connection between two endpoints. Each endpoint is defined by an IP
address and a TCP port number.
The byte stream is transfered in segments. The window size determines the number of bytes of
data that can be sent before an acknowledgement from the receiver is necessary.
At the lower levels of the protocol stack, due to network congestion, traffic load balancing, or
other unpredictable network behavior, IP packets may be lost, duplicated, or delivered out of
order. TCP detects these problems, requests re-transmission of lost data, rearranges out-of-order
data and even helps minimize network congestion to reduce the occurrence of the other
problems. If the data still remains undelivered, the source is notified of this failure. Once the
TCP receiver has reassembled the sequence of octets originally transmitted, it passes them to the
receiving application. Thus, TCP abstracts the application's communication from the underlying
networking details.
Below is the header format of TCP:
Major Internet applications such as the World Wide Web, email, remote administration, peer-to-
peer file sharing and streaming media applications rely on TCP. Applications that do not require
reliable data stream service may use the User Datagram Protocol (UDP), which provides a
connectionless datagram service that emphasizes reduced latency over reliability.
In TCP, the congestion window is one of the factors that determines the number of bytes that can
be outstanding at any time. Above diagram is an example in which congestion may occur when
all clients sends data at the same time to the server. The congestion window is maintained by the
sender. Note that this is not to be confused with the TCP window size which is maintained by the
receiver. The congestion window is a means of stopping a link between the sender and the
receiver from becoming overloaded with too much traffic. It is calculated by estimating how
much congestion there is on the link.
# to create the link between the nodes with bandwidth, delay and queue
$ns duplex-link $n0 $n2 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 0.3Mb 200ms DropTail
$ns duplex-link $n3 $n4 0.5Mb 40ms DropTail
$ns duplex-link $n3 $n5 0.5Mb 30ms DropTail
1. Congestion window
-- TCP and its Algorithms (Slow-Start, Congestion Avoidance, Fast Retransmit and Fast
Recovery) :
TCP is a complex transport layer protocol containing four interwined algorithms: Slow-start,
congestion avoidance, fast retransmit and fast recovery.
In Slow-start phase, TCP increases the congestion window each time an acknowledgement is
received, by number of packets acknowledged. This strategy effectively doubles the TCP
congestion window for every round trip time (RTT).
When the congestion window exceeds a threshold named ssthresh, it enters congestion
avoidance phase. TCP congestion window is increased by 1 for each RTT until a loss event
occurs.
TCP maintains a timer after sending out a packet, if no acknowledgement is received after the
timer is expired, the packet is considered as lost. However, this might take too long for TCP to
realize a packet is lost and take action. A fast retransmit algorithm is proposed to make use of
duplicate ACKs to detect packet loss. In fast retransmit, when an acknowledgement packet with
the same sequence number is received a specified number of times (normally set to 3), TCP
sender is reasonably confident that the TCP packet is lost and will retransmit the packet.
Fast recovery is closely related to fast retransmit. When a loss event is detected by TCP sender,
a fast retransmit is performed. If fast recovery is used, TCP sender will not enter slow-start
phase, instead it will reduce the congestion window by half, and “inflates” the congestion
window by calculating usable window using min(awin, cwnd+ndup), where awin is the
receiver’s window, cwnd is the congestion window, and ndup is number of dup ACK received.
When an acknowledgement of new data (called recovery ACK) is received, it returns to
congestion avoidance phase.
Calculation:
Used TCP Reno for window size calculation. cwnd_ variable was used to get the window
size from the tcp-reno.cc file.
Starts with slow start, in which:
cwnd = cwnd + 1;
This increases exponentially until packet starts dropping. When packets drops, it enters into
congestion avoidance mode, where:
ssthresh = cwnd/2;
Then, cwnd = cwnd + 1/cwnd;
i.e., increases almost linearly.
TCP Reno: When triple duplicate ACKs are received, it will halve the congestion window,
perform a fast retransmit, and enters fast recovery. If a timeout event occurs, it will enter
slow-start. TCP Reno is effective to recover from a single packet loss, but it still suffers from
performance problems when multiple packets are dropped from a window of data.
Round-trip time (RTT), also called round-trip delay, is the time required for a signal pulse or
packet to travel from a specific source to a specific destination and back again. This time
delay includes the propagation times for the paths between the two communication
endpoints.
In the context of computer networks, the signal is generally a data packet, and the RTT is also
known as the ping time. An internet user can determine the RTT by using the ping command.
Calculation:
Ping Agent was used to calculate RTT. A method of ping.cc called “recv” was being called
for the same.
RTT = avg (2 x propagation time)
It helps in calculation of Timeout, which is calculated by:
Timeout = RTT + Back-off time
3. Throughput
TCP throughput, which is the rate that data is successfully delivered over a TCP connection,
is an important metric to measure the quality of a network connection.
Throughput needs to be maximised.
Calculation:
Throughput (in bits/sec) = Number of Packets received * 8 / RTT
4. Drop Ratio
Packet loss occurs when one or more packets of data travelling across a computer network
fail to reach their destination. Packet loss is typically caused by network congestion. Packet
loss is measured as a percentage of packets lost with respect to packets sent.
Calculation:
Calculated number of packets dropped in different time intervals.
1. Congestion window
Inference:
(i) This graph shows the phase of slow start from 0 to 5,000 (approx).
(ii) It shows drop in window size when packets starts dropping, from 5,000 to 10,000.
(iii) Then from 10,000, approxiamately linear increase in window size is observed (since cwnd =
cwnd + 1/cwnd).
(iv) Then window size again drops to ‘1’ when termination signal is sent.
2. Throughput
Inference:
(i) This graph shows that throughput varies itself according to change in window size. This is so
because, when window size crosses threshold value, packets starts dropping, leading to decrease
in throughput.
(ii) When window size becomes stable, it is always expected to give maximum throughput value,
which in our case is around 1,5900 bits/sec.
3. Drop Ratio
Inference:
(i) This graph shows that as congestion window adjusts it’s size, it tries to minimize the packets
dropped in the process.
(ii) With increase in time, if number of packets dropped would be decreased, then only the
connection would be reliable, which is what exactly happening in our case, though not ideal.
PART B
TOPIC: TCL/FTP OVER A N-NODES AD-HOC NETWORK
WITH DSDV ROUTING PROTOCOL
Routing table updates in DSDV are distributed by two different types of update packets:
Full dump: This type of update packet contains all the routing information available at a
node. As a consequence, it may require several Network Protocol Data Units (NPDUs) to
be transferred if the routing table is large. Full dump packets are transmitted infrequently
if the node only experiences occasional movement.
Incremental: This type of update packet contains only the information that has changed
since the latest full dump was sent out by the node. Hence, incremental packets only
consume a fraction of the network resources compared to a full dump.
The routing table is in the form of the following given below-
Table 1 is the routing table of the node H6 at the moment before the movement of the nodes.
The Install time field in the routing table helps to determine when to delete stale routes.
In the routing information updating process, the original node tags each update packet with a
sequence number to distinguish stale updates from the new one. The sequence number is a
monotonically increasing number that uniquely identifies each update from a given node. As
a result, if a node receives an update from another node, the sequence number must be equal
or greater than the sequence number of the corresponding node already in the routing table,
or else the newly received routing information in the update packet is stale and should be
discarded. If the sequence number of one node in the newly received routing information
update packet is same as the corresponding sequence number in the routing table, then the
metric will be compared and the route with the smallest metric will be use.
The figure shows how actually the routing table of the node H6 is getting updated. Firstly, the
sequence number is considered in order to update the routing table. If the sequence numbers
are equal then the route with minimum metric value is selected and updating takes place
accordingly.
Responding to Topology Changes -
Links can be broken when the mobile nodes move from place to place or have been shut down
etc. . The metric of a broken link is assigned infinity. When a link to next hop has broken, any
route through that next hop is immediately assigned an infinity metric and an updated sequence
number. Because link broken qualifies as a significant route change, the detecting node will
immediately broadcast an update packet and disclose the modified routes.
Figure 3 illustrates an example of link broken. We assume the link between the node H1 and
H7 is broken . ode H7 detects the link broken and broadcasts an update packet (Figure 4a) to
node H6. Node H6 updates its routing table with the newly received routing information (odd
sequence number – S517_H1 and ∞ metric) of entry H1. It means that the link to node H1 is
broken.
TCL Script have been written in order to show the DSDV protocol simulation. By running the
nam file the following results have been obtained.
$ns run
FIG 4: RESULTS OF DSDV.tcl SCRIPT
SIMULATION RESULTS
By making changes in the dsdv.cc file in all in one folder, the following results have been
evaluated by executing the above tcl script and the results are as follow-
2) Printing the updated routing table. The following are the updated roots with source,
destination, metrics, next hop, sequence number. The following is the output-
3) The following given below gives the simulation results such as the node from which the
update need to take place, the number of entries in the routing table, the number of entries which
is to be updated in the routing table and the number of entries which remains unchanged.
NUMBER OF NODES
SIMULATION TIME
Figure 6 display the x-graph in which the results of the change in PDR is shown with respect to
the increasing number of nodes. As a result we can see that the PDR increases with increase in
number of nodes up-to the certain level then decreases gradually and then increase.
FIG 7: NUMBER OF NODES VS PACKET DROPPED
Figure 9 gives the information about the change in PDR value with increase in the simulation
time. The results shows that the PDR value gradually decreases with increase in the simulation
time.
ADVANTAGES OF DSDV PROTOCOL
DSDV assumes that all wireless links in an ad hoc network are bi-directional. However, this is
not true in reality. Wireless media is different from wired media due to its asymmetric
connection. Unidirectional links are prevalent in wireless networks.
• The presence of unidirectional links creates the following problems for DSDV protocol-
• Knowledge Asymmetry: Over the unidirectional links, the sink nodes know the existence
of the source nodes, but the source nodes cannot assume the existence of the sink nodes.
Sink Unreachability: In DSDV, the destination node initiates the path updates. Over a
unidirectional link, there might be no way that a sink node can broadcast its existence.
• It is difficult to determine the maximum setting time.
• It has excessive communication overhead due to periodic and triggered updates. Each
node must have a complete routing table.
PART C
TOPIC: TCL SCRIPT TO CREATE MIME TRAFFIC AND
ANALYSIS THE SAME
Internet: audio, video, images, application programs, and other kinds, as well as the ASCII text
handled in the original protocol, the Simple Mail Transport Protocol (SMTP). In 1991, Nathan
Borenstein of Bellcore proposed to the IETF that SMTP be extended so that Internet (but mainly
Web) clients and servers could recognize and handle other kinds of data than ASCII text. As a
result, new file types were added to "mail" as a supported Internet Protocol file type.
The PackMime Internet traffic model was developed by researchers in the Internet Traffic
Research group at Bell Labs, based on recent Internet traffic traces. PackMime includes a model
of HTTP traffic, called PackMime-HTTP. The traffic intensity generated by PackMime-HTTP is
controlled by the rate parameter, which is the average number of new HTTP connections tarted
each second. The PackMime-HTTP implementation in ns-2, developed at UNC-Chapel Hill, is
capable of generating HTTP/1.0 and HTTP/1.1 (persistent, non-pipelined) connections. The goal
of PackMime-HTTP is not to simulate the interaction between a single web client and web
server, but to simulate the TCP-level traffic generated on a link shared by many web clients and
servers. A typical PackMime-HTTP instance consists of two ns nodes: a server node and a client
node. It is important to note that these nodes do not correspond to a single web server or web
client. A single PackMime-HTTP client node generates HTTP connections coming from a
“cloud” of web clients. Likewise, a single PackMime-HTTP server node accepts and serves
HTTP connections destined for a “cloud” of web servers. A single web client is represented by a
single PackMime-HTTP client application, and a single web server is represented by a single
PackMime-HTTP server application. There are many client applications assigned to a single
client ns node, and many server applications assigned to a single server ns node.
PackMimeHTTP is an ns object that drives the generation of HTTP traffic. Each
PackMimeHTTP object controls the operation of two types of Applications, a PackMimeHTTP
server Application and a PackMimeHTTP client Application. Each of these Applications is
connected to a TCP Agent (Full-TCP). Note: PackMime-HTTP only supports Full-TCP agents.
Each web server or web client cloud is represented by a single ns node that can produce and
consume multiple HTTP connections at a time. For each HTTP connection, PackMimeHTTP
creates (or allocates from the inactive pool, as described below) server and client Applications
and their associated TCP Agents.
PackMimeHTTP sets a timer to expire when the next new connection should begin. The time
between new connections is governed by the connection rate parameter supplied by the user.
New connections are started according to the connection arrival times without regard to the
completion of previous requests, but a new request between the same client and server pair (as
with HTTP 1.1)
begins only after the previous requestresponse pair has been completed. PackMimeHTTP
handles the reuse of Applications and Agents that have completed their data transfer. There are
5 pools used to maintain Applications and Agents – one pool for inactive TCP Agents and one
pool each for active and inactive client and server Applications. The pools for active
Applications ensure that all active Applications are destroyed when the simulation is finished.
Active TCP Agents do not need to be placed in a pool because each active Application contains a
pointer to its associated TCP Agent. New objects are only created when there are no Agents or
Applications available in the inactive pools.
Example Topology Using PackMimeHTTP and DelayBox. The cloud of web clients is a single
ns node, and the cloud of web servers is a single ns node. Each of the DelayBox nodes is a single
ns node.
2.2 Evaluation Features / Parameters
Test-packmime-.tcl
# useful constants
set CLIENT 0
set SERVER 1
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Setup Simulator
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Setup Topology
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# $bw Mb
# client -------- server
# cloud 0ms cloud
#
# n(0) n(1)
# create nodes
set n(0) [$ns node]
set n(1) [$ns node]
# create link
$ns duplex-link $n(0) $n(1) ${bw}Mb 0ms DropTail
# setup TCP
Agent/TCP/FullTcp set segsize_ 1460; # set MSS to 1460 bytes
Agent/TCP set window [expr round ($window * 1024.0 / 1500.0)]
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Setup PackMime
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Setup PackMime Random Variables
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
global defaultRNG
# create RandomVariables
set flow_arrive [new RandomVariable/PackMimeHTTPFlowArrive $rate]
set req_size [new RandomVariable/PackMimeHTTPFileSize $rate $CLIENT]
set rsp_size [new RandomVariable/PackMimeHTTPFileSize $rate $SERVER]
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Packet Tracing
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
proc trace {} {
global ns n
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Cleanup
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
proc finish {} {
global ns pm reqsizeRNG rspsizeRNG flowRNG req_size rsp_size flow_arrive
$ns flush-trace
# delete PackMime
delete $pm
# delete Simulator
delete $ns
exit 0
}
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Simulation Schedule
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Start the Simulation
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
$ns run
Evaluation of Mime is done here on the basis of PDR and Information transfer in
different scenarios.
PDR -24
PDR - 24
PDR -24
B.1) 10 Mb
Received packets=715
PDR= 24
B.2) 100Mb
Send packets=2925
Received packets=715
PDR= 24
Send packets=8
Received packets=8
PDR= 48
Send packets=4671
Received packets=1315,
PDR= 193
Send packets=4671
Received packets=1431
PDR= 211
Send packets=30186
Received packets=8441
PDR= 735
2.3 Graphical Analysis of Protocol
1. Throughput.awk
BEGIN {
#Initialisation part
}
{
if (seq_no == 0)
startTime = time;
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0)) #since
seq_no = -1 for ping
{
endTime = time;
TotalPktRec += pktSize;
}
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime1 = time;
TotalPktRec1 += pktSize;
}
}
else if (time >=35 && time < 40)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime2 = time;
TotalPktRec2 += pktSize;
}
}
else if (time >=40 && time < 45)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime3 = time;
TotalPktRec3 += pktSize;
}
}
else if (time >=45 && time < 50)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime4 = time;
TotalPktRec4 += pktSize;
}
}
else if (time >=50 && time < 55)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime5 = time;
TotalPktRec5 += pktSize;
}
}
else if (time >=55 && time < 60)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime6 = time;
TotalPktRec6 += pktSize;
}
}
else if (time >=60 && time < 65)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime7 = time;
TotalPktRec7 += pktSize;
}
}
else if (time >=65 && time <67)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime8 = time;
TotalPktRec8 += pktSize;
}
}
else if (time >=67 && time <69)
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime9 = time;
TotalPktRec9 += pktSize;
}
}
else
{
if ((event = "r") && ((to == 3) || (to == 4) || (to == 5)) && (seq_no > 0))
#since seq_no = -1 for ping
{
endTime10 = time;
TotalPktRec10 += pktSize;
}
}
}
END {
throughput = (TotalPktRec * 8)/(endTime - startTime); #in bits/sec
DropRatio.awk
BEGIN {
#Initialisation part
}
{
#
if (event == "d" && from == 2)
TotalPktDropped ++ ;
END {
printf ("\nOverall Packets dropped: %d\n", TotalPktDropped);
PART B: TCP over a n nodes Ad-hoc network with DSDV routing protocol
PDR.awk File
BEGIN {
droppacket=0;
sendLine = 0;
recvLine = 0;
fowardLine = 0;
if(mseq==0)
mseq=10000;
for(i=0;i<mseq;i++){
rseq[i]=-1;
sseq[i]=-1;
}
}
$0 ~/^s.* AGT/ {
# if(sseq[$6]==-1){
sendLine ++ ;
# sseq[$6]=$6;
#}
$0 ~/^r.* AGT/{
# if(rreq[$6]==-1){
recvLine ++ ;
# sseq[$6]=$6;
# }
$0 ~/^f.* RTR/ {
fowardLine ++ ;
}
# Final output
END {
droppacket=sendLine-recvLine
BEGIN {
recvdSize = 0
txsize=0
drpSize=0
startTime = 0
stopTime = 0
thru=0
event = $1
time = $2
node_id = $3
pkt_size = $8
level = $4
startTime = time
# pkt_size -= hdr_size
txsize++;
# Update total received packets’ size and store packets arrival time
stopTime = time
# pkt_size -= hdr_size
recvdSize++
# thru=(recvdSize/txsize)
# pkt_size -= hdr_size
drpSize++
END {
PART C:TCL script to create MIME traffic and analysis the same
BEGIN {
sendpkt=0;
rcvpkt=0;
sttime=0;
flag=0;
timee=0;
}
{
event=$1;
time=$2;
from=$3;
to=$4;
flowid=$8;
if( event="+")
{sendpkt++;
if(flag==0)
{sttime=time;
flag=1;
}
}
if( event=="r")
rcvpkt++;
}
END {
timee=time-sttime;
pdr=rcvpkt/timee;
printf("Send packets=%d\n recieved packets=%d\n , PDR= %d \n",sendpkt,rcvpkt,pdr);
}
BEGIN {
sendpkt=0;
rcvpkt=0;
sttime=0;
flag=0;
timee=0;
}
{
event=$1;
time=$2;
from=$3;
to=$4;
flowid=$8;
if(from==0 && event="+")
{sendpkt++;
if(flag==0)
{sttime=time;
flag=1;
}
}
if( event=="r")
rcvpkt++;
}
END {
timee=time-sttime;
pdr=rcvpkt/timee;
printf("Send packets=%d\n recieved packets=%d\n , PDR= %d \n",sendpkt,rcvpkt,pdr);
}
REFERENCE