Esempio n. 1
0
        if self.upperLayer:
            self.upperLayer.receive(bitstream)
# ---------------------------------------------------------------------------
# Create the network
link = Bus()
numHosts = 31 # CHANGE HERE FOR THE NUMBER OF NODES
hosts=[]
for i in range(numHosts):
    h = Host()
    h.hostname = "host"+str(i)
    niu = NIC()
    h.addDevice(niu,"eth0")
    niu.addProtocol(PHY(), "phy")
    niu.addProtocol(MAC(), "mac")
    niu.addProtocol(LLC(), "dl")
    h.addProtocol(PseudoNW(), "nw")
    h.nw.setSrcMAC(h.eth0.mac.address)
    h.nw.setProtocolType(2048)
    h.nw.registerLowerLayer(niu.dl)
    h.eth0.dl.registerUpperLayer(h.nw, 2048)
    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
Esempio n. 2
0
    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()
        self.channelOccupation = {}
Esempio n. 3
0
    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()