Пример #1
0
    def test_RTM_AUTO_ackduplication(self):
        alice_0 = Channel(0, RTM_AUTO)
        bob_0 = Channel(0, RTM_AUTO)

        alice_0.write(bytearray('DUPA'))
        pk = alice_0.on_sendable()
        self.assertEquals(alice_0.is_tx_in_progress(), True)

        bob_0.on_received(pk)

        self.assertEquals(bob_0.read(), bytearray('DUPA'))

        ack = bob_0.on_sendable()
        self.assertEquals(ack.is_ack, True)

        alice_0.on_received(ack)
        alice_0.on_received(ack)

        self.assertEquals(alice_0.is_tx_in_progress(), False)
Пример #2
0
    def test_RTM_AUTO_ackduplication(self):
        alice_0 = Channel(0, RTM_AUTO)
        bob_0 = Channel(0, RTM_AUTO)

        alice_0.write(bytearray('DUPA'))
        pk = alice_0.on_sendable()
        self.assertEquals(alice_0.is_tx_in_progress(), True)

        bob_0.on_received(pk)

        self.assertEquals(bob_0.read(), bytearray('DUPA'))

        ack = bob_0.on_sendable()
        self.assertEquals(ack.is_ack, True)

        alice_0.on_received(ack)
        alice_0.on_received(ack)

        self.assertEquals(alice_0.is_tx_in_progress(), False)
Пример #3
0
    def test_RTM_AUTO_resend(self):
        alice_0 = Channel(0, RTM_AUTO, 0.5)
        bob_0 = Channel(0, RTM_AUTO, 0.5)

        alice_0.write(bytearray('DUPA'))
        pk = alice_0.on_sendable()

        sleep(0.6)

        pk = alice_0.on_sendable()
        self.assertEquals(alice_0.is_tx_in_progress(), True)

        bob_0.on_received(pk)

        ack = bob_0.on_sendable()
        self.assertEquals(ack.is_ack, True)

        alice_0.on_received(ack)

        self.assertEquals(alice_0.is_tx_in_progress(), False)
Пример #4
0
    def test_RTM_AUTO_resend(self):
        alice_0 = Channel(0, RTM_AUTO, 0.5)
        bob_0 = Channel(0, RTM_AUTO, 0.5)

        alice_0.write(bytearray('DUPA'))
        pk = alice_0.on_sendable()

        sleep(0.6)

        pk = alice_0.on_sendable()
        self.assertEquals(alice_0.is_tx_in_progress(), True)

        bob_0.on_received(pk)

        ack = bob_0.on_sendable()
        self.assertEquals(ack.is_ack, True)

        alice_0.on_received(ack)

        self.assertEquals(alice_0.is_tx_in_progress(), False)
Пример #5
0
    def test_RTM_MANUAL_handover(self):
        """Tests an in-transmission packet content change"""
        alice_0 = Channel(0, RTM_MANUAL, 0.5)
        bob_0 = Channel(0, RTM_MANUAL, 0.5)

        alice_0.write(bytearray('DUPA'))
        pk = alice_0.on_sendable()

        sleep(0.6)

        alice_0.write(bytearray('STEFAN'))

        pk = alice_0.on_sendable()

        bob_0.on_received(pk)

        ack = bob_0.on_sendable()
        self.assertEquals(ack.is_ack, True)

        alice_0.on_received(ack)

        self.assertEquals(alice_0.is_tx_in_progress(), False)
        self.assertEquals(bob_0.read(), bytearray('STEFAN'))
Пример #6
0
    def test_RTM_MANUAL_handover(self):
        """Tests an in-transmission packet content change"""
        alice_0 = Channel(0, RTM_MANUAL, 0.5)
        bob_0 = Channel(0, RTM_MANUAL, 0.5)

        alice_0.write(bytearray('DUPA'))
        pk = alice_0.on_sendable()

        sleep(0.6)

        alice_0.write(bytearray('STEFAN'))

        pk = alice_0.on_sendable()

        bob_0.on_received(pk)

        ack = bob_0.on_sendable()
        self.assertEquals(ack.is_ack, True)

        alice_0.on_received(ack)

        self.assertEquals(alice_0.is_tx_in_progress(), False)
        self.assertEquals(bob_0.read(), bytearray('STEFAN'))