netperf_sysconf.py 3.94 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
host0.add_disk(cfg_disk0)
26
27
tar_disk0 = system.LinuxConfigDiskImage(h=host0)
host0.add_disk(tar_disk0)
28

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

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

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

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

54

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

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

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

                def qemu_sim(e):
80
                    h = sim.QemuSim(e)
81
82
                    h.sync = False
                    return h
83

84
85
                host_sim = qemu_sim

86
            elif host_type == "qt":
87
                host_sim = sim.QemuSim
88
89
            else:
                raise NameError(host_type)
90

91
            # NIC
92
            if nic_type == "i40e":
93
                nic_sim = sim.I40eNicSim
94
            elif nic_type == "vr":
95
                nic_sim = sim.CorundumVerilatorNICSim
96
97
98
99
            else:
                raise NameError(nic_type)

            # Net
100
            if net_type == "switch":
101
                net_sim = sim.SwitchNet
102
103
104
            else:
                raise NameError(net_type)

105
            host_inst0 = host_sim(simulation)
106
            host_inst0.add(host0)
107
            host_inst0.wait_terminate = True
108
            host_inst0.cpu_type = 'X86KvmCPU'
109

110
            host_inst1 = host_sim(simulation)
111
            host_inst1.add(host1)
112
            host_inst1.cpu_type = 'X86KvmCPU'
113

114
            nic_inst0 = nic_sim(simulation)
115
116
            nic_inst0.add(nic0)

117
            nic_inst1 = nic_sim(simulation)
118
119
            nic_inst1.add(nic1)

120
            net_inst = net_sim(simulation)
121
            net_inst.add(switch)
122

123
124
125
            # sim_helpers.enable_sync_simulation(
            #     simulation=simulation, amount=500, ratio=sim.Time.Nanoseconds
            # )
126
127
128

            print(simulation.name + "   all simulators:")
            sims = simulation.all_simulators()
129
130
            for s in sims:
                print(s)
131

132
            experiments.append(simulation)