dctcp.py 5.35 KB
Newer Older
Antoine Kaufmann's avatar
Antoine Kaufmann committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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.

23
import simbricks.nodeconfig as node
Jonas Kaufmann's avatar
Jonas Kaufmann committed
24
import simbricks.simulators as sim
25
from simbricks.simulator_utils import create_dctcp_hosts
Hejing Li's avatar
Hejing Li committed
26

Jonas Kaufmann's avatar
Jonas Kaufmann committed
27
import simbricks.experiments as exp
Hejing Li's avatar
Hejing Li committed
28
29
30
31
32
33
34
35

# iperf TCP_multi_client test
# naming convention following host-nic-net-app
# host: qemu/gem5-timing
# nic:  cv/cb/ib
# net:  switch/dumbbell/bridge
# app: DCTCPm

Jonas Kaufmann's avatar
Jonas Kaufmann committed
36
37
types_of_host = ['qemu', 'qt', 'gt', 'gO3']
types_of_nic = ['cv', 'cb', 'ib']
Hejing Li's avatar
Hejing Li committed
38
39
types_of_net = ['dumbbell']
types_of_app = ['DCTCPm']
Hejing Li's avatar
Hejing Li committed
40
types_of_mtu = [1500, 4000, 9000]
Hejing Li's avatar
Hejing Li committed
41
42
43

num_pairs = 2
max_k = 199680
Hejing Li's avatar
Hejing Li committed
44
45
k_step = 8320
#k_step = 16640
Jonas Kaufmann's avatar
Jonas Kaufmann committed
46
link_rate_opt = '--LinkRate=10Gb/s '  # don't forget space at the end
Hejing Li's avatar
Hejing Li committed
47
link_latency_opt = '--LinkLatency=500ns '
48
49
cpu_freq = '5GHz'
cpu_freq_qemu = '2GHz'
Hejing Li's avatar
Hejing Li committed
50
#mtu = 4000
Jonas Kaufmann's avatar
Jonas Kaufmann committed
51
sys_clock = '1GHz'  # if not set, default 1GHz
Hejing Li's avatar
Hejing Li committed
52
53
54
55
56
57

ip_start = '192.168.64.1'

experiments = []

# set network sim
58
NetClass = sim.NS3DumbbellNet
Hejing Li's avatar
Hejing Li committed
59

Hejing Li's avatar
Hejing Li committed
60
for mtu in types_of_mtu:
61
62
    for host in types_of_host:
        for nic in types_of_nic:
Hejing Li's avatar
Hejing Li committed
63
64
            for k_val in range(0, max_k + 1, k_step):

65
                net = NetClass()
Hejing Li's avatar
Hejing Li committed
66
67
                net.opt = link_rate_opt + link_latency_opt + f'--EcnTh={k_val}'

Jonas Kaufmann's avatar
Jonas Kaufmann committed
68
                e = exp.Experiment(
69
                    host + '-' + nic + '-' + 'dumbbell' + '-' + 'DCTCPm' +
Jonas Kaufmann's avatar
Jonas Kaufmann committed
70
71
                    f'{k_val}' + f'-{mtu}'
                )
Hejing Li's avatar
Hejing Li committed
72
73
                e.add_network(net)

74
                freq = cpu_freq
Hejing Li's avatar
Hejing Li committed
75
                # host
76
77
78
                if host == 'qemu':
                    HostClass = sim.QemuHost
                elif host == 'qt':
79
                    freq = cpu_freq_qemu
Jonas Kaufmann's avatar
Jonas Kaufmann committed
80

Hejing Li's avatar
Hejing Li committed
81
82
83
84
                    def qemu_timing():
                        h = sim.QemuHost()
                        h.sync = True
                        return h
Jonas Kaufmann's avatar
Jonas Kaufmann committed
85

86
87
                    HostClass = qemu_timing
                elif host == 'gt':
Jonas Kaufmann's avatar
Jonas Kaufmann committed
88

Hejing Li's avatar
Hejing Li committed
89
90
91
92
                    def gem5_timing():
                        h = sim.Gem5Host()
                        #h.sys_clock = sys_clock
                        return h
Jonas Kaufmann's avatar
Jonas Kaufmann committed
93

94
                    HostClass = gem5_timing
Hejing Li's avatar
Hejing Li committed
95
                    e.checkpoint = True
96
                elif host == 'gO3':
Jonas Kaufmann's avatar
Jonas Kaufmann committed
97

Hejing Li's avatar
Hejing Li committed
98
99
                    def gem5_o3():
                        h = sim.Gem5Host()
Jonas Kaufmann's avatar
Jonas Kaufmann committed
100
                        h.cpu_type = 'DerivO3CPU'
Hejing Li's avatar
Hejing Li committed
101
102
                        h.sys_clock = sys_clock
                        return h
Jonas Kaufmann's avatar
Jonas Kaufmann committed
103

104
                    HostClass = gem5_o3
Hejing Li's avatar
Hejing Li committed
105
106
                    e.checkpoint = True
                else:
107
                    raise NameError(host)
Hejing Li's avatar
Hejing Li committed
108
109

                # nic
110
111
112
113
114
115
116
117
118
                if nic == 'ib':
                    NicClass = sim.I40eNIC
                    NcClass = node.I40eDCTCPNode
                elif nic == 'cb':
                    NicClass = sim.CorundumBMNIC
                    NcClass = node.CorundumDCTCPNode
                elif nic == 'cv':
                    NicClass = sim.CorundumVerilatorNIC
                    NcClass = node.CorundumDCTCPNode
Hejing Li's avatar
Hejing Li committed
119
                else:
120
                    raise NameError(nic)
Hejing Li's avatar
Hejing Li committed
121

Jonas Kaufmann's avatar
Jonas Kaufmann committed
122
123
124
125
126
                servers = create_dctcp_hosts(
                    e,
                    num_pairs,
                    'server',
                    net,
127
128
129
                    NicClass,
                    HostClass,
                    NcClass,
Jonas Kaufmann's avatar
Jonas Kaufmann committed
130
131
132
133
134
135
136
137
138
                    node.DctcpServer,
                    freq,
                    mtu
                )
                clients = create_dctcp_hosts(
                    e,
                    num_pairs,
                    'client',
                    net,
139
140
141
                    NicClass,
                    HostClass,
                    NcClass,
Jonas Kaufmann's avatar
Jonas Kaufmann committed
142
143
144
145
146
                    node.DctcpClient,
                    freq,
                    mtu,
                    ip_start=num_pairs + 1
                )
Hejing Li's avatar
Hejing Li committed
147
148
149
150
151

                i = 0
                for cl in clients:
                    cl.node_config.app.server_ip = servers[i].node_config.ip
                    i += 1
Jonas Kaufmann's avatar
Jonas Kaufmann committed
152

153
154
155
                # All the clients will not poweroff after finishing iperf test
                # except the last one This is to prevent the simulation gets
                # stuck when one of host exits.
Hejing Li's avatar
Hejing Li committed
156

157
158
                # The last client waits for the output printed in other hosts,
                # then cleanup
Jonas Kaufmann's avatar
Jonas Kaufmann committed
159
160
                clients[num_pairs - 1].node_config.app.is_last = True
                clients[num_pairs - 1].wait = True
Hejing Li's avatar
Hejing Li committed
161
162
163

                print(e.name)
                experiments.append(e)