Beispiel #1
0
    h.addDevice(niu,"eth0")
    niu.addProtocol(IdealRadioPhy(), "phy")
    niu.addProtocol(CSMA_CA_DL(), "dl") # CHANGE HERE FOR A DIFFERENT MAC
    h.eth0.attachToMedium(link, (i,i))
    h.eth0.dl.setSrcAddress(i)
    hosts.append(h)

# Attach a traffic sink to the first node
server = hosts[0]
sink = TrafficSink()
server.addProtocol(sink, "app")
server.eth0.dl.registerUpperLayer(sink)

# Attach an traffic source with poisson traffic to all other nodes
for h in hosts[1:]:
    source = PoissonSource()
    h.addProtocol(source, "app")
    source.registerLowerLayer(h.eth0.dl)
    h.eth0.dl.registerUpperLayer(source)
    h.eth0.dl.setDstAddress(0) # All notes transmit to the server.

# ---------------------------------------------------------------------------
# Define statistics to be traced

class StatSampler:
    startTime = 0.0
    channelOccupation = {}
    channelSamples = 0.0

    def resetStats(self):
        self.startTime = TIME()