The IP and UDP headers require a checksum to be calculated. Information about UDP headers can be found here. Where an IP and MAC address are used to determine what computer the information is meant for, ports are used by UDP to determine what application the information is meant for. UDP is used by many applications, and so there has to be a way for an application to know which information is meant for it. We will have to fill all of this in after we fill in the Ethernet code. Information about the IP header can be found here. The IP header stores the IP addresses of the source and the destination as well as other important data. The packet was made using the example application and captured using Wireshark.) Second part of the packet - IP header (An image showing the individual bytes we will have to fill in later. In this case, "0x0800" is used to specify IPv4. The "type" part of the Ethernet II header specifies what kind of packet is being used. If you use this code in a network with more than one LAN, you will have to determine what default gateway address to use with GetIpNetTable and your own addresses. A default gateway is a modem/router/computer that connects a network to the Internet or another network. In this article, I set the destination hardware address to that of my " Default Gateway". The most important thing here is the destination hardware address because it determines the first place the packet is sent after being created. This header consists of three main parts: the destination hardware address, the source hardware address, and the type. How a UDP packet works Headers First part of the packet - Ethernet II headerĪ packet to be sent through the Internet usually starts with an Ethernet II header. These are included in the Windows SDK, and can be downloaded for free here (1.33 GB good luck dial-up users). Some functions and structures used in this article are from Winsock2 and the Iphlp API. Also, if you want to run WinPCap applications, you will have to install the WinPcap binaries. Make sure you do this because I spent a good time wondering why my WinPCAp project would not compile despite me checking for errors many times. In Visual Studio 2008, this can be done in the C++ Options of your project. Once the libraries are set up, you need to add " HAVE_REMOTE" to your preprocessor. The WinPCap 4.02 libraries I use here can be downloaded here. Lastly, you must know how to install headers and libraries for use with your compiler. Also, know how memcpy() works it's used a lot. The headers involved are Ethernet II, IP, and UDP. Additionally, you might want to review the packet headers before reading over this material. You should know the basics of how computers communicate through the Internet this includes knowing what packets, sockets, UDP, IP addresses, and MAC addresses are. With WinPcap, it is possible to specify your own source IP and source hardware addresses in packets. The reason I use WinPCap in this article is that it solves the issue of Winsock for Windows (XP SP2 and above) not allowing raw UDP packets to be sent (in Linux, you can just use regular sockets). Please note that the code here is very minimalistic, and can be greatly expanded depending on your needs. The code has been tested to work with Windows XP SP2 and Vista SP1 on Linksys routers, and on Toshiba modems connected directly to the Internet. In this article, I will explain how to create UDP packets and then send them to a remote server through the Internet using WinPCap for Windows.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |