Example #1
0
    pass

# ---------------------------------------------------------------------------
# Create the network

goodlink = PtPLink()
badlink = ErrorPtPLink()

hosts=[]
# Create two nodes
for i in range(2):
    h = Host()
    h.hostname = "host"+str(i)
    # On each node, create two interfaces, eth0 and eth1
    for j in range(2):
        niu = NIC()
        h.addDevice(niu,"eth"+str(j))
        niu.addProtocol(FullDuplexPhy(), "phy")
        niu.addProtocol(PointToPointDL(), "dl")
    # eth0 is attached to the errored link, eth1 to the error-free link
    h.eth0.attachToMedium(badlink, 100.0*i)
    h.eth1.attachToMedium(goodlink, 10.0*i) # The good link is shorter
    hosts.append(h)

# Give the hosts good names
h1,h2 = hosts

# Connect the source and the sink
source = ChksumSource()
h1.addProtocol(source, "app")
source.registerLowerLayer(h1.eth0.dl)
Example #2
0
from nessi.trafficgen import PoissonSource, TrafficSink
try:
    import psyco
    psyco.full()
except ImportError:
    pass

# ---------------------------------------------------------------------------
# Create the network
link = IdealRadioChannel()
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(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:]:
Example #3
0
    pass

# ---------------------------------------------------------------------------
# Create the network

goodlink = PtPLink()
badlink = ErrorPtPLink()

hosts = []
# Create two nodes
for i in range(2):
    h = Host()
    h.hostname = "host" + str(i)
    # On each node, create two interfaces, eth0 and eth1
    for j in range(2):
        niu = NIC()
        h.addDevice(niu, "eth" + str(j))
        niu.addProtocol(FullDuplexPhy(), "phy")
        niu.addProtocol(PointToPointDL(), "dl")
    # eth0 is attached to the errored link, eth1 to the error-free link
    h.eth0.attachToMedium(badlink, 100.0 * i)
    h.eth1.attachToMedium(goodlink, 10.0 * i)  # The good link is shorter
    hosts.append(h)

# Give the hosts good names
h1, h2 = hosts

# Connect the source and the sink
source = ChksumSource()
h1.addProtocol(source, "app")
source.registerLowerLayer(h1.eth0.dl)
Example #4
0
                             self.protocolType)
    def sendStatus(self,status,bitstream):
        if self.upperLayer:
            self.upperLayer.sendStatus(status,bitstream)
    def receive(self,bitstream):
        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()
Example #5
0
try:
    import psyco

    psyco.full()
except ImportError:
    pass

# ---------------------------------------------------------------------------
# Create the network
link = IdealRadioChannel()
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(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:]:
Example #6
0
from nessi.trafficgen import DLFlooder, TrafficSink
try:
    import psyco
    psyco.full()
except ImportError:
    pass

# ---------------------------------------------------------------------------
# Create the network
link = ErrorPtPLink()
hosts = []
# Create two nodes
for i in range(2):
    h = Host()
    h.hostname = "host" + str(i + 1)
    niu = NIC()
    h.addDevice(niu, "eth0")
    niu.addProtocol(FullDuplexPhy(), "phy")
    niu.addProtocol(StopAndGoDL(), "dl")  # CHANGE HERE FOR A DIFFERENT ARQ
    h.eth0.attachToMedium(link, 1000000.0 * i)  # Length: 1000 km
    hosts.append(h)

# For convenience, use short variable names for the hosts
h1, h2 = hosts

# Connect the source and the sink
source = DLFlooder()
h1.addProtocol(source, "app")
source.registerLowerLayer(h1.eth0.dl)
h1.eth0.dl.registerUpperLayer(source)