netperf_sysconf.py 4.29 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
22
23
host0 = system.CorundumLinuxHost(sys)
# host0 = system.I40ELinuxHost(sys)
Hejing Li's avatar
Hejing Li committed
24
pcie0 = system.PCIeHostInterface(host0)
25
cfg_disk0 = system.DistroDiskImage(h=host0, name="base")
26
host0.add_disk(cfg_disk0)
27
28
tar_disk0 = system.LinuxConfigDiskImage(h=host0)
host0.add_disk(tar_disk0)
29

Hejing Li's avatar
Hejing Li committed
30
host0.add_if(pcie0)
31
32
nic0 = system.CorundumNIC(sys)
# nic0 = system.IntelI40eNIC(sys)
33
nic0.add_ipv4("10.0.0.1")
Hejing Li's avatar
Hejing Li committed
34
pcichannel0 = system.PCIeChannel(pcie0, nic0._pci_if)
35

Hejing Li's avatar
Hejing Li committed
36
37
38
# create a host instance and a NIC instance then install the NIC on the host
host1 = system.I40ELinuxHost(sys)
pcie1 = system.PCIeHostInterface(host1)
39
cfg_disk1 = system.DistroDiskImage(h=host1, name="base")
40
host1.add_disk(cfg_disk1)
41
42
tar_disk1 = system.LinuxConfigDiskImage(h=host1)
host1.add_disk(tar_disk1)
43

44
host1.add_if(pcie1)
Hejing Li's avatar
Hejing Li committed
45
nic1 = system.IntelI40eNIC(sys)
46
nic1.add_ipv4("10.0.0.2")
Hejing Li's avatar
Hejing Li committed
47
pcichannel1 = system.PCIeChannel(pcie1, nic1._pci_if)
Hejing Li's avatar
Hejing Li committed
48

Hejing Li's avatar
Hejing Li committed
49
50
51
# create switch and its ports
switch = system.EthSwitch(sys)
netif0 = system.EthInterface(switch)
Hejing Li's avatar
Hejing Li committed
52
switch.add_if(netif0)
Hejing Li's avatar
Hejing Li committed
53
netif1 = system.EthInterface(switch)
Hejing Li's avatar
Hejing Li committed
54
switch.add_if(netif1)
55

56

Hejing Li's avatar
Hejing Li committed
57
# create channels and connect the switch to the host nics
Hejing Li's avatar
Hejing Li committed
58
59
ethchannel0 = system.EthChannel(switch.eth_ifs[0], nic0._eth_if)
ethchannel1 = system.EthChannel(switch.eth_ifs[1], nic1._eth_if)
60
61

# configure the software to run on the host
62
63
# host0.add_app(system.NetperfClient(host0, nic1._ip))
# host1.add_app(system.NetperfServer(host1))
64
65
66
ping_client_app = system.PingClient(host0, nic1._ip)
ping_client_app.wait = True
host0.add_app(ping_client_app)
67
host1.add_app(system.Sleep(host1, infinite=True))
68
69
70
71
72
73
74

"""
Execution Config
"""
for host_type in host_types:
    for nic_type in nic_types:
        for net_type in net_types:
75
76
            simulation = sim.Simulation(
                "n-" + host_type + "-" + nic_type + "-" + net_type
77
78
            )
            # Host
79
            if host_type == "gem5":
80
                host_sim = sim.Gem5Sim
81
            elif host_type == "qemu":
82
83

                def qemu_sim(e):
84
                    h = sim.QemuSim(e)
85
86
                    h.sync = False
                    return h
87

88
89
                host_sim = qemu_sim

90
            elif host_type == "qt":
91
                host_sim = sim.QemuSim
92
93
            else:
                raise NameError(host_type)
94

95
            # NIC
96
            if nic_type == "i40e":
97
                nic_sim = sim.I40eNicSim
98
            elif nic_type == "vr":
99
                nic_sim = sim.CorundumVerilatorNICSim
100
101
102
103
            else:
                raise NameError(nic_type)

            # Net
104
            if net_type == "switch":
105
                net_sim = sim.SwitchNet
106
107
108
            else:
                raise NameError(net_type)

109
            host_inst0 = sim.QemuSim(simulation)
110
            host_inst0.add(host0)
111
112
            # host_inst0.wait_terminate = True
            # host_inst0.cpu_type = 'X86KvmCPU'
113

114
115
            # host_inst1 = sim.Gem5Sim(simulation)
            host_inst1 = sim.QemuSim(simulation)
116
            host_inst1.add(host1)
117
            # host_inst1.cpu_type = 'X86KvmCPU'
118

119
120
121
            # nic_inst0 = sim.I40eNicSim(simulation=simulation)
            # nic_inst0 = sim.CorundumBMNICSim(simulation)
            nic_inst0 = sim.CorundumVerilatorNICSim(simulation)
122
123
            nic_inst0.add(nic0)

124
            nic_inst1 = sim.I40eNicSim(simulation=simulation)
125
126
            nic_inst1.add(nic1)

127
            net_inst = sim.SwitchNet(simulation)
128
            net_inst.add(switch)
129

130
131
132
            sim_helpers.enable_sync_simulation(
                simulation=simulation, amount=500, ratio=sim.Time.Nanoseconds
            )
133
134
135

            print(simulation.name + "   all simulators:")
            sims = simulation.all_simulators()
136
137
            for s in sims:
                print(s)
138

139
            experiments.append(simulation)