예제 #1
0
try:
    import psyco
    psyco.full()
except ImportError:
    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
예제 #2
0
from nessi.devices import NIC
from nessi.csma import IdealRadioPhy, AlohaDL, CSMADL, CSMA_CA_DL
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)
예제 #3
0
파일: lan-ethernet.py 프로젝트: T3Fei/Nessi
            bitstream = bitstream[:1500]
        self.lowerLayer.send(bitstream, self.dstMAC, self.srcMAC,
                             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
예제 #4
0
try:
    import psyco
    psyco.full()
except ImportError:
    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
예제 #5
0
from nessi.dlc import FullDuplexPhy
from nessi.arq import StopAndGoDL, GoBackNDL, SelectiveRepeatDL
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)