コード例 #1
0
 def handleDatagram(self, buffer):
     dataPacket = DataPacket()
     dataPacket.buffer = buffer
     dataPacket.decode()
     if dataPacket.sequenceNumber < self.windowStart:
         return
     elif dataPacket.sequenceNumber > self.windowEnd:
         return
     elif dataPacket.sequenceNumber < len(self.receivedWindow):
         return
     diff = dataPacket.sequenceNumber - self.lastSequenceNumber
     if dataPacket.sequenceNumber < len(self.nackQueue):
         del self.nackQueue[dataPacket.sequenceNumber]
     self.ackQueue.append(dataPacket.sequenceNumber)
     self.receivedWindow.append(dataPacket.sequenceNumber)
     if diff != 1:
         i = self.lastSequenceNumber + 1
         while i < dataPacket.sequenceNumber:
             if i not in self.receivedWindow:
                 self.nackQueue.append(i)
             i += 1
     if diff >= 1:
         lastSequenceNumber = dataPacket.sequenceNumber
         self.windowStart += diff
         self.windowEnd += diff
     for packet in dataPacket.packets:
         self.receivePacket(EncapsulatedPacket.fromBinary(packet))
コード例 #2
0
 def decodePayload(self):
     self.sequenceNumber = self.getLTriad()
     while not self.feof():
         self.packets.append(EncapsulatedPacket.fromBinary(self))
コード例 #3
0
 def close(self):
     self.addEncapsulatedToQueue(
         EncapsulatedPacket.fromBinary(BinaryStream(b"\x00\x00\x08\x15")),
         self.priority["Immediate"])
コード例 #4
0
 def close(self):
     self.addEncapsulatedToQueue(EncapsulatedPacket.fromBinary('\x00\x00\x08\x15'), self.priority["Immediate"])