Example #1
0
 def __init__(self, n_tips=3):
     super(Switch, self).__init__(n_tips)
     self.nics = [NIC(tip) for tip in self.tips]
     mac2port = CacheTable(entry_duration=1000)
     self.ports = [
         Port(
             host=self,
             nic=nic,
             mac2port=mac2port,
             index=i,
         ) for i, nic in enumerate(self.nics)
     ]
     each(self.ports).calc_other_ports(self.ports)
     mint.worker(self.run, priority=simulation.SWITCH_PRIORITY)
Example #2
0
    def __init__(self, ip=None, mac=None):
        super(Host, self).__init__(n_tips=1)
        self.tip = self.tips[0]
        self.nic = NIC(self.tip)
        self.libsocket = LibSocket(self)

        if mac is None:
            mac = self.index
        if ip is None:
            ip = '1.0.0.{}'.format(self.index)
        self.ip = ip_from_user(ip)
        self.mac = mac_from_user(mac)

        self.ip2mac = CacheTable(entry_duration=1000)
        self.arp_table = self.ip2mac
        self.avail_ports = defaultdict(lambda: 49152)
        self.pending_packets = defaultdict(deque)
        self.pending_frames = deque()
        self.sockets = {}

        mint.worker(self.run)
Example #3
0
 def __init__(self, n_interfaces):
     super(EntityWithNIC, self).__init__(n_interfaces)
     self.nics = [NIC(tip) for tip in self.tips]
     self.nic = self.nics[0]