Skip to content

Commit

Permalink
Latency measurement with tshark
Browse files Browse the repository at this point in the history
  • Loading branch information
MadhavChoudhary committed Jun 16, 2018
1 parent c62e11b commit 4034cd9
Showing 2 changed files with 94 additions and 0 deletions.
25 changes: 25 additions & 0 deletions edit_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import csv
import numpy as np

array_in = np.genfromtxt('test_in.csv',delimiter='\n', dtype=str, skip_header=1)
array_out = np.genfromtxt('test_out.csv',delimiter='\n', dtype=str, skip_header=1)

i = 0
while i < len(array_in) :
array_in[i] = array_in[i][11:-1]
array_in[i] = float(array_in[i])
i += 1

i = 0
while i < len(array_out) :
array_out[i] = array_out[i][11:-1]
array_out[i] = float(array_out[i])
i += 1

i = 0
sum = 0
while i < len(array_out) :
sum = sum*(i/(i+1)) + float(array_out[i])/(i+1) - float(array_in[i])/(i+1)
i += 1

print sum
69 changes: 69 additions & 0 deletions latency_new.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
!/bin/bash

BMV2_PATH=../../behavioral-model
P4C_BM_PATH=../../p4c
PKTGEN_PATH=../pktgen/build/p4benchmark
P4C_BM_SCRIPT=p4c-bm2-ss
SWITCH_PATH=$BMV2_PATH/targets/simple_switch/simple_switch
CLI_PATH=$BMV2_PATH/tools/runtime_CLI.py

PROG="main"

#read -p "Enter the language version {14|16} = " VERSION
#read -p "No. of Packets to send = " PACKETS
VERSION="16"
PACKETS="10000"

#ps -ef | grep simple_switch | grep -v grep | awk '{print $2}' | xargs kill
#ps -ef | grep tshark | grep -v grep | awk '{print $2}' | xargs kill

rm latency.csv
rm -rf output/

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
do
rm test_in.csv
rm test_out.csv
p4benchmark --feature parse-field --fields $i --version $VERSION

cd output

set -m
$P4C_BM_SCRIPT --std p4-$VERSION $PROG.p4 -o $PROG.json

if [ $? -ne 0 ]; then
echo "p4 compilation failed"
exit 1
fi
sudo tshark -c $PACKETS -i veth0 -T fields -e frame.time_epoch -e frame.number -E header=n -E quote=d -E occurrence=f >> ../test_in.csv &
sudo tshark -c $PACKETS -i veth4 -T fields -e frame.time_epoch -e frame.number -E header=n -E quote=d -E occurrence=f >> ../test_out.csv &
sleep 6

sudo echo "sudo" > /dev/null
sudo $SWITCH_PATH >/dev/null 2>&1
sudo $SWITCH_PATH $PROG.json \
-i 0@veth0 -i 1@veth2 -i 2@veth4 -i 3@veth6 -i 4@veth8 \
--log-console &

sleep 2
echo "**************************************"
echo "Sending commands to switch through CLI"
echo "**************************************"
$CLI_PATH --json $PROG.json < commands.txt

echo "READY!!!"

./run_test.py -n $PACKETS

ps -ef | grep simple_switch | grep -v grep | awk '{print $2}' | xargs kill

echo "Killed Switch Process"

cd ..

python edit_csv.py >> latency.csv

ps -ef | grep tshark | grep -v grep | awk '{print $2}' | xargs kill

done

0 comments on commit 4034cd9

Please sign in to comment.