当前位置: 首页>>代码示例>>Python>>正文


Python Packet.createAcknowledgementPacket方法代码示例

本文整理汇总了Python中packet.Packet.createAcknowledgementPacket方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.createAcknowledgementPacket方法的具体用法?Python Packet.createAcknowledgementPacket怎么用?Python Packet.createAcknowledgementPacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在packet.Packet的用法示例。


在下文中一共展示了Packet.createAcknowledgementPacket方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _pushIfExpectedSequence

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import createAcknowledgementPacket [as 别名]
 def _pushIfExpectedSequence(self, packet):
     if packet.get_sequence_number() is self._next_sequence_number:
         self.ee.emit('data', packet.getPayload())
         # [1] Never send packets directly!
         self._packet_sender.send(Packet.createAcknowledgementPacket(packet.getSequenceNumber()))
         self._nextSequenceNumber += 1
         self._packets.seek()
         if self._packets.hasNext():
           self._pushIfExpectedSequence(self._packets.nextValue())
开发者ID:hoffmabc,项目名称:python-rudp,代码行数:11,代码来源:receiver.py

示例2: receive

# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import createAcknowledgementPacket [as 别名]
    def receive(self, packet):
        if self._closed:
            # Since this is closed, don't do anything.
            return

        # Ignores packets that have a sequence number less than the next sequence
        # number
        if not packet.getIsSynchronize() and packet.getSequenceNumber() < self._sync_sequence_number:
            return

        if packet.getIsSynchronize() and not self._synced:
            # This is the beginning of the stream.

            if packet.getSequenceNumber() is self._sync_sequence_number:
              self._packet_sender.send(Packet.createAcknowledgementPacket(packet.getSequenceNumber()))
              return

            # Send the packet upstream, send acknowledgement packet to end host, and
            # increment the next expected packet.
            self._packets.clear()
            self.ee.emit('data', packet.getPayload())
            self._packet_sender.send(Packet.createAcknowledgementPacket(packet.getSequenceNumber()))
            self._packets.insert(packet)
            self._next_sequence_number = packet.getSequenceNumber() + 1
            self._synced = True
            self._sync_sequence_number = packet.getSequenceNumber()


            if packet.getIsReset():
                self.ee.emit('_reset')
                self._synced = False

            # We're done.
            return

        elif (packet.getIsReset()):
            self.ee.emit('_reset')
            self.ee._synced = False

        elif not self._synced:
            # If we are not synchronized with sender, then this means that we should
            # wait for the end host to send a synchronization packet.

            # We are done.
            return

        elif packet.getSequenceNumber() < self._syncSequenceNumber:
            # This is a troll packet. Ignore it.
            return

        elif packet.getSequenceNumber() >= (self._packets.currentValue().getSequenceNumber() + constants.WINDOW_SIZE):
            # This means that the next packet received is not within the window size.
            self.ee.emit('_window_size_exceeded')
            return

        # This means that we should simply insert the packet. If the packet's
        # sequence number is the one that we were expecting, then send it upstream,
        # acknowledge the packet, and increment the next expected sequence number.
        #
        # Once acknowledged, check to see if there aren't any more pending packets
        # after the current packet. If there are, then check to see if the next
        # packet is the expected packet number. If it is, then start the
        # acknowledgement process anew.

        result = self._packets.insert(packet)

        if result is LinkedList.InsertionResult.INSERTED:
            self._pushIfExpectedSequence(packet)
        elif result is LinkedList.InsertionResult.EXISTS:
            self._packet_sender.send(Packet.createAcknowledgementPacket(packet.getSequenceNumber()))
开发者ID:hoffmabc,项目名称:python-rudp,代码行数:72,代码来源:receiver.py


注:本文中的packet.Packet.createAcknowledgementPacket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。