IP header and TCP header data structure (C)
Public struct ip_hdr // IP Header
{
Public byte h_lenver; // 4-bit Header Length + 4-bit IP version number
Public byte tos; // 8-bit service type TOS
Public ushort total_len; // The total length of 16 bits (in bytes)
Public ushort ident; // 16-bit ID
Public ushort frag_and_flags; // 3-digit flag + 13-digit offset
Public byte ttl; // 8-bit TTL
Public byte proto; // 8-bit protocol (TCP, UDP, or other)
Public ushort checksum; // The 16-bit IP header checksum.
Public uint sourceIP; // 32-bit source IP address
Public uint destIP; // 32-bit destination IP address
}
Public struct tcp_hdr // TCP Header
{
Public ushort th_sport; // 16-bit Source Port
Public ushort th_dport; // 16-bit destination port
Public uint th_seq; // 32-bit serial number
Public uint th_ack; // 32-bit confirmation number
Public byte th_lenres; // 4-bit header length/6-bit reserved words
Public byte th_flag; // 6-digit flag
Public ushort th_win; // 16-bit window size
Public ushort th_sum; // 16-bit checksum
Public ushort th_urp; // 16-bit emergency data offset
}