Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
d611d116
Commit
d611d116
authored
Jun 07, 2022
by
Hejing Li
Browse files
ae: add network decomposition scripts
parent
c88bf6de
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
423 additions
and
0 deletions
+423
-0
experiments/ae/net-decmp.sh
experiments/ae/net-decmp.sh
+33
-0
experiments/pyexps/ae/data_decmp.py
experiments/pyexps/ae/data_decmp.py
+55
-0
experiments/pyexps/ae/pktgen.sh
experiments/pyexps/ae/pktgen.sh
+335
-0
No files found.
experiments/ae/net-decmp.sh
0 → 100755
View file @
d611d116
#!/bin/bash
cd
../pyexps/ae
# Run 2 hosts connected to one switch. Bit rate: 0 GB
echo
"Run Run 2 hosts connected to one switch. Bit rate: 0 GB"
./pktgen.sh 2 0 run_switch
>
../../out/pktgen/2h1s0b.out 2>&1
python3 data_decmp.py ../../out/pktgen/2h1s0b.out 2>&1
# Run 2 hosts connected to one switch. Bit rate: 100 GB
echo
"Run 2 hosts connected to one switch. Bit rate: 100 GB"
./pktgen.sh 2 100 run_switch
>
../../out/pktgen/2h1s100b.out 2>&1
python3 data_decmp.py ../../out/pktgen/2h1s100b.out 2>&1
# Run 32 hosts connected to one switch. Bit rate: 0 GB
echo
"Run 32 hosts connected to one switch. Bit rate: 0 GB"
./pktgen.sh 32 0 run_switch
>
../../out/pktgen/32h1s0b.out 2>&1
python3 data_decmp.py ../../out/pktgen/32h1s0b.out 2>&1
# Run 32 hosts connected to one switch. Bit rate: 100 GB
echo
"Run 32 hosts connected to one switch. Bit rate: 100 GB"
./pktgen.sh 32 100 run_switch
>
../../out/pktgen/32h1s100b.out 2>&1
python3 data_decmp.py ../../out/pktgen/32h1s100b.out 2>&1
# This part runs decomposed network configuration.
# 32 hosts are spread to 4 ToR switchs
# ToR switches are connected by 1 root switch
# Run Bit rate: 0 GB
echo
"Decomposed Run Bit rate: 0 GB"
./pktgen.sh 32 0 4 run_switch_tor
>
../../out/pktgen/32hT0b.out 2>&1
python3 data_decmp.py ../../out/pktgen/32hT0b.out 2>&1
# Run Bit rate: 100 GB
echo
"Decomposed Run Bit rate: 100 GB"
./pktgen.sh 32 100 4 run_switch_tor
>
../../out/pktgen/32hT100b.out 2>&1
python3 data_decmp.py ../../out/pktgen/32hT100b.out 2>&1
\ No newline at end of file
experiments/pyexps/ae/data_decmp.py
0 → 100644
View file @
d611d116
# Copyright 2021 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import
glob
import
json
import
os
import
itertools
import
sys
if
len
(
sys
.
argv
)
!=
2
:
print
(
'Usage: data_decmp.py OUTFILE'
)
sys
.
exit
(
1
)
out_file
=
sys
.
argv
[
1
]
if
not
os
.
path
.
isfile
(
out_file
):
print
(
"no result file at: "
+
out_file
)
exit
(
0
)
f
=
open
(
out_file
,
'r'
)
lines
=
f
.
readlines
()
for
line
in
lines
:
if
"start:"
in
line
:
start_time
=
float
(
line
.
split
()[
1
])
if
"end:"
in
line
:
end_time
=
float
(
line
.
split
()[
1
])
time_diff
=
end_time
-
start_time
print
(
'SimTime: %d (s)'
%
(
time_diff
))
f
.
close
()
experiments/pyexps/ae/pktgen.sh
0 → 100755
View file @
d611d116
#! /bin/bash
SB_BASE
=
"
$(
readlink
-f
$(
dirname
${
BASH_SOURCE
[0]
}
)
/../../..
)
"
RUN_DIR
=
$SB_BASE
/experiments/out/pktgen/
${
1
}
h
${
2
}
b
#RUN_DIR=/tmp/simbricks/pktgen/${1}h${2}b
NUM_HOST
=
$1
ALL_PIDS
=
""
PKTGEN_PIDS
=
""
SWITCH_PIDS
=
""
# - inst num
# - pktgen bit rate
run_pktgen
(){
echo
"starting host
$1
"
PKTGEN_EXE
=
$SB_BASE
/sims/net/pktgen/pktgen
$PKTGEN_EXE
-S
500
-E
500
-n
$1
-h
$RUN_DIR
/eth.
$1
-b
$2
&
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
PKTGEN_PIDS
=
"
$PKTGEN_PIDS
$pid
"
return
$pid
}
# -num host connected
run_switch
(){
echo
"Starting switch"
SWITCH_EXE
=
$SB_BASE
/sims/net/switch/net_switch
args
=
""
iface
=
0
while
[
$iface
-lt
$1
]
do
args
=
"
$args
-s
$RUN_DIR
/eth.
$iface
"
((
iface++
))
done
$SWITCH_EXE
-S
500
-E
500
\
$args
>
$RUN_DIR
/log.switch &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
return
$pid
}
# - number of hosts
run_switch_dumbbell
(){
echo
"Starting switch dumbbell"
SWITCH_EXE
=
$SB_BASE
/sims/net/switch/net_switch
args_0
=
""
args_1
=
""
iface
=
0
half
=
$((
$1
/
2
))
while
[
$iface
-lt
$half
]
do
args_0
=
"
$args_0
-s
$RUN_DIR
/eth.
$iface
"
#((iface+=2))
((
iface+
=
1
))
done
#iface=1
#num_inc=$(($1+1))
#while [ $iface -lt $num_inc ]
while
[
$iface
-lt
$1
]
do
args_1
=
"
$args_1
-s
$RUN_DIR
/eth.
$iface
"
#((iface+=2))
((
iface+
=
1
))
done
$SWITCH_EXE
-S
500
-E
500
\
$args_0
-h
$RUN_DIR
/s0eth
>
$RUN_DIR
/log.switch &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
sleep
1
$SWITCH_EXE
-S
500
-E
500
\
$args_1
-s
$RUN_DIR
/s0eth
>
$RUN_DIR
/log.switch &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
return
$pid
}
# - number of hosts
# - number of middle switch
run_switch_chain
(){
echo
"Starting switch chain"
SWITCH_EXE
=
$SB_BASE
/sims/net/switch/net_switch
args_0
=
""
args_1
=
""
iface
=
0
half
=
$((
$1
/
2
))
while
[
$iface
-lt
$half
]
do
args_0
=
"
$args_0
-s
$RUN_DIR
/eth.
$iface
"
#((iface+=2))
((
iface+
=
1
))
done
#iface=1
#num_inc=$(($1+1))
#while [ $iface -lt $num_inc ]
while
[
$iface
-lt
$1
]
do
args_1
=
"
$args_1
-s
$RUN_DIR
/eth.
$iface
"
#((iface+=2))
((
iface+
=
1
))
done
nswitch
=
0
nums_dec
=
$((
$2
-
1
))
while
[
$nswitch
-lt
$2
]
do
pswitch
=
$((
$nswitch
-
1
))
#the first
if
[
$nswitch
-eq
0
]
then
$SWITCH_EXE
-S
500
-E
500
\
$args_0
-h
$RUN_DIR
/s0eth
>
$RUN_DIR
/switch_
${
nswitch
}
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
sleep
1
#the last
elif
[
$nswitch
-eq
$nums_dec
]
then
$SWITCH_EXE
-S
500
-E
500
\
$args_1
-s
$RUN_DIR
/s
${
pswitch
}
eth
>
$RUN_DIR
/switch_
${
nswitch
}
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
else
$SWITCH_EXE
-S
500
-E
500
\
-s
$RUN_DIR
/s
${
pswitch
}
eth
-h
$RUN_DIR
/s
${
nswitch
}
eth
>
$RUN_DIR
/switch_
${
nswitch
}
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
sleep
1
fi
((
nswitch++
))
done
return
}
# - num host connected per Tor switch
# - num of Tor switch
run_switch_tor
(){
echo
"Starting ToR switch"
SWITCH_EXE
=
$SB_BASE
/sims/net/switch/net_switch
per_sw
=
$((
$1
/
$2
))
nswitch
=
0
host_idx
=
0
# Run Tor switches
while
[
$nswitch
-lt
$2
]
do
args
=
""
iface
=
0
while
[
$iface
-lt
$per_sw
]
do
args
=
"
$args
-s
$RUN_DIR
/eth.
$host_idx
"
((
iface++
))
((
host_idx++
))
done
# add interface connecting to root switch
args
=
"
$args
-h
$RUN_DIR
/s.
${
nswitch
}
"
((
nswitch++
))
$SWITCH_EXE
-S
500
-E
500
\
$args
>
$RUN_DIR
/log.tor
${
nswitch
}
&
pid
=
$!
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
done
sleep
2
# Run root switch
echo
"Run root switch"
args
=
""
iface
=
0
while
[
$iface
-lt
$nswitch
]
do
args
=
"
$args
-s
$RUN_DIR
/s.
$iface
"
((
iface++
))
done
$SWITCH_EXE
-S
500
-E
500
\
$args
>
$RUN_DIR
/log.rswitch &
pid
=
$!
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
}
# - number of hosts
# - number of layers should >= 2
run_switch_hierarchy
(){
echo
"Starting switch hierarchy"
SWITCH_EXE
=
$SB_BASE
/sims/net/switch/net_switch
layer
=
1
#leave switch
iface
=
0
while
[
$iface
-lt
$1
]
do
$SWITCH_EXE
-S
500
-E
500
\
-h
$RUN_DIR
/s
${
layer
}
.
$iface
-s
$RUN_DIR
/eth.
${
iface
}
>
$RUN_DIR
/s
${
layer
}
.
${
iface
}
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
((
iface++
))
done
((
layer++
))
sleep
2
#node switch
while
[
$layer
-lt
$2
]
do
iface
=
0
layer_dec
=
$((
$layer
-
1
))
while
[
$iface
-lt
$1
]
do
$SWITCH_EXE
-S
500
-E
500
\
-s
$RUN_DIR
/s
${
layer_dec
}
.
$iface
-h
$RUN_DIR
/s
${
layer
}
.
$iface
>
$RUN_DIR
/s
${
layer
}
.
${
iface
}
.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
((
iface++
))
done
((
layer++
))
sleep
2
done
sleep
2
#root switch
args
=
""
iface
=
0
layer_dec
=
$((
$layer
-
1
))
while
[
$iface
-lt
$1
]
do
args
=
"
$args
-s
$RUN_DIR
/s
${
layer_dec
}
.
$iface
"
((
iface++
))
done
$SWITCH_EXE
-S
500
-E
500
\
$args
>
$RUN_DIR
/root_switch.log &
pid
=
$!
ALL_PIDS
=
"
$ALL_PIDS
$pid
"
SWITCH_PIDS
=
"
$SWITCH_PIDS
$pid
"
}
cleanup
()
{
echo
"Cleaning up"
for
p
in
$ALL_PIDS
;
do
kill
-KILL
$p
&>/dev/null
done
date
}
sighandler
(){
echo
"caught Interrup, aborting..."
cleanup
date
exit
1
}
trap
"sighandler"
SIGINT
echo
-n
"start: "
date
+%s
rm
-rf
$RUN_DIR
mkdir
-p
$RUN_DIR
r
=
0
while
[
$r
-lt
$1
]
do
run_pktgen
$r
$2
((
r++
))
done
sleep
3
#run_switch $1
#SWITCH_PID=$!
#run_switch_dumbbell $1
#run_switch_chain $1 $2
if
[
"$#"
-lt
3
]
;
then
echo
"usage: ./pktgen.sh [num_host] [bit_rate] [opt] [net_config] "
fi
if
[
"$#"
-eq
4
]
;
then
if
[
$4
==
"run_switch_hierarchy"
]
;
then
echo
"run switch hierarchy"
run_switch_hierarchy
$1
$3
elif
[
$4
==
"run_switch_tor"
]
;
then
echo
"run switch tor
$3
"
run_switch_tor
$1
$3
else
echo
"no matching config"
cleanup
exit
0
fi
elif
[
$3
==
"run_switch"
]
;
then
run_switch
$1
elif
[
$3
==
"run_switch_dumbbell"
]
;
then
run_switch_dumbbell
$1
else
echo
"no argument match"
cleanup
exit
0
fi
for
p
in
$PKTGEN_PIDS
;
do
wait
$p
done
echo
"Pktgen Done, kill switch"
#kill -9 $SWITCH_PID
for
p
in
$SWITCH_PIDS
;
do
kill
-9
$p
done
echo
-n
"end: "
date
+%s
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment