netperf_sysconf.py 3.59 KB
Newer Older
1
2
3
from simbricks.orchestration import system
from simbricks.orchestration import simulation as sim
from simbricks.orchestration import instantiation as inst
4
from simbricks.orchestration.helpers import simulation as sim_helpers
5

6
7
8
9
10
11
12
13
"""
Netperf Example:
One Client: Host_0, One Server: Host1 connected through a switch
HOST0 -- NIC0 ------ SWITCH ------ NIC1 -- HOST1

This scripts generates the experiments with all the combinations of different execution modes
"""

14
15
16
host_types = ["gem5"]
nic_types = ["i40e"]
net_types = ["switch"]
17
18
experiments = []

Hejing Li's avatar
Hejing Li committed
19
sys = system.System()
20
21

# create a host instance and a NIC instance then install the NIC on the host
Hejing Li's avatar
Hejing Li committed
22
23
host0 = system.I40ELinuxHost(sys)
pcie0 = system.PCIeHostInterface(host0)
24
cfg_disk0 = system.DistroDiskImage(h=host0, name="base")
25
26
host0.add_disk(cfg_disk0)

Hejing Li's avatar
Hejing Li committed
27
28
host0.add_if(pcie0)
nic0 = system.IntelI40eNIC(sys)
29
nic0.add_ipv4("10.0.0.1")
Hejing Li's avatar
Hejing Li committed
30
pcichannel0 = system.PCIeChannel(pcie0, nic0._pci_if)
31

Hejing Li's avatar
Hejing Li committed
32
33
34
# create a host instance and a NIC instance then install the NIC on the host
host1 = system.I40ELinuxHost(sys)
pcie1 = system.PCIeHostInterface(host1)
35
cfg_disk1 = system.DistroDiskImage(h=host1, name="base")
36
37
host1.add_disk(cfg_disk1)

38
host1.add_if(pcie1)
Hejing Li's avatar
Hejing Li committed
39
nic1 = system.IntelI40eNIC(sys)
40
nic1.add_ipv4("10.0.0.2")
Hejing Li's avatar
Hejing Li committed
41
pcichannel1 = system.PCIeChannel(pcie1, nic1._pci_if)
Hejing Li's avatar
Hejing Li committed
42

Hejing Li's avatar
Hejing Li committed
43
44
45
# create switch and its ports
switch = system.EthSwitch(sys)
netif0 = system.EthInterface(switch)
Hejing Li's avatar
Hejing Li committed
46
switch.add_if(netif0)
Hejing Li's avatar
Hejing Li committed
47
netif1 = system.EthInterface(switch)
Hejing Li's avatar
Hejing Li committed
48
switch.add_if(netif1)
49

50

Hejing Li's avatar
Hejing Li committed
51
# create channels and connect the switch to the host nics
Hejing Li's avatar
Hejing Li committed
52
53
ethchannel0 = system.EthChannel(switch.eth_ifs[0], nic0._eth_if)
ethchannel1 = system.EthChannel(switch.eth_ifs[1], nic1._eth_if)
54
55

# configure the software to run on the host
56
host0.add_app(system.NetperfClient(host0, nic1._ip))
Hejing Li's avatar
Hejing Li committed
57
host1.add_app(system.NetperfServer(host1))
58
59
60
61
62
63
64

"""
Execution Config
"""
for host_type in host_types:
    for nic_type in nic_types:
        for net_type in net_types:
65
66
            simulation = sim.Simulation(
                "n-" + host_type + "-" + nic_type + "-" + net_type
67
68
            )
            # Host
69
            if host_type == "gem5":
70
                host_sim = sim.Gem5Sim
71
            elif host_type == "qemu":
72
73

                def qemu_sim(e):
74
                    h = sim.QemuSim(e)
75
76
                    h.sync = False
                    return h
77

78
79
                host_sim = qemu_sim

80
            elif host_type == "qt":
81
                host_sim = sim.QemuSim
82
83
            else:
                raise NameError(host_type)
84

85
            # NIC
86
            if nic_type == "i40e":
87
                nic_sim = sim.I40eNicSim
88
            elif nic_type == "vr":
89
                nic_sim = sim.CorundumVerilatorNICSim
90
91
92
93
            else:
                raise NameError(nic_type)

            # Net
94
            if net_type == "switch":
95
                net_sim = sim.SwitchNet
96
97
98
            else:
                raise NameError(net_type)

99
            host_inst0 = host_sim(simulation)
100
            host_inst0.add(host0)
101
            host_inst0.wait_terminate = True
102

103
            host_inst1 = host_sim(simulation)
104
105
            host_inst1.add(host1)

106
            nic_inst0 = nic_sim(simulation)
107
108
            nic_inst0.add(nic0)

109
            nic_inst1 = nic_sim(simulation)
110
111
            nic_inst1.add(nic1)

112
            net_inst = net_sim(simulation)
113
            net_inst.add(switch)
114
115
116
117
118
119
120

            sim_helpers.enable_sync_simulation(
                simulation=simulation, amount=500, ratio=sim.Time.Nanoseconds
            )

            print(simulation.name + "   all simulators:")
            sims = simulation.all_simulators()
121
122
            for s in sims:
                print(s)
123

124
            experiments.append(simulation)