def run(self): if not self.ip: self.dhcp = DHCPClient(self) while True: self.interface.do_send() self.interface.do_recv() mint.elapse(1)
def recvfrom(self, bufsize=0): while True: try: data, (ip, port) = self.idatagrams.popleft() ip = str(ip) port = int(port) return data, (ip, port) except IndexError: mint.elapse(1)
def f_(*args, **kwargs): while True: block = kwargs.pop('block', True) try: return f(*args, **kwargs) except exc: if block: mint.elapse(1) else: raise
def run(self): while True: self.routes.remove_expired_entries() for iport in self.ports: try: raw = iport.recv(block=False) except Empty: continue frame = Frame(raw) self.routes.register(frame.src, iport) oports = self.routes.get(frame.dst, exclude=iport) for oport in oports: try: oport.send(raw, block=False) except Full: mint.report('frame dropped {}', repr(raw)) mint.elapse(1)
def run(self): while True: self.output() self.input() mint.elapse(1)
def run(self): while True: self.send() self.recv() mint.elapse(1)
def run(self): while True: self.transfer(self.tips[0], self.pipes[0], self.tips[1]) self.transfer(self.tips[1], self.pipes[1], self.tips[0]) mint.elapse(1)
def recvfrom(self, bufsize=0): while True: try: return self.idata.popleft() except IndexError: mint.elapse(1)
def run(self): while True: each(self.interfaces).do_send() each(self.interfaces).do_recv() mint.elapse(1)
raise NotImplementedError(''' currently the link implementation does not allow frame animation on link out of a hub cause hub work on physical layer and has no sense of frame all together also, the current frame animation is unfit for link with positive latency we'll tackle this in the future ''' import mint from mint.core import Entity from mint.utils import each class Hub(Entity): def __init__(self, n_ports=3): super(Hub, self).__init__(n_ports) def run(self): while True: isum = sum(each(self.tips).isymbol) each.v(sample)(self.tips, isum) mint.elapse(1) def sample(tip, isum): tip.osymbol = 1 if (isum - tip.isymbol) else 0
def run(self): while True: self.interface.do_send() self.interface.do_recv() mint.elapse(1)
def run(self): while True: each(self.ports).forward() mint.elapse(1)