-
Notifications
You must be signed in to change notification settings - Fork 1
/
tcp_test.py
29 lines (23 loc) · 988 Bytes
/
tcp_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import argparse
import random
from ripl.ripl.dctopo import JellyfishTopo
def main():
parser = argparse.ArgumentParser(description='Generate topology')
parser.add_argument('-n', '--node', nargs="?", type=int, default=50, help='number of switches')
parser.add_argument('-p', '--port', nargs="?", type=int, default=8, help='number of ports for each switch')
parser.add_argument('-t', '--test', nargs="?", type=int, default=20, help='number of server / client')
args = parser.parse_args()
nSwitches = args.node
nPorts = args.port
adjlist_file = "rrg_{}_{}".format(nPorts, nSwitches)
jelly_topo = JellyfishTopo(nSwitches, nPorts, adjlist_file)
randomHosts = jelly_topo.hosts()
random.shuffle(randomHosts)
clients = randomHosts[0::2]
servers = randomHosts[1::2]
pairs_list = zip(clients, servers)
for pair in pairs_list[:args.test]:
print pair[1] + " iperf -s &"
print pair[0] + " iperf -c %s -P 8 >> results/output.txt &" %(pair[1])
if __name__ == '__main__':
main()