-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimple_pipeline.batchy
90 lines (73 loc) · 2.75 KB
/
simple_pipeline.batchy
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
# Batchy
#
# Copyright (C) 2019 by its authors (See AUTHORS)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Step 0: init (run-time) parameters
# +---------+
# | |
# -->| NF1 |
# / | |
# +----------+ / +---------+
# | |/
# | Splitter |
# | |\
# +----------+ \ +---------+
# \ | |
# -->| NF2 |
# | |
# +---------+
#
# Simple Pipeline
# scheduler type, either RTC or WFQ
mode = get_arg('mode', 'RTC', str)
# supported controllers:
# RTC: projgrad, feasdir, null, max
# WFQ: null
controller = get_arg('controller', 'projgrad', str)
# measurement timespan:
rounds = get_arg('rounds', 40, int) # number of rounds
control_period = get_arg('control_period', .25, float) # control rounds time interval
# flows' delay SLO [ns]
flow1_delay_slo = get_arg('delay_slo1', 15_000, int)
flow2_delay_slo = get_arg('delay_slo2', 100_000, int)
# Step 1: create worker
w0 = batchy.add_worker('w0')
# Step 2: add task to worker
t0 = w0.add_task('task0', type=mode)
# Step 3: add modules to task, set internal pipeline
splitter = t0.add_module(RandomSplit(gates=list(range(2)), drop_rate=0.0),
type='ingress')
nf1 = t0.add_module(Bypass(cycles_per_batch=1000, cycles_per_packet=100),
T_0=1000, T_1=100)
nf2 = t0.add_module(Bypass(cycles_per_batch=1000, cycles_per_packet=100),
T_0=1000, T_1=100)
splitter.connect(nf1, ogate=0)
splitter.connect(nf2, ogate=1)
# Step 4: add flows
batchy.add_flow(name='flow1', path=[{'task': t0, 'path':[splitter, nf1]}],
delay_slo=flow1_delay_slo)
batchy.add_flow(name='flow2', path=[{'task': t0, 'path':[splitter, nf2]}],
delay_slo=flow2_delay_slo)
# Step 5: add test traffic
batchy.add_source()
batchy.add_sink()
# Step 6: set controller for worker
t0.set_controller(batchy.resolve_task_controller(controller))
# Step 7: run pipeline
batchy.run(rounds, control_period)
# Step 8: get results
basename = 'simple_pipeline_stats'
batchy.plot(f'/tmp/{basename}.png')
batchy.dump(f'/tmp/{basename}.txt')