github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/tcp/doc.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 /* 4 5 +---------+ ---------\ active OPEN 6 | CLOSED | \ ----------- 7 +---------+<---------\ \ create TCB 8 | ^ \ \ snd SYN 9 passive OPEN | | CLOSE \ \ 10 ------------ | | ---------- \ \ 11 create TCB | | delete TCB \ \ 12 V | \ \ 13 +---------+ CLOSE | \ 14 | LISTEN | ---------- | | 15 +---------+ delete TCB | | 16 rcv SYN | | SEND | | 17 ----------- | | ------- | V 18 +---------+ snd SYN,ACK / \ snd SYN +---------+ 19 | |<----------------- ------------------>| | 20 | SYN | rcv SYN | SYN | 21 | RCVD |<-----------------------------------------------| SENT | 22 | | snd ACK | | 23 | |------------------ -------------------| | 24 +---------+ rcv ACK of SYN \ / rcv SYN,ACK +---------+ 25 | -------------- | | ----------- 26 | x | | snd ACK 27 | V V 28 | CLOSE +---------+ 29 | ------- | ESTAB | 30 | snd FIN +---------+ 31 | CLOSE | | rcv FIN 32 V ------- | | ------- 33 +---------+ snd FIN / \ snd ACK +---------+ 34 | FIN |<----------------- ------------------>| CLOSE | 35 | WAIT-1 |------------------ | WAIT | 36 +---------+ rcv FIN \ +---------+ 37 | rcv ACK of FIN ------- | CLOSE | 38 | -------------- snd ACK | ------- | 39 V x V snd FIN V 40 +---------+ +---------+ +---------+ 41 |FINWAIT-2| | CLOSING | | LAST-ACK| 42 +---------+ +---------+ +---------+ 43 | rcv ACK of FIN | rcv ACK of FIN | 44 | rcv FIN -------------- | Timeout=2MSL -------------- | 45 | ------- x V ------------ x V 46 \ snd ACK +---------+delete TCB +---------+ 47 ------------------------>|TIME WAIT|------------------>| CLOSED | 48 +---------+ +---------+ 49 50 Rx means Receive, and Tx means Transmit 51 1 2 3 4 52 ----------|----------|----------|---------- 53 SND.UNA SND.NXT SND.UNA 54 +SND.WND 55 1 - old sequence numbers which have been acknowledged 56 2 - sequence numbers of unacknowledged data 57 3 - sequence numbers allowed for new data transmission 58 4 - future sequence numbers which are not yet allowed 59 60 Rx means Receive, and Tx means Transmit 61 1 2 3 62 ----------|----------|---------- 63 RCV.NXT RCV.NXT 64 +RCV.WND 65 1 - old sequence numbers which have been acknowledged 66 2 - sequence numbers allowed for new reception 67 3 - future sequence numbers which are not yet allowed 68 69 Prefer SetTimeout over SetDeadline : 70 71 TODO::: concurrency safe?? 72 */ 73 package tcp