-
Notifications
You must be signed in to change notification settings - Fork 1
/
leftOffice.py
81 lines (61 loc) · 3.44 KB
/
leftOffice.py
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
#!/usr/bin/env python
# coding: utf-8
from helpers import *
def setUpLeftOffice(cmd):
logHeader("Constructing left office")
loHosts = createLeftOfficeWifiNodes(cmd)
logNodes("Left office wifi node count: ", loHosts)
loWifiPhy = setUpWifiPhy()
loWifiMac = setUpWifiMac(cmd.wifiMacType, Ssid(cmd.leftOfficeWifiSsid))
loWifiDev = setUpWifi(loWifiPhy, loWifiMac, loHosts)
setUpWifiHostsMobility(loHosts, cmd.wifiNodesDistance)
loWifiInterfaces = setUpIPAddresses(cmd.leftOfficeWifiNetwork, cmd.networkMask, loWifiDev)
loInfra = createLeftOfficeInfraNodes(cmd)
logNodes("Left office infra node count: ", loInfra)
loInfraWithWifiAP = addToContainer(loInfra, loHosts.Get(cmd.leftOfficeWifiRouter))
loInfraDev = installCSMA(cmd.leftOfficeCsmaDataRate, cmd.leftOfficeCsmaDelay, loInfraWithWifiAP)
loLANs = createLeftOfficeLanNodes(cmd)
logNodes("Left office lan node count: ", loLANs)
loLANWithGW = addToContainer(loLANs, loHosts.Get(cmd.leftOfficeWifiRouter))
loLanDev = installCSMA(cmd.leftOfficeCsmaDataRate, cmd.leftOfficeCsmaDelay, loLANWithGW)
loInfraInterfaces = setUpIPAddresses(cmd.leftOfficeInfraNetwork, cmd.networkMask, loInfraDev)
loLanInterfaces = setUpIPAddresses(cmd.leftOfficeLanNetwork, cmd.networkMask, loLanDev)
leftOfficeGw = setUpLoApplications(
loWifiInterfaces,
loInfraInterfaces,
loLanInterfaces,
loHosts,
loInfra,
loLANs,
cmd
)
doLeftOfficeTracing(loWifiPhy, loHosts, addToContainer(loInfra, loLANs), cmd)
return leftOfficeGw
def setUpLoApplications(loWifiInterfaces, loInfraInterfaces, loLanInterfaces, loHosts, loInfra, loLANs, cmd):
loServerNode = loInfra.Get(cmd.leftOfficeUdpEchoServer)
loRouterNode = loHosts.Get(cmd.leftOfficeWifiRouter)
installUdpEchoServer(loRouterNode, cmd.discardPort, cmd.serverStart, cmd.stopTime)
loServerAddress = loInfraInterfaces.GetAddress(cmd.leftOfficeUdpEchoServer)
loServerClient = setUpUdpEchoClient(loServerAddress, cmd.discardPort, cmd.packetInterval, cmd.packetSize)
log("Left office server node #", loServerNode.GetId())
logDebug("Left office server node address: ", loServerAddress)
assertTrue(loServerAddress, cmd.leftOfficeServerIp)
log("Left office router node #", loRouterNode.GetId())
cloudClient = setUpCloudUdpEchoClient(cmd)
logDebug("Number of left office WiFi clients: ", loHosts.GetN())
installUdpEchoWifiClients(cloudClient, loServerClient, loHosts, [cmd.leftOfficeWifiRouter], cmd)
logDebug("Number of left office LAN clients: ", loLANs.GetN())
installUdpEchoLanClients(cloudClient, loServerClient, loLANs, [], cmd)
return loRouterNode
def doLeftOfficeTracing(wifiPhy, wifiNodes, csmaNodes, cmd):
doWifiTracing(cmd.leftOfficeTracePrefix, wifiPhy, wifiNodes, cmd)
doCSMATracing(cmd.leftOfficeTracePrefix, csmaNodes, cmd)
def createLeftOfficeWifiNodes(cmd):
log("Creating ", cmd.leftOfficeWifiNodes, " left office wifi nodes")
return createNodesWithStack(cmd.leftOfficeWifiNodes)
def createLeftOfficeInfraNodes(cmd):
log("Creating ", cmd.leftOfficeInfraNodes, " left office infra nodes")
return createNodesWithStack(cmd.leftOfficeInfraNodes)
def createLeftOfficeLanNodes(cmd):
log("Creating ", cmd.leftOfficeLanNodes, " left office lan nodes")
return createNodesWithStack(cmd.leftOfficeLanNodes)