OctopusLian / leetcode-solutions

LeetCode,LintCode,牛客网,企业题库,《Sword to Offer》,《Cracking the Coding Interview》题解
MIT License
4 stars 4 forks source link

每日一题:TCP头部信息有哪些?(滴滴一面) #157

Closed OctopusLian closed 2 years ago

OctopusLian commented 4 years ago

https://blog.nowcoder.net/n/9eb1ea4dbecf4cdcbb1afe104e6513a3 福哥口诀法:T源目序缺首保 紧确推和复同终 窗校紧选数(TCP格式:源端口,目的端口,序号,确认号,首部长度,保留,紧急位URG,确认位ACK,推送位PSH,复位位RST,同步位SYN,终止位FIN,窗口,校验和,紧急指针,选项,数据)

typedef struct _TCP_HEADER { short m_sSourPort;       // 源端口号16bit short m_sDestPort;        // 目的端口号16bit unsigned int m_uiSequNum;   // 序列号32bit unsigned int m_uiAcknowledgeNum; // 确认号32bit short m_sHeaderLenAndFlag;   // 前4位:TCP头长度;中6位:保留;后6位:标志位 short m_sWindowSize;      // 窗口大小16bit short m_sCheckSum;       // 检验和16bit short m_surgentPointer;      // 紧急数据偏移量16bit }attribute((packed))TCP_HEADER, *PTCP_HEADER;