How to use the pythonping.icmp.Types function in pythonping

To help you get started, we’ve selected a few pythonping examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alessandromaggio / pythonping / test / test_executor.py View on Github external
def test_success(self):
        """Verifies the if the Response can indicate a success to a request correctly"""
        self.assertTrue(self.craft_response_of_type(icmp.Types.EchoReply).success,
                        'Unable to validate a successful response')
        self.assertFalse(self.craft_response_of_type(icmp.Types.DestinationUnreachable).success,
                         'Unable to validate Destination Unreachable')
        self.assertFalse(self.craft_response_of_type(icmp.Types.BadIPHeader).success,
                         'Unable to validate Bad IP Header')
        self.assertFalse(executor.Response(None, 0.1).success, 'Unable to validate timeout (no payload)')
github alessandromaggio / pythonping / test / test_icmp.py View on Github external
def test_checksum_creation(self):
        """Verifies it generates the correct checksum, given packet data"""
        packet = icmp.ICMP(icmp.Types.EchoRequest, payload='random text goes here', identifier=16)
        self.assertEqual(packet.expected_checksum, 485, 'Checksum creation failed')
        packet = icmp.ICMP(icmp.Types.EchoReply, payload='foobar', identifier=11)
        self.assertEqual(packet.expected_checksum, 48060, 'Checksum creation failed')
github alessandromaggio / pythonping / test / test_icmp.py View on Github external
def test_pack(self):
        """Verifies that creates the correct pack"""
        self.assertEqual(
            icmp.ICMP(icmp.Types.EchoReply, payload='banana', identifier=19700).packet,
            b'\x00\x00\xcb\x8e\xf4L\x01\x00banana',
            "Fail to pack ICMP structure to packet"
        )
        self.assertEqual(
            icmp.ICMP(icmp.Types.EchoReply, payload='random text goes here', identifier=12436).packet,
            b'\x00\x00h\xd1\x940\x01\x00random text goes here',
            "Fail to pack ICMP structure to packet"
        )
        self.assertEqual(
            icmp.ICMP(icmp.Types.EchoRequest, payload='random text goes here', identifier=18676).packet,
            b'\x08\x00\x00\xb9\xf4H\x01\x00random text goes here',
            "Fail to unpack ICMP structure to packet"
        )
github alessandromaggio / pythonping / test / test_executor.py View on Github external
def test_success(self):
        """Verifies the if the Response can indicate a success to a request correctly"""
        self.assertTrue(self.craft_response_of_type(icmp.Types.EchoReply).success,
                        'Unable to validate a successful response')
        self.assertFalse(self.craft_response_of_type(icmp.Types.DestinationUnreachable).success,
                         'Unable to validate Destination Unreachable')
        self.assertFalse(self.craft_response_of_type(icmp.Types.BadIPHeader).success,
                         'Unable to validate Bad IP Header')
        self.assertFalse(executor.Response(None, 0.1).success, 'Unable to validate timeout (no payload)')