Exemple #1
0
 def handleDatagram(self, buffer):
     dataPacket = DataPacket()
     dataPacket.buffer = buffer
     dataPacket.decode()
     if dataPacket.sequenceNumber < self.windowStart:
         return
     if dataPacket.sequenceNumber > self.windowEnd:
         return
     if 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:
         self.lastSequenceNumber = dataPacket.sequenceNumber
         self.windowStart += diff
         self.windowEnd += diff
     for packet in dataPacket.packets:
         self.receivePacket(packet)
 def handleDatagram(self, buffer):
     dataPacket = DataPacket()
     dataPacket.buffer = buffer
     dataPacket.decode()
     if dataPacket.sequenceNumber in self.receivedWindow:
         return
     if dataPacket.sequenceNumber in self.nackQueue:
         self.nackQueue.remove(dataPacket.sequenceNumber)
     self.ackQueue.append(dataPacket.sequenceNumber)
     self.receivedWindow.append(dataPacket.sequenceNumber)
     diff = dataPacket.sequenceNumber - self.lastSequenceNumber
     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:
         self.lastSequenceNumber = dataPacket.sequenceNumber
     for packet in dataPacket.packets:
         self.receivePacket(packet)