IP head = 4-bit version 4-position length 8 bit service type (TOS) 16 bit total length 16 bits ID 3-bit flag 13-bit offset 8 bit Space (TTL) 8 Agreement 16-bit inspection and 32-bit source IP address 32 bit IP address.
Can be defined as follows: typedef struct {byte hlen: 4; // 4 length Byte Vers: 4; // 4 version
// TOS service type begin ******************************************************** * No minimum cost (this variable is valid only in NNTP) *** Byte ST_NOUSE: 2; // Unused BYTE ST_RELIABILITY: 1; // Highest Reliability BYTE ST_THROUGHPUT: 1; // Maximum throughput BYTE ST_DELAY: 1 ; // minimum time post, byte st_precendnce: 3; // Prioritital status field (it is said to have now been ignored) // TOS service type End *************************** **********
Word Totallen; // 16-bit total length (bytes) Word ID; // 16-bit identification // 13-seat slide and 3-bit flags are used in IP slice byte offhigh: 5; // 13 Biased 5 digits
// 3-bit sign begin ****************************** BYTE flag_morefrag: 1; // More divided slums BYTE flag_donotfrag: 1; // Independent portable BYTE FLAG_NOUSE: 1; // 3 bits logo End *********************
BYTE OFFLOW: 8; // 13-seat offset low 8 digits
BYTE TIMETOLIVE: 8; // TTL 8-bit survival time Byte Protocol: 8; // 8-bit protocol Word hchecksum; // 16 first inspection and Byte Sip [4]; // 32-bit source IP address BYTE DIP [4] ; // 32 bit of IP address} ipheader;
TCP header = 16-bit source port number 16-bit destination port number 32 bit number 32 bit confirmation number 4-position length reserved bit (6 digits) URG ACK PSH RST SYN FIN 16 bit Window size 16-bit inspection and 16 emergency pointers
Can be defined as follows: typedef struct {word sport; // 16-bit source port number word dport; // 16-bit destination port number DWORD seqnum; // 32 bit number DWORD ACKNUM; // 32 bit confirmation number BYTE RESERVED1: 4; / / Retain 4 Byte Hlen: 4; // 4 top length
BYTE CB_FIN: 1; // The sender completes the send task Byte CB_SYN: 1; // Synchronous serial number to initiate a connection Byte CB_RST: 1; // Rebuild connection Byte CB_PSH: 1; // Receiver should be as soon as possible Give the application layer BYTE CB_ATE CB_ATE CB_ATE CB_ATE CB_URG: 1; // Emergency Pointer Effective BYTE Reserved2: 2; // Reserved 2 Ben Word Window; // 16 Position Word Checksum; // 16 Test and Word Urgptr; // 16 Emergency Pointer} TCPHEADER;