IP header and TCP header data structure (C)

Source: Internet
Author: User
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
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.