Beispiel #1
0
    h.eth0.attachToMedium(link, i*1.0) # CHANGE HERE FOR THE BUS LENGTH
    hosts.append(h)

# Attach a traffic sink to the first node
server = hosts[0]
sink = TrafficSink()
server.addProtocol(sink, "app")
sink.setCheckSequence(True)
server.nw.registerUpperLayer(sink)
serverMAC = server.eth0.mac.address

# Attach a traffic source DLFlooder to all other nodes
for h in hosts[1:]:
    source = PoissonSource()
    source.setInterarrival(0.1)
    source.setPDUSize(100)
    h.addProtocol(source, "app")
    source.registerLowerLayer(h.nw)
    h.nw.setDstMAC(serverMAC)

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

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

    def resetStats(self):
        self.startTime = TIME()
        self.channelOccupation = {}