Modelling Delay Between Networks
We are trying to model the delay between two networks. First of all, we will send the packets from the source machine to the destination machine. Then we will capture the packet data from both machines using Tshark. Then we will analyze the packet file to calculate the arrival curve and service curve.
Note: Linux System is preferred for this modelling.We need 2 Linux Machines for this modelling
Install Tshark
Install Tshark on both Linux systems
Tshark is a network analyzer tool that helps us to capture packet data from live network. It also enables us to read packets from a previously saved capture file. Tshark is a command line program. So, we will be able to capture packets from the terminal.
Run following command in terminal to install Tshark in both system:
sudo apt-get update –y
sudo apt-get install -y tshark
Machine 1:Machine 2:
Download Code
Download Files from the Portal into respective machines
Download Receiver.py from the portal into the destination machine, and download Sender.py to the source machine.
Link: Modelling Code
Open Code
Open the downloaded code from the portal into the IDE of choice. Here we imported the code inside Spyder.
Sender.py on source machine
Receiver.pyon source machine
Install PTP
Since we are working on sending packets between two systems and computing the delay in the network. It is vital to keep the two system clocks synchronized and accurate. For this purpose, we will use PTP (Precision Time Protocol) which is capable of sub-microsecond accuracy.
First, we will install PTP in both source and destination machine by running following command.
sudo apt-get install -y linuxptp
Installing PTP on source machine:
Installing PTP on destination machine:
Enable PTP Synchronization
PTP uses hardware time stamping by default. If both machines are connected using cable, we can try this. Otherwise, we can also use software time stamping.
To enable PTP synchronization on both source and destination machine run the following command in Linux terminal.
For Hardware Time Stamping:
ptp4l -i eth3 -m
For Software Time Stamping:
ptp4l -i eth3 -m -S
Note: In both commands, eth3 is the interface you want to configure. You can use the interface of your own choice.
Link: Staring PTP
Run Receiver.py
Run Receiver.py python file in destination machine.
Run Tshark
Run Tshark using following code snippet
tshark [ -i <capture interface>|- ] [ -w <outfile>|- ] where <capture interface> is the name of the interface and <outfile>is the name of a file.
Execute the following command to run Tshark on Source Machine:
sudo tshark -i wlp2s0 -w /tmp/Sender.pcap
Execute the following command to run Tshark on Destination Machine:
sudo tshark -i wlp2s0 -w /tmp/Receiver.pcap
This will create Sender.pcap file on the source machine and Receiver.pcap file on destination machine.
Open Sender.py
Open Sender.py and inside Sender.py set the ip address of workstation_ip to ip address of the receiver machine.
Run Sender.py
Run Sender.py on source machine.
Collect PCAP Files
Tshark has built the pcap file on both source machine and destination machine.
Collect those, Sender.pcap and Receiver.pcap file and copy them into 1 system. We will need these files to calculate the delay in the system.
Download pcapReader.py
Download pcapReader.py from the portal. We will use this python script to compute the delay between 2 systems.
Link: Modelling Code
Open pcapReader.py
Open the downloaded code from the portal into the IDE of choice. Here we imported the code inside Spyder.
Install Python modeules
Install required python modules using following command.
E.g., To install dpkt and Scapy. Go to terminal and run following commands.
pip install dpkt
pip install scapy
Run pcapReader.py
Inside pcapReader.py
Then,
run pcapReader.py
The result will display rate and burst of the arrival curve.
Similarly, the last line of results displays the delay i.e latency.