from binascii import unhexlify from pynetstack.datastructs import EthernetFrame, IPPacket, ICMPPacket from pynetstack.tests.data import ping_request from pynetstack.tests.utils import print_object data = unhexlify(ping_request) ethernet_frame = EthernetFrame() ethernet_frame.decode(data) ip_packet = IPPacket() ip_packet.decode(ethernet_frame.payload) packet = ICMPPacket() packet.decode(ip_packet.payload) print_object(packet)
from binascii import unhexlify from pynetstack.datastructs import EthernetFrame, IPPacket from pynetstack.tests.utils import print_object data = unhexlify('002129994adce4115b2ca6d8080045000034e3084000400627bac0a80274cc02a0e2c7f100505b5ae554ee9f1067801007c7302800000101080a0008715f3ab2baa3') ethernet_frame = EthernetFrame() ethernet_frame.decode(data) print_object(ethernet_frame) packet = IPPacket() packet.decode(ethernet_frame.payload) print_object(packet) """ encoded = frame.encode() if ethernet_frame.payload[:28] == encoded: print 'encoding ok' else: print 'encoding failed' """
from binascii import unhexlify from pynetstack.datastructs import ARPPacket from pynetstack.tests.utils import print_object from datastructs import EthernetFrame data = unhexlify('ffffffffffff14dae94c72670806000108000604000114dae94c7267c0a80266000000000000c0a802fa000000000000000000000000000000000000') ethernet_frame = EthernetFrame() ethernet_frame.decode(data) frame = ARPPacket() frame.decode(ethernet_frame.payload) print_object(frame) encoded = frame.encode() if ethernet_frame.payload[:28] == encoded: print 'encoding ok' else: print 'encoding failed'