-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
531 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/bin/bash | ||
|
||
# Description : Broadly, it transmits and receives ST and BE flows using 2-port NIC on same end-host | ||
# Author : Joydeep Pal | ||
# Date : Nov-2022 | ||
# Date Modified : 10-Jan-2023, 18-May-2023, 06-Dec-2023 (Overhaul), 05-Jun-2024 (Overhaul) | ||
|
||
# System Design: | ||
# | ||
# Port 1 --> || --> Port 2 | ||
# | ||
# Each interface is given to its own network namespace. This is useful when iperf/ping commands | ||
# are to be used on Tx and Rx ports in the same host. Otherwise these commands don't send packets | ||
# out to the wire because kernel routes it internally. Run in root. | ||
# Any Tx flow should go to another interface, same interface doesn't support both tx and rx. | ||
set -e | ||
|
||
# Define interface names | ||
INTERFACE1="enp9s0f0" | ||
INTERFACE2="enp9s0f1" | ||
|
||
# Create network namespaces | ||
ip netns add ns1 | ||
ip netns add ns2 | ||
|
||
# Assign interfaces to namespaces | ||
ip link set $INTERFACE1 netns ns1 | ||
ip link set $INTERFACE2 netns ns2 | ||
|
||
# --------------------------------- | ||
# Section 1: Configure IP addresses for the interfaces if no VLAN is needed | ||
# --------------------------------- | ||
ip netns exec ns1 ip addr add 192.168.1.1/24 dev $INTERFACE1 | ||
ip netns exec ns2 ip addr add 192.168.1.2/24 dev $INTERFACE2 | ||
ip netns exec ns1 ip link set $INTERFACE1 up | ||
ip netns exec ns2 ip link set $INTERFACE2 up | ||
|
||
COMMENT << HERE | ||
# Optional : Capture packet for fine-grained analysis | ||
# Start packet capture on individually for each flow at server (rx) | ||
tshark -i $INTERFACE1 -a duration:7 -w /tmp/capture-experiment.pcap & | ||
HERE | ||
|
||
# Start iperf server for each flow | ||
ip netns exec ns2 iperf -s -u -p 5001 > server1_stats.txt & | ||
ip netns exec ns2 iperf -s -u -p 5002 > server2_stats.txt & | ||
ip netns exec ns2 iperf -s -u -p 5001 -P 1 -i 1 -e --histogram > server1_stats.txt 2>&1 & | ||
# ip netns exec ns2 iperf -s -u -B $INTERFACE2 -P 1 -e --histogram --jitter-histograms -i 1 > server1_stats.txt 2>&1 & | ||
|
||
# Start iperf client for each flow | ||
#ip netns exec ns1 iperf -c 192.168.1.2 -u -p 5001 -t 10 -i 1 > client1_stats.txt & | ||
#ip netns exec ns1 iperf -c 192.168.1.2 -u -p 5001 -t 2 -i 1 -P 1 -b 10m -l 1000 -e --trip-times --tos 0 | ||
ip netns exec ns1 iperf -c 192.168.1.2 -u -p 5001 -t 10 -i 1 -b 10m -e --trip-times --tos 0 > client1_stats.txt & | ||
#ip netns exec ns1 iperf -c $IP_TX -u -B $INTERFACE1 -p 5020 -t 2 -i 1 -P 1 -b 10m -l 1000 -e --trip-times --tos 0 > client1_stats.txt 2>&1 & | ||
ip netns exec ns1 iperf -c 192.168.1.2 -u -p 5002 -t 10 -i 1 -b 10m -e --trip-times --tos 0 > client2_stats.txt & | ||
#ip netns exec ns1 iperf -c $IP_TX -u -B $IFACE_TX -p 5021 -t 2 -i 1 -P 1 -b 10m -l 1000 -e --trip-times --tos 0 > client2_stats.txt 2>&1 & | ||
|
||
# Wait for iperf to finish | ||
wait | ||
|
||
# ---------------------------------------- | ||
# Section 2: If VLAN interfaces are needed | ||
# ---------------------------------------- | ||
ip netns exec ns1 ip link set $INTERFACE1 up | ||
ip netns exec ns2 ip link set $INTERFACE2 up | ||
|
||
ip netns exec ns1 ip link add link enp9s0f0 name enp9s0f0.11 type vlan id 11 | ||
ip netns exec ns1 ip link add link enp9s0f0 name enp9s0f0.12 type vlan id 12 | ||
ip netns exec ns1 ip addr add 192.168.1.11/24 dev enp9s0f0.11 | ||
ip netns exec ns1 ip addr add 192.168.2.12/24 dev enp9s0f0.12 | ||
ip netns exec ns1 ip link set enp9s0f0.11 up | ||
ip netns exec ns1 ip link set enp9s0f0.12 up | ||
|
||
ip netns exec ns2 ip link add link enp9s0f1 name enp9s0f1.11 type vlan id 11 | ||
ip netns exec ns2 ip link add link enp9s0f1 name enp9s0f1.12 type vlan id 12 | ||
ip netns exec ns2 ip addr add 192.168.1.21/24 dev enp9s0f1.11 | ||
ip netns exec ns2 ip addr add 192.168.2.22/24 dev enp9s0f1.12 | ||
ip netns exec ns2 ip link set enp9s0f1.11 up | ||
ip netns exec ns2 ip link set enp9s0f1.12 up | ||
|
||
## iperf server and client | ||
ip netns exec ns2 iperf -s -B 192.168.1.21 -u -p 5001 | ||
ip netns exec ns2 iperf -s -B 192.168.2.22 -u -p 5002 | ||
ip netns exec ns1 iperf -c 192.168.1.21 -B 192.168.1.11 -u -p 5001 -t 10 -i 1 -b 10m -e --trip-times --tos 0 | ||
ip netns exec ns1 iperf -c 192.168.2.22 -B 192.168.2.12 -u -p 5002 -t 10 -i 1 -b 10m -e --trip-times --tos 0 | ||
|
||
# ------------------------------------ | ||
# Section 2a: If capture is needed | ||
# ------------------------------------ | ||
ip netns exec ns1 tshark -i enp9s0f0.11 -a duration:5 -s 118 -w /tmp/capture-experiment-1-tx.pcap & | ||
ip netns exec ns1 tshark -i enp9s0f0.12 -a duration:5 -s 118 -w /tmp/capture-experiment-2-tx.pcap & | ||
ip netns exec ns2 tshark -i enp9s0f1.11 -a duration:5 -s 118 -w /tmp/capture-experiment-1-rx.pcap & | ||
ip netns exec ns2 tshark -i enp9s0f1.12 -a duration:5 -s 118 -w /tmp/capture-experiment-2-rx.pcap & | ||
wait | ||
|
||
# ------------------------------------ | ||
# Cleanup | ||
# ------------------------------------ | ||
|
||
# Detach interfaces from namespaces | ||
ip netns exec ns1 ip link set $INTERFACE1 down | ||
ip netns exec ns2 ip link set $INTERFACE2 down | ||
ip netns exec ns1 ip link set $INTERFACE1 netns 1 | ||
ip netns exec ns2 ip link set $INTERFACE2 netns 1 | ||
|
||
# Delete namespaces | ||
ip netns delete ns1 | ||
ip netns delete ns2 | ||
|
||
COMMENT << HERE | ||
# Optional : If capture enabled for fine-grained analysis, | ||
# convert pcap to csv for analysis using python script' | ||
args="-T fields -E header=y -E separator=, \ | ||
-e udp.dstport -e frame.time_epoch -e frame.len \ | ||
-e iperf.tos -e iperf.id -e iperf.id2 -e iperf.sec -e iperf.usec" | ||
# -e iperf.mport -e ip.src -e ip.dst -e ip.id -e udp.srcport -e udp.dstport \ | ||
# Each flow's tx and rx should be put into {tx1,rx1,tx2,rx2,..}.csv | ||
eval tshark -r /tmp/capture-experiment-1-tx.pcap $args > /tmp/capture-experiment-1-tx.csv & | ||
eval tshark -r /tmp/capture-experiment-1-rx.pcap $args > /tmp/capture-experiment-1-rx.csv & | ||
eval tshark -r /tmp/capture-experiment-2-tx.pcap $args > /tmp/capture-experiment-2-tx.csv & | ||
eval tshark -r /tmp/capture-experiment-2-rx.pcap $args > /tmp/capture-experiment-2-rx.csv & | ||
wait | ||
./txrx-same-system-analysis.py | ||
HERE | ||
|
||
echo '=================== Done !! =====================' | ||
echo ' ' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
# Description : Runs iperf2 tests on separate hosts (Real and/or in Mininet) | ||
# Author : Joydeep Pal | ||
# Date Created : 06-Dec-2023 | ||
# Date Modified : 07-Jun-2024 | ||
|
||
# Note : Can try with `sudo ... -z` (Linux real-time scheduler) to see if you get reduced latency | ||
|
||
# Script Parameters | ||
# Destination - mininet's host h2 | ||
# h2-eth0 - 10.6.6.2 | ||
# Source - mininet's host h1 | ||
# h1-eth0 - 10.3.3.1 | ||
|
||
set -e | ||
|
||
# Define interface names | ||
INTERFACE1="h1-eth0" | ||
INTERFACE2="h2-eth0" | ||
|
||
COMMENT << HERE | ||
# Optional : Capture packet for fine-grained analysis | ||
# Start packet capture individually for each flow at server (rx) | ||
tshark -i $INTERFACE1 -a duration:15 -w rx-exp1.pcapng & | ||
tshark -i $INTERFACE2 -a duration:15 -w tx-exp1.pcapng & | ||
HERE | ||
|
||
# Start iperf server for each flow | ||
iperf -s -u -p 5010 -B '10.3.3.1' -i 1 -P 1 -e --histogram --jitter-histograms & # >> flow1-rx.csv & | ||
iperf -s -u -p 5011 -B '10.10.10.1' -i 1 -P 1 -e --histogram --jitter-histograms & | ||
|
||
# Start iperf client for each flow | ||
iperf -c '10.3.3.1' -u -p 5010 -B '10.6.6.2' -t 10 -P 1 -i 1 -b 1m -l 1000 --tos 0 -e --trip-times & # >> flow1-tx.csv & \ | ||
iperf -c '10.10.10.1' -u -p 5010 -B '10.10.10.2' -t 10 -P 1 -i 1 -b 1m -l 1000 --tos 0 -e --trip-times & | ||
|
||
# Wait for iperf to finish | ||
wait | ||
|
||
COMMENT << HERE | ||
# Optional : If capture enabled for fine-grained analysis, | ||
# convert pcap to csv for analysis using python script' | ||
tshark -r rx-exp1.pcapng -Y "udp.dstport==5010 && iperf.id2<=4000000000 && not icmp" -w /tmp/capture-experiment-rx.pcap | ||
tshark -r tx-exp1.pcapng -Y "udp.dstport==5010 && iperf.id2<=4000000000 && not icmp" -w /tmp/capture-experiment-tx.pcap | ||
args="-T fields -E header=y -E separator=, \ | ||
-e ip.src -e ip.dst -e ip.id -e udp.srcport -e udp.dstport \ | ||
-e frame.time_epoch -e frame.len \ | ||
-e iperf.id -e iperf.id2 -e iperf.sec -e iperf.usec -e iperf.bufferlen" # -e data.len -e data.data | ||
# Each flow's tx and rx should be put into {tx1,rx1,tx2,rx2,..}.csv | ||
eval tshark -r /tmp/capture-experiment.pcap $args > tx1.csv & | ||
eval tshark -r /tmp/capture-experiment.pcap $args > rx1.csv & | ||
eval tshark -r /tmp/capture-experiment.pcap $args > tx2.csv & | ||
wait | ||
sleep 1 | ||
ls -al *.csv | ||
exit | ||
COMMANDS << HERE | ||
echo 'Ping from h1 to h2' | ||
ping -I 10.3.3.1 10.6.6.2 -c 5 | ||
echo 'Ping from h2 to h1' | ||
ping -I 10.6.6.2 10.3.3.1 -c 5 | ||
echo 'iperf test from h2 (client) to h1 (server)' | ||
iperf -s -B 10.3.3.1 -e -P 1 | ||
iperf -c 10.3.3.1 -B 10.6.6.2 -t 1 -P 1 -X -e --trip-times | ||
echo 'iperf test from h1 (client) to h2 (server)' | ||
iperf -s -B 10.6.6.2 -e -P 1 | ||
iperf -c 10.6.6.2 -B 10.3.3.1 -t 1 -P 1 -X -e --trip-times | ||
HERE | ||
|
||
echo '=================== Done !! =====================' | ||
echo ' ' | ||
|
Oops, something went wrong.