def addToQueue(self, pk, flags = priority["Normal"]): priority = flags & 0b0000111 if pk.needAck and pk.messageIndex is not None: self.needAck[pk.identifierAck] = pk.messageIndex if priority == self.priority["Immediate"]: packet = DataPacket() packet.sequenceNumber = self.sendSequenceNumber self.sendSequenceNumber += 1 if pk.needAck: packet.packets.append(deepcopy(pk)) pk.needAck = False else: packet.packets.append(pk.toBinary()) self.sendPacket(packet) packet.sendTime = timeNow() self.recoveryQueue[packet.sequenceNumber] = packet return length = len(self.sendQueue) if (length + pk.getTotalLength()) > self.mtuSize: self.sendTheQueue() if pk.needAck: self.sendQueue.packets.append(deepcopy(pk)) pk.needACK = False else: self.sendQueue.packets.append(pk.toBinary())
def addToQueue(self, pk, flags=priority["Normal"]): priority = flags & 0b1 if priority == self.priority["Immediate"]: packet = DataPacket() packet.sequenceNumber = self.sendSequenceNumber self.sendSequenceNumber += 1 packet.packets.append(pk) self.sendPacket(packet) packet.sendTime = timeNow() self.recoveryQueue[packet.sequenceNumber] = packet return length = self.sendQueue.length() if (length + pk.getTotalLength()) > self.mtuSize: self.sendTheQueue() self.sendQueue.packets.append(pk)