Esempio n. 1
0
 def __init__(self, **kwargs):
     """Constructor."""
     self.__model = None
     self.__bidirectional = None
     self.__graph = None
     self.__listen = {}
     Element.__init__(self, **kwargs)
Esempio n. 2
0
 def log(self, event=None, p=None, *args, **kwargs):
     """Overloaded to check verbose level and set common annotations."""
     force = False
     if ('verbose' in kwargs): force = (kwargs['verbose']>CHANNELIF_VERBOSE)
     if self.verbose>CHANNELIF_VERBOSE or force:
         kwargs.update(self.get_cif_anno(p))
         Element.log(self, event, p, *args, **kwargs)
Esempio n. 3
0
    def __init__(self, broadcast=None, nulladdr=None, mtu=None, **kwargs):
        """Constructor.

        :param broadcast: Broadcast address.
        :param nulladdr: Null address (used by `ARP`).
        :param mtu: Maximum transmission unit.

        If the `broadcast` address is not specified, then the default broadcast
        address is used.
        """
        if broadcast is None: broadcast = self.__class__.broadcast
        if nulladdr  is None: nulladdr  = self.__class__.nulladdr
        if mtu is None: mtu = self.__class__.mtu
        self.broadcast = broadcast
        self.mtu = mtu
        self.__phy = None
        self.__addr = None
        self.__htype = None
        self.checkcrc = None
        self.promiscuous = None
        self.drpdata = SimEvent()
        self.ackdata = SimEvent()
        Element.__init__(self, **kwargs)
        errmsg = "[MAC]: Invalid Port configuration! " + \
                 "Must have 'RXU' and 'TXU' ports!"
        assert self.hasport("RXU") and self.hasport("TXU"), errmsg
        self.drpdata.name = "%s.%s"%(self.name, "drpdata")
        self.ackdata.name = "%s.%s"%(self.name, "ackdata")
Esempio n. 4
0
    def __init__(self, mtu=None, **kwargs):
        """Constructor.

        :param mtu: Maximum transmission unit.
        """
        if mtu is None: mtu = self.__class__.mtu
        self.mtu = mtu
        self.__cif = None
        Element.__init__(self, **kwargs)
Esempio n. 5
0
 def __init__(self, **kwargs):
     """Constructor."""
     self.halduplex = None
     self.__ifstate = CHANNELIF_RX
     # set up events and buffer
     self.txdata = SimEvent(name="txdata")
     self.txdone = SimEvent(name="txdone")
     self.rxdata = SimEvent(name="rxdata")
     self.rxdone = SimEvent(name="rxdone")
     self.rxbuffer = []
     Element.__init__(self, **kwargs)
     # rename events
     self.txdata.name = "%s(%s).txdata"%(self.name, self.uid)
     self.txdone.name = "%s(%s).txdone"%(self.name, self.uid)
     self.rxdata.name = "%s(%s).rxdata"%(self.name, self.uid)
     self.rxdone.name = "%s(%s).rxdone"%(self.name, self.uid)
Esempio n. 6
0
    def __init__(self, broadcast=None, nulladdr=None, mtu=None, **kwargs):
        """Constructor.

        :param broadcast: Broadcast address.
        :param nulladdr: Null address (used by `ARP`).
        :param mtu: Maximum transmission unit.

        If the `broadcast` address is not specified, then the default broadcast
        address is used.
        """
        if broadcast is None:
            broadcast = self.__class__.broadcast
        if nulladdr is None:
            nulladdr = self.__class__.nulladdr
        if mtu is None:
            mtu = self.__class__.mtu
        self.broadcast = broadcast
        self.mtu = mtu
        self.__addr = None
        self.__ptype = None
        Element.__init__(self, **kwargs)
        assert self.hasport("RXD") and self.hasport("TXD"), (
            "[NET]: Invalid Port configuration! " + "Must have 'RXD' and 'TXD' ports!"
        )
Esempio n. 7
0
    def connect(self, net, mac):
        """Connect a `NET` and `MAC` to this `ARP` module.

        :param net: `NET` to be associated with `mac`.
        :param mac: `MAC` associated with `net`.

        This method will disconnect `net` and `mac` prior to connecting the
        elements to the `ARP` module. After creating the connection, this method
        will add the address info to `table` using `addentry()`. It will also
        add a mapping for the broadcast addresses as well.
        """
        if isinstance(net, Reference): net = net._deref
        if isinstance(mac, Reference): mac = mac._deref
        errmsg = "[ARP]: Cannot connect to non-NET (%s)!"%(net)
        assert isinstance(net, NET), errmsg
        errmsg =  "[ARP]: Cannot connect to non-MAC (%s)!"%(mac)
        assert isinstance(mac, MAC), errmsg
        self.disconnect(net)
        self.disconnect(mac)
        # add ports
        addport = lambda p: Element.addport(self, p)
        ptx, prx = addport((net,"TX")), addport((net,"RX"))
        htx, hrx = addport((mac,"TX")), addport((mac,"RX"))
        # connect net <-> mac through ARP
        ptx.connect(net.getport("RXD"))     # connect to net
        net.getport("TXD").connect(prx)
        htx.connect(mac.getport("RXU"))     # connect to mac
        mac.getport("TXU").connect(hrx)
        # create listeners as children
        tracename = "%s.%s"%(self.tracename,net.traceid)
        f = self.newchild((net, "listen"), FSM, tracename=tracename)
        f.goto(self.PSEND, net, mac)
        tracename = "%s.%s"%(self.tracename,mac.traceid)
        g = self.newchild((mac, "listen"), FSM, tracename=tracename)
        g.goto(self.HRECV, net, mac)
        # add listeners and start
        self.listen[net] = (mac, f)
        self.listen[mac] = (net, g)
        f.start(), g.start()
        errmsg =  "[ARP]: Error connecting (%s) <-> (%s)!"%(net, mac)
        assert self.connected(net) and self.connected(mac), errmsg
        # add entry (paddr, ptype) <-> (haddr, htype); and broadcast entry
        self.addentry(net.addr, mac.addr, net.ptype, mac.htype)
        self.addentry(net.broadcast, mac.broadcast, net.ptype, mac.htype)
Esempio n. 8
0
 def log(self, evt=None, p=None, *args, **kwargs):
     """Overloaded to check verbose level and set common annotations."""
     force = False
     if ('verbose' in kwargs): force = (kwargs['verbose']>CHANNEL_VERBOSE)
     if self.verbose>CHANNEL_VERBOSE or force:
         Element.log(self, evt, p, *args, **kwargs)
Esempio n. 9
0
 def __init__(self, **kwargs):
     """Constructor."""
     self.transmitter = Dot11N_Transmitter()
     self.receiver    = Dot11N_Receiver()
     self.rxinput = None
     Element.__init__(self, **kwargs)
Esempio n. 10
0
 def __init__(self, **kwargs):
     """Constructor."""
     self.__timer = None
     Element.__init__(self, **kwargs)
Esempio n. 11
0
 def __init__(self, **kwargs):
     """Constructor."""
     self.__tic = None
     self.__pos = None
     self.__vec = None
     Element.__init__(self, **kwargs)
Esempio n. 12
0
 def __init__(self, **kwargs):
     """Constructor."""
     self.base = None
     self.__db = {}
     Element.__init__(self, **kwargs)
Esempio n. 13
0
 def log(self, event=None, p=None, *args, **kwargs):
     """Overloaded to check verbose level and set common annotations."""
     kwargs.update(self.get_net_anno(p))
     Element.log(self, event, p, *args, **kwargs)
Esempio n. 14
0
 def __init__(self, **kwargs):
     self.__listen = {}
     self.__table = {}
     self.__useshared = False
     Element.__init__(self, **kwargs)