# 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 = {} self.channelSamples = 0.0
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() self.channelOccupation = {} self.channelSamples = 0.0
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() self.channelOccupation = {}