The following TCP/IP data packets are the data packet structures that I have used during socket and wipcap network programming. These data packets seem inconspicuous at ordinary times, it will be very useful when actually used ...... /* Physical Frame header structure */ Typedef struct { ?? Byte? Desmac [6]; // target MAC address ?? Byte? Srcmac [6]; // source MAC address ?? Ushort? Ethertype; // Frame Type } Dlc_header ;?????? /* IP header structure */ Typedef struct? { ? Byte? H_len_ver ;? // IP version number (4 digits in height) and length of the IP packet header in 32 bits (four digits below) ? Byte? ToS ;????? // Service type TOS ? Ushort total_len; // total IP package length? ? Ushort ident ;???? // ID ? Ushort frag_and_flags ;? // Flag Space ? Byte TTL ;????? // Survival time ? Byte proto ;??? // Protocol ? Ushort checksum; // IP header checksum ? Byte? Sourceip [4]; // source IP address (32-bit) ? // Or uint? Sourceip; ? Byte? Destip [4];? // Destination IP address (32-bit) // Or uint? Destip; } Ip_header; /* TCP Header */ Typedef struct { ? Ushort? Srcport; // Source Port ? Ushort? Dstport; // the destination port. ? Uint? Seqnum ;? // Sequence number ? Uint? Acknum ;? // Expect to get the peer's TCP Package number ? Byte h_len ;? // TCP Header Length in 32 bits ? Byte? Flags; // flag (URG, ack, etc) ? Ushort indow; // window size ? Ushort chksum; // checksum ? Ushort urgptr; // emergency pointer } Tcp_header; // The TCP pseudo header is used for TCP checksum calculation to ensure the validity of TCP verification. Typedef struct { Ulong sourceip; // source IP address Ulong destip; // destination IP address Byte mbz; // null (0) Byte ptcl; // protocol type (ipproto_tcp) Ushort tcpl; // The length of the TCP Header (unit: bytes) } Psd_header; /* UDP header */ Typedef struct? { Ushort srcport; // Source Port Ushort dstport; // destination port Ushort total_len; // The length of the UDP header and UDP data (unit: bytes) Ushort chksum; // checksum } Udp_header; // UDP pseudo header-used only for calculating the checksum Typedef struct tsd_hdr { Byte sourceip [4]; // source IP address Byte destip [4]; // destination IP address Byte mbz; // null (0) Byte ptcl; // protocol type (ipproto_udp) Ushort udpl; // The total length of the UDP packet (excluding the length unit of the pseudo header: bytes) } Psd_header; /* ICMP header */ Typedef struct { ? Byte I _type ;?? // The type of ICMP sent is 8 (icmp_echo_request), and the received ICMP is 0. ? Byte I _code ;?? // Code ? Ushort I _cksum; // ICMP packet checksum ? Ushort I _id ;??? // Identification number (process number is generally used as the identification number) ? Ushort I _seq ;?? // Message serial number (usually set to 0) ? Ulong timestamp; // Timestamp } Icmp_header;
// ARP Frame Structure Typedef struct { ?? Ushort hw_type; // hardware type: 0x1 ?? Ushort prot_type; // upper-layer protocol type IP Address: 0x0800 ?? Byte hw_addr_len; // hardware address length: 6 ?? Byte prot_addr_len; // Protocol address (IP address) Length: 4 ?? Ushort flag; // 1 indicates the request and 2 indicates the response ?? Byte send_hw_addr [6]; // source MAC address ?? Byte send_prot_addr [4]; // source IP address ?? Byte targ_hw_addr [6]; // target MAC address ?? Byte targ_prot_addr [4]; // destination IP address ?? Byte padding [18]; // fill in data? } Arp_frame; /* DNS data header */ Typedef struct { Ushort ID; // ID. The client can match the DNS request with the response; Ushort flags; // flag: (query) 0x0100 (response) 0x8180? These numbers are in the host sequence. Ushort questions; // number of problems Ushort answers; // number of resource records Ushort author; // number of authorized resource records Ushort addition; // number of additional resource records } Dns_header; // This is the public part of the DNS package, that is, both the query package and the response package contain this part. The query problem (domain) cannot be determined, therefore, it is difficult to write data in the struct |