def recver(self): while True: frame = self.servant.recv() header, payload, _ = self.decompose(frame) header = self.unbuild(header) if header.acking: # sending frame ACKed if header.ack == self.sending_seq: self.acked = True self.sending_seq = (self.sending_seq + 1) % self.SEQ_SIZE self.timer.stop() if payload: # is the expecting frame if header.seq == self.expecting_seq: self.master.push(payload) self.expecting_seq = (self.expecting_seq + 1) % self.SEQ_SIZE else: utils.put(self.host, 'drop', struct.unpack('!B', payload)[0], 'at', mint.now()) # send ACK header = self.build( acking=True, ack=header.seq, # ack the recved frame seq=0) # meaningless frame = self.compose(header) # no payload self.servant.send(frame)
def show(self, fmt='iioo'): def join(frame): return ''.join('1' if bit else '0' for bit in frame) if 'oo' in fmt: utils.put(self.host, 'os', ' '.join(utils.format(f, 'bin') for f in self._oframes)) if 'o' in fmt: utils.put(self.host, 'o ', join(self._oframe)) if 'i' in fmt: utils.put(self.host, 'i ', join(self._iframe)) if 'ii' in fmt: utils.put(self.host, 'is', ' '.join(utils.format(f, 'bin') for f in self.iframes))
def show(self, fmt='iioo'): def join(frame): return ''.join('1' if bit else '0' for bit in frame) if 'oo' in fmt: utils.put(self.host, 'os', ' '.join( utils.format(f, 'bin') for f in self._oframes)) if 'o' in fmt: utils.put(self.host, 'o ', join(self._oframe)) if 'i' in fmt: utils.put(self.host, 'i ', join(self._iframe)) if 'ii' in fmt: utils.put(self.host, 'is', ' '.join( utils.format(f, 'bin') for f in self.iframes))
def title(self): utils.put('=' * 25 + ' {}'.format(self.now))
def show(self): utils.put(self) utils.put('\to {}', self.osymbol) utils.put('\ti {}', self.isymbol)
def title(self): utils.put('=' * 25 + ' {} {}'.format(self.now, self.phase))
def show(self): utils.put(self) utils.put("\to {}", self.osymbol) utils.put("\ti {}", self.isymbol)