(Report) PACN Lab Assignment - 3
(Report) PACN Lab Assignment - 3
Experiment 01
Aim : To create network containers using netns and ping between them in Linux OS.
Description : Create two network namespaces namely NetNsA and NetNsB and we will ping from one namespace to
another (say NetNsA to NetNsB). Namespaces have been pinged in three different ways:
(i) simply run ping between NetNsA and NetNsB.
(ii) run ping with a fixed delay of 50ms.
(iii) run ping with a variable delay of 50ms.
Procedure : Measuring average RTT using three methods mentioned in the description (in ms).
Number of Iterations RTT using ping RTT using ping with fixed RTT using ping with variable
(in ms) Delay of 50ms (in ms) 50 ms delay (in ms)
Python Script:
import subprocess
setup = [
'ip netns add NetNsA',
'ip netns add NetNsB',
'ip -n NetNsA link add eth0 type veth peer name eth0 netns NetNsB',
'ip -n NetNsA addr add 192.168.1.1/24 dev eth0',
'ip -n NetNsB addr add 192.168.2.1/24 dev eth0',
'ip netns exec NetNsA ip link set eth0 up',
'ip netns exec NetNsB ip link set eth0 up',
'ip netns exec NetNsA ip route add default via 192.168.1.1 dev eth0',
'ip netns exec NetNsB ip route add default via 192.168.2.1 dev eth0'
]
queuingDisciplines = [
'no-op',
'ip netns exec NetNsA tc qdisc add dev eth0 root netem delay 50ms',
'ip netns exec NetNsA tc qdisc add dev eth0 root netem delay 50ms 50ms'
]
teardown = [
'ip netns del NetNsA',
'ip netns del NetNsB'
]
if __name__ == '__main__':
try:
run_steps(setup)
iteration = 1
pingCmd = "ip netns exec NetNsA ping -c 4 192.168.2.1"
delQueuingDisciplineCmd = "ip netns exec NetNsA tc qdisc del dev eth0 root"
if iteration == 3:
subprocess.Popen(delQueuingDisciplineCmd, shell=True)
for i in range(10):
pingOutput = subprocess.Popen(pingCmd, shell=True,
stdout=subprocess.PIPE,stderr=subprocess.PIPE, encoding='utf-8')
with open("log.txt", "a") as log:
log.write(pingOutput)
iteration += 1
print(averages)
finally:
run_steps(teardown, ignore_errors=True)
Note:
The link to check the autologs of the above experiment is given below:
➔ https://drive.google.com/drive/folders/154plgfbPVs75IbNSmBqQJXPkmXP3bYcT?usp=share_link
Observations :
1. Ping with fixed delay of 50ms between the two network namespaces has minimum fluctuations in values for
roundtrip time after the first iteration. Similar case for ping with no delay.
2. In ping with variable delay, the fluctuation is high, signifying less accuracy.
3. After the first iteration, ping with fixed delay stabilizes.
4. Average RTTs for all the three pings are as follows,
Average RTT for regular ping Average RTT for fixed delay Average RTT for variable Delay
(ms) (ms) (ms)
Inferences:
1. From the average RTTs, we can infer that -
Regular Ping < Ping with Fixed Delay < Ping with Variable Delay
2. Pings with fixed delays have maximum accuracy, whereas the pings with variable delays have the least.
3. The increased latency and jitter introduced by the queue discipline can result in degraded network performance
and may cause issues such as packet loss and congestion.
4. The ‘netem’ queue discipline is a power tool for simulating network conditions and testing the behavior of
applications and protocols under different network scenarios.
Experiment No. 02
Aim : To analyze the performance of file transfer between the two network namespaces using ftp and scp commands.
Description: Create different flows to examine the performance of file transfer between the two network namespaces
connected via Ethernet. The two types of flows that needs to be created:
Task 1:
Write a python script titled ‘elephant’ that transfers a large size file using ftp. Execution time should be in 10s of
seconds. Write another python script titled ‘mouse’ that transfers a small size file using scp. Execution time
should be in 10s of seconds. Record the start time and end time for each file size transfer.
if __name__ == "__main__":
file = '100MB.8'
startTime = time.time()
scpCmd = 'ip netns exec NetNsA sshpass -p "root" scp /home/rpi/Desktop/NetNsA/' + file +
' [email protected]:/home/rpi/Desktop/NetNsB/' + file
scpElephantProcess = subprocess.Popen(scpCmd, shell=True,
stdout=subprocess.PIPE,stderr=subprocess.PIPE, encoding='utf-8')
scpElephantProcess.communicate()
endTime = time.time()
executionTime = endTime - startTime
print("File Size = {}, ExecutionTime = {}".format(file, executionTime))
mouse.py for small file size transfer using scp with exponential inter-file gap.
#run command - sudo python3 mouse.py <NmIndices> <FileIndices>
import sys
import time
import random
import subprocess
if __name__ == "__main__":
N = Nm[int(sys.argv[1])]
file = mouse_files[int(sys.argv[2])]
executionTime = 0.00
startTime = time.time()
for i in range(N):
scpCmd = 'ip netns exec NetNsA sshpass -p "root" scp /home/rpi/Desktop/NetNsA/' + file
+ ' [email protected]:/home/rpi/Desktop/NetNsB/' + str(i) + '_' + file
scpMouseProcess = subprocess.Popen(scpCmd, shell=True,
stdout=subprocess.PIPE,stderr=subprocess.PIPE, encoding='utf-8')
scpMouseProcess.communicate()
time.sleep(random.expovariate(0.20))
endTime = time.time()
executionTime = endTime - startTime
print("File Size = {}, Nm = {}, ExecutionTime = {}".format(file, N, executionTime))
Task 2:
Write a control script that runs elephant.py and Nm mouse.py in parallel.
Task 3:
Repeat task 2 for various values of Nm. Plot elephant throughput Xe v/s Nm mouse transfers.
Fig. Line Chart: Elephant Throughput v/s Nm for various mouse file sizes
Fig. Line Chart: Execution Time v/s Number of Iteration
Observations:
1. As the number of iterations increases, the average execution time for mouse files increases drastically.
2. The average execution time for the elephant file fluctuates very less throughout the experiment.
3. The average execution time for elephant file and Nm mouse files of various sizes.
Average
Mouse Mouse Execution Mouse Execution Mouse Execution
Number of Elephant
Execution Time Time for 10 KB Time for 100 KB Time for 500 KB
Iterations Execution Time
for 1B (seconds) (seconds) (seconds) (seconds)
(seconds)
Inferences:
1. As the number of mouse flows(Nm) increases, the total throughput of the system will increase up to a certain
point, beyond which the system will become congested and the throughput will decrease due to the increased
packet loss and delay.
2. For the 500KB mouse file, the execution time is almost higher every time than for the rest of the mouse files. So,
we can infer that the transfer time for mouse files is directly proportional to the number of iterations.
3. The average throughput of the elephant file doesn’t fluctuate much as the average execution time doesn’t vary
much.
4. Overall, we can infer that the performance of a network with a mix of elephant and mouse flows depends on the
number and size of the mouse flows, as well as the available bandwidth and capacity of the network. By
optimizing these parameters, we can improve the overall throughput and performance of the network.