def __init__(self, n_interfaces): assert n_interfaces > 0 self.tips = [Tip(self) for _ in xrange(n_interfaces)] self.tip = self.tips[0] self.stdout = [] mint.add(self) mint.worker(self.run)
def __init__(self, a, b, latency=0): super(Link, self).__init__(n_tips=2) a.peer_with(self.tips[0]); self.tips[1].peer_with(b) self.latency = latency self.pipes = [deque([0] * self.latency) for _ in xrange(2)] self.endpoint_names = map(str, each(self.tips).peer.host) mint.worker(self.run, priority=simulation.LINK_PRIORITY)
def __init__(self, delimiter, mac, handlers=None): if handlers is None: handlers = {} self.handlers = handlers self.delimiter = delimiter self.mac = mac mint.worker(self.run)
def __init__(self, a, b, latency=0): super(Link, self).__init__(n_tips=2) a.peer_with(self.tips[0], by=self) self.tips[1].peer_with(b, by=self) self.latency = latency self.pipes = [deque([0] * self.latency) for _ in xrange(2)] self.endpoint_names = map(str, each(self.tips).peer.host) mint.worker(self.run, priority=simulation.LINK_PRIORITY)
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)
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)
def __init__(self, *args, **kwargs): super(BitFramer, self).__init__(*args, **kwargs) self.oframe = Outputter() self.iframe = Inputter() mint.worker(self.run)
def __init__(self, *args, **kwargs): super(NIC, self).__init__(*args, **kwargs) self.oframe = Outputter(self.host) self.iframe = Inputter(self.host) mint.worker(self.run, priority=simulation.NIC_PRIORITY)
def __init__(self, n_tips=3): super(Switch, self).__init__(n_tips) self.ports = [BitFramer(tip) for tip in self.tips] self.routes = Switch.Routes(self.ports) mint.worker(self.run, priority=simulation.SWITCH_PRIORITY)
def __init__(self, n_tips=3): super(Switch, self).__init__(n_tips) self.ports = [BitDelimiter(tip) for tip in self.tips] self.routes = Switch.Routes(self.ports) mint.worker(self.run, priority=simulation.SWITCH_PRIORITY)