示例#1
0
    def sendPacket(self, packet, callCount=0):
        """
        param packet: Packet object
        param callCount: only used for the timeout mechanism.
        """
        # the packet is received

        if packet.ack == 1:
            print "###sending ACK packet###:", packet
            buf = util.packMsg(packet)
            self.transport.write(buf.raw, (self.serverAddress, self.serverPort))
            return

        if packet.seqNum != self.seqNum:
            return

        print "###sending packet###:", packet
        buf = util.packMsg(packet)
        self.transport.write(buf.raw, (self.serverAddress, self.serverPort))
        callCount += 1
        if callCount < attempt_num:
            reactor.callLater(timeout, self.sendPacket, packet, callCount)
        else:
            print "too many tries, packet:", packet," aborted"
            return
示例#2
0
    def sendPacket(self, packet, callCount=0):
        # send an ack packet to registered or non registered user
        # ack packet is sent only once
        if packet.ack == 1:
            print "###sending ACK packet### : ", packet
            buf = util.packMsg(packet)
            self.transport.write(buf.raw)
            return

        # not ack packet, set timeout and send later if packet is not received
        # when an un-ack packet is received, we stop the timeout
        if packet.seqNum != self.seqNum:  # packet is received
            return
        print "###sending packet### : ", packet
        buf = util.packMsg(packet)
        self.transport.write(buf.raw)
示例#3
0
    def sendPacket(self, packet):
        """
        param packet: Packet object
        param callCount: only used for the timeout mechanism.
        """
        if packet.ack == 1:
            print "###sending ACK packet###:", packet
            buf = util.packMsg(packet)
            self.transport.write(buf.raw)
            return

        if packet.seqNum != self.seqNum:
            return

        print "###sending packet###:", packet
        buf = util.packMsg(packet)
        self.transport.write(buf.raw)