IMPORTANT This code does not work on windows. Use Debian OS to run this code. This code uses AF_PACKET function of socket module which is not available for windows. Same goes for AF_INET. Some concepts 1) Ethernet Frame Header 2) Mac Address unpacking 3) IPv4 Header 4) ICMP packet 5) TCP packet 6) UDP Packet