物联网LWIP网络开发 TCP/IP设计完结篇 12.5TCP报文处理

TCP报文处理

TCP缓冲队列

tcp_pcb_List

/* The TCP PCB lists. 
	在lwip内核里面,有一些关键的tcp控制块,需要内核用来调度使用,内核用链表结构进行管理
*/

/** 所有处于close状态的TCP,都在这一个链表进行管理 */
struct tcp_pcb *tcp_bound_pcbs;
/** 所有处于监听状态的TCP,都在这个链表进行管理 */
union tcp_listen_pcbs_t tcp_listen_pcbs;
/** 所有处于数据收发状态的TCP*/
struct tcp_pcb *tcp_active_pcbs;
/** 所有处于2MSL状态的TCP */
struct tcp_pcb *tcp_tw_pcbs;

tcp_seg

/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */
struct tcp_seg {
  struct tcp_seg *next;    /* TCP段缓冲队列的链表指针 */
  struct pbuf *p;          /* 实际的TCP数据段+首部内容 */
  u16_t len;               /* 在本段内TCP数据长度*/
  u8_t  flags;
  struct tcp_hdr *tcphdr;  /* TCP 首部指针 */
};

物联网LWIP网络开发 TCP/IP设计完结篇 12.5TCP报文处理_第1张图片

TCP报文处理机制

TCP 报文发送

/**
 * @ingroup tcp_raw
 * Find out what we can send and send it
 *
 * @param pcb Protocol control block for the TCP connection to send data
 * @return ERR_OK if data has been sent or nothing to send
 *         another err_t on error
 */
err_t
tcp_output(struct tcp_pcb *pcb)

TCP报文接收


/**
 * The initial input processing of TCP. It verifies the TCP header, demultiplexes
 * the segment between the PCBs and passes it on to tcp_process(), which implements
 * the TCP finite state machine. This function is called by the IP layer (in
 * ip_input()).
 *
 * @param p received TCP segment to process (p->payload pointing to the TCP header)
 * @param inp network interface on which this segment was received
 */
void
tcp_input(struct pbuf *p, struct netif *inp)

物联网LWIP网络开发 TCP/IP设计完结篇 12.5TCP报文处理_第2张图片

物联网LWIP网络开发 TCP/IP设计完结篇 12.5TCP报文处理_第3张图片

你可能感兴趣的:(lwIP网络,lwip,网络)