- Đầu tiên ta cộng các từ 16 bit trong header: Code:
Khai báo 1 bảng TCP session, trong đó mỗi dòng là 1 struct tcpSession lưu thông tin về 1 kết nối:
Code:
//--- ---
struct tcpSession{
unsigned int desPort; //Port on the remote host unsigned int srcPort; //Port on the local host
unsigned long desIP; //IP ađress of the remote host unsigned long seqNumber; //Sequence number
unsigned long ackNumber; //Acknowlegement number
unsigned char sesState; //Current state of TCP session unsigned int srcWin;
unsigned int desWin;
unsigned long lastRxAck; //Last Received Ack unsigned char nextAck;
unsigned char timeOut; //Session time out
void(*appDataIn)(unsigned char* dataBuffer,unsigned int dataLen,struct tcpSession *pSession);
unsigned char appID; //Upper layer application ID unsigned char appState; //Upper layer application state };
Bây giờ chuyển sang “tcp.c”:
Khai báo 1 bảng TCP session, trong đó mỗi dòng là 1 struct tcpSession lưu thông tin về 1 kết nối: nối:
Code:
//--- ---
struct tcpSession tcpSessionTable[TCP_MAX_SESSION];