Professional Documents
Culture Documents
Practical-9: Wireshark Packet Capture and Measurement of Various Types of Delay in TCP
Practical-9: Wireshark Packet Capture and Measurement of Various Types of Delay in TCP
Practical-9
AIM: Wireshark packet capture and Measurement of various types of Delay in TCP
---------------------------------------------------------------------------------------------------------------------------
Tools required:
1. Desktop Computer
2. Cisco Packet Tracer
Simulate different scenarios given below in Cisco packet tracker and fill up table.
Note: While applying IP address, student need to allocate IP address as per his/her student
ID. For Example, if student ID is 20ce005 then IP address allocation for first network should
start with 5.0.0.0. For subsequent network, it should start with ID+1 i.e. 6.0.0.0, 7.0.0.0. and
so on.
Submission: After writing answer into this word document, Student need to change name to his ID
followed by practical number. Ex 20ce005_Pr1.docx. Upload on assignment segment.
Rubrics: Nicely drafted document with clarity in answers leads to full marks. Otherwise, submission
carries proportional mark.
Recommended to type, avoid copy-past to increase your typing skill.
Executing fourth.cc
$ cp examples/tutorial/fourth.cc scratch/fourth.cc
Running fourth.cc
$ ./waf --run scratch/fourth
Output will be
$ Traced 0 to 1234
Executing fifth.cc
Page 1 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
$ cp examples/tutorial/fifth.cc scratch/fifth.cc
void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
m_socket->Send (packet);
Page 2 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
void
MyApp::ScheduleTx (void)
{
if (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ())));
m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this);
}
}
static void
CwndChange (uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "\t" << newCwnd);
}
It will show output time and change in Congestion Window Size
static void
RxDrop (Ptr<const Packet> p)
{
NS_LOG_UNCOND ("RxDrop at " << Simulator::Now ().GetSeconds ());
}
Page 3 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
It will called when packet are dropped and So after this big change in Congestion Window
size is reduced according to Congestion algorithm defined.
Running fifth.cc
$ ./waf --run scratch/fifth
Congestion Window (cwnd) is a TCP state variable that limits the amount of data the TCP can send
into the network before receiving an ACK.
MSS: Maximum Segment Size refers to highest payload size, an end device is ready to accept within
single packet
Slow Start Phase : exponential increment – In this phase after every RTT the congestion window size
increments exponentially.
Initially cwnd = 1
After 1 RTT, cwnd = 2^(1) = 2
2 RTT, cwnd = 2^(2) = 4
3 RTT, cwnd = 2^(3) = 8
Page 4 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
Congestion Avoidance Phase : additive increment – This phase starts after the threshold value also
denoted as ssthresh. The size of cwnd(congestion window) increases additive. After each RTT cwnd =
cwnd + 1.
Initially cwnd = i
After 1 RTT, cwnd = i+1
2 RTT, cwnd = i+2
3 RTT, cwnd = i+3
Congestion Detection Phase : multiplicative decrement – If congestion occurs, the congestion window
size is decreased. The only way a sender can guess that congestion has occurred is the need to
retransmit a segment. Retransmission is needed to recover a missing packet which is assumed to have
been dropped by a router due to congestion. Retransmission can occur in one of two cases: when the
RTO timer times out or when three duplicate ACKs are received.
Page 5 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
$ gnuplot
gnuplot> set terminal png size 640,480
gnuplot> set output "cwnd.png"
gnuplot> plot "cwnd.dat" using 1:2 title 'Congestion Window' with linespoints
gnuplot> exit
Page 6 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
Here On 0 to 1 second slow-start is happening and Rxdrop is dropped at 1.13 second so it will go
congestion avoidance phase and addictive increase is happened. Rxdrop happens in near 1.4 second
and then additive increase happen and then it repeats.
Page 7 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/log.h"
#include "ns3/tcp-socket-base.h"
NS_LOG_COMPONENT_DEFINE ("SecondScriptExample");
class MyApp : public Application
{
public:
MyApp ();
virtual ~MyApp();
private:
virtual void StartApplication (void);
virtual void StopApplication (void);
Ptr<Socket> m_socket;
Address m_peer;
uint32_t m_packetSize;
uint32_t m_nPackets;
DataRate m_dataRate;
EventId m_sendEvent;
bool m_running;
uint32_t m_packetsSent;
};
MyApp::MyApp ()
: m_socket (0),
m_peer (),
m_packetSize (0),
m_nPackets (0),
m_dataRate (0),
m_sendEvent (),
Page 8 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
m_running (false),
m_packetsSent (0)
{
}
MyApp::~MyApp()
{
m_socket = 0;
}
void
MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize,
uint32_t nPackets, DataRate dataRate)
{
m_socket = socket;
m_peer = address;
m_packetSize = packetSize;
m_nPackets = nPackets;
m_dataRate = dataRate;
}
void
MyApp::StartApplication (void)
{
m_running = true;
m_packetsSent = 0;
m_socket->Bind ();
m_socket->Connect (m_peer);
SendPacket ();
}
void
MyApp::StopApplication (void)
{
m_running = false;
if (m_sendEvent.IsRunning ())
{
Simulator::Cancel (m_sendEvent);
}
if (m_socket)
{
m_socket->Close ();
}
}
void
MyApp::SendPacket (void)
{
Ptr<Packet> packet = Create<Packet> (m_packetSize);
m_socket->Send (packet);
Page 9 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
void
MyApp::ScheduleTx (void)
{
if (m_running)
{
Time tNext (Seconds (m_packetSize * 8 / static_cast<double>
(m_dataRate.GetBitRate ())));
m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket,
this);
}
}
static void
CwndChange (uint32_t oldCwnd, uint32_t newCwnd)
{
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "\t" << newCwnd);
}
static void
RxDrop (Ptr<const Packet> p)
{
NS_LOG_UNCOND ("RxDrop at " << Simulator::Now ().GetSeconds ());
}
int
main (int argc, char *argv[])
{
bool verbose = true;
uint32_t nCsma = 3;
CommandLine cmd;
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices",
nCsma);
cmd.AddValue ("verbose", "Tell echo applications to log if true",
verbose);
cmd.Parse (argc,argv);
Config::SetDefault("ns3::TcpL4Protocol::SocketType",StringValue("ns3::T
cpNewReno"));
Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue
(1500));
Config::SetDefault("ns3::TcpSocket::InitialCwnd", UintegerValue (1));
Config::SetDefault("ns3::TcpSocketBase::MaxWindowSize", UintegerValue
(20*1500));
nCsma = nCsma == 0 ? 1 : nCsma;
NodeContainer csmaNodes;
csmaNodes.Create (nCsma);
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("10Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (10000)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);
Page 10 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
InternetStackHelper stack;
stack.Install (csmaNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
csma.EnablePcapAll ("fir");
csma.EnablePcap ("fir", csmaDevices.Get (1), true);
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
uint32_t
TcpNewReno::SlowStart (Ptr<TcpSocketState> tcb, uint32_t segmentsAcked)
Page 11 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
{
NS_LOG_FUNCTION (this << tcb << segmentsAcked);
return 0;
}
And
tcb->m_cWnd += (3*tcb->m_segmentSize);
Plotting five.cc
>gnuplot
set terminal png size 640,480
set output "five1.png"
plot "five1.dat" using 1:2 title 'Congestion Window' with linespoints
exit
Page 12 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
tcb->m_cWnd += tcb->m_segmentSize;
Page 13 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
tcb->m_cWnd += (2*tcb->m_segmentSize);
Page 14 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
Page 15 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
Page 16 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
Page 17 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
1)
Page 18 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpBic
2)
Page 19 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpCubic
3)
Page 20 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpHighSpeed
4)
Page 21 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpHtcp
5)
Page 22 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpLinuxReno
6)
Page 23 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpNewReno
7)
Page 24 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpVegas
8)
Page 25 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpVeno
9)
Page 26 of 27
CE257 DATA COMMUNICATION & NETWORKING 20CE158
TcpWestWood
Page 27 of 27