aboutsummaryrefslogtreecommitdiff
path: root/examples/congestion.py
blob: 844f136ec6c00080d958854ef1d026f5dc91112d (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python

# An example script using the rumba package

from rumba.model import Node, UnicastLayer, EthDixLayer
from rumba.storyboard import *
from rumba.utils import ExperimentManager, PROMPT_SWAPOUT
from rumba.topologies import build_star

# import testbed plugins
import rumba.testbeds.jfed as jfed

# import Ouroboros prototype plugin
import rumba.prototypes.ouroboros as our

import rumba.log as log


__all__ = ["exp", "sb", "nodes", "main", "run"]

log.set_logging_level('DEBUG')

n1 = UnicastLayer("n1")

leaves, routerNode = build_star(
    ["client1", "client2", "server"], n1, hub_name="router")
clientNode1, clientNode2, serverNode = leaves

nodes = ["client1", "client2", "router", "server"]

tb = jfed.Testbed(exp_name='cc2',
                  cert_file='/path/to/cert.pem',
                  authority='wall1.ilabt.iminds.be',
                  image='UBUNTU18-64-STD',
                  username='username',
                  exp_hours='1',
                  proj_name='ouroborosrocks')

exp = our.Experiment(tb,
                     nodes=[clientNode1, clientNode2, routerNode, serverNode],
                     # git_repo='https://codeberg.org/o7s/ouroboros',
                     git_branch='be',
                     build_options='-DCMAKE_BUILD_TYPE=Debug '
                                   '-DSHM_BUFFER_SIZE=131072 '
                                   '-DIPCP_ETH_PAD_RUNT_FRAMES=false '
                                   '-DDISABLE_CORE_LOCK=false '
                                   '-DPCP_SCHED_THR_MUL=1',
                     add_packages=['ethtool'],
                     influxdb={
                         'ip': '127.0.0.1',
                         'port': 8086,
                         'org': "Ouroboros",
                         'token': "your-influxdb-token"
                     })

sb = StoryBoard(experiment=exp, duration=1500, servers=[])


def run():
    sb.run_command("server",
                   'irm bind prog ocbr name ocbr_server;'
                   'irm name register ocbr_server layer n1;'
                   'ocbr --listen > /dev/null 2>&1 &')
    sb.run_command("client1",
                   'irm bind prog ocbr name ocbr_client1;'
                   'irm name register ocbr_client1 layer n1;'
                   'ocbr --listen > /dev/null 2>&1 &')
    sb.run_command("server",
                   'irm bind prog oping name oping_server;'
                   'irm name register oping_server layer n1;'
                   'oping --listen > /dev/null 2>&1 &')
    sb.run_command("client1", "for sz in `seq 0 10 200 1000`;"
                              "do oping -n oping_server -i 0ms -s $sz -d 120;"
                              "done")
    sb.run_command("client1", "ocbr -n ocbr_server -r 70M -d 600 --spin > /dev/null 2>&1 &")
    sb.run_command("server", "ocbr -n ocbr_client1 -r 70M -d 600 --spin > /dev/null 2>&1 &")
    time.sleep(30)
    sb.run_command("client2", "ocbr -n ocbr_server -r 70M -d 30 --spin > /dev/null 2>&1 &")
    time.sleep(45)
    sb.run_command("client2", "ocbr -n ocbr_server -r 20M -d 30 --spin > /dev/null 2>&1 &")
    time.sleep(45)
    sb.run_command("client2", "ocbr -n ocbr_server -r 60M -d 30 -s 1400 --spin > /dev/null 2>&1 &")
    time.sleep(45)
    sb.run_command("client2", "ocbr -n ocbr_server -r 60M -d 30 -s 1200 --spin > /dev/null 2>&1 &")
    time.sleep(45)
    sb.run_command("client2", "ocbr -n ocbr_server -r 60M -d 30 -s 1000 --spin > /dev/null 2>&1 &")
    time.sleep(45)
    sb.run_command("client2", "ocbr -n ocbr_server -r 60M -d 30 -s 800 --spin > /dev/null 2>&1 &")
    time.sleep(35)
    sb.run_command("client2", "ocbr -n ocbr_server -r 60M -d 30 -s 500 --spin > /dev/null 2>&1 &")
    time.sleep(35)
    sb.run_command("client2", "ocbr -n ocbr_server -r 60M -d 30 -s 200 --spin > /dev/null 2>&1 &")
    time.sleep(200)
#    sb.ouroboros_stop_metrics_exporter(nodes)
#    exp.terminate_prototype()


def main():
    with ExperimentManager(exp, swap_out_strategy=PROMPT_SWAPOUT):
        exp.swap_in()
        exp.install_prototype()
        exp.set_phy_link_rate_between("router", "server", 100)
        exp.start_metrics_exporter(nodes, interval=300)
        exp.bootstrap_prototype()
        run()


if __name__ == "__main__":
    main()