1 This is a light-weight, user-space implementation of RFC 793 (TCP), without any
2 reliance on an IP layer. It can be used to provide multiple in-order, reliable
3 streams on top of any datagram layer.
5 UTCP does not rely on a specific event system. Instead, the application feeds
6 it with incoming packets using utcp_recv(), and outgoing data for the streams
7 using utcp_send(). Most of the rest is handled by callbacks. The application
8 must however call utcp_timeout() regularly to have UTCP handle packet loss.
10 The application should run utcp_init() for every peer it wants to communicate
13 DIFFERENCES FROM RFC 793:
15 * No checksum. UTCP requires the application to handle packet integrity.
16 * 32-bit window size. Big window sizes are the default.
21 * Implement send buffer
23 * Handle retransmission
27 * Nagle (add PSH back to signal receiver that now we want an immediate ACK?)
29 * Congestion window scaling
41 SYN|FIN + request data ->
42 <- SYN|ACK|FIN + response data
45 Does this need special care or can we rely on higher level MACs?
50 - snd.una: the sequence number of the first byte we did not receive an ACK for
51 - snd.nxt: the sequence number of the first byte after the last one we ever sent
52 - snd.wnd: the number of bytes we have left in our (UTCP/application?) input buffer
54 - rcv.nxt: the sequence number of the first byte after the last one we passed up to the application
55 - rcv.wnd: the number of bytes the receives has left in its input buffer (may be more/less than our send buffer size)
57 - The only packets that do not have ACK set must either have SYN or RST set
58 - Only packets received with rcv.nxt <= hdr.seq <= rcv.nxt + rcv.wnd are valid, drop others.
59 - If it has ACK set, and it's higher than snd.una, update snd.una.
60 But don't update it past c->snd.next. (RST in that case?)
62 - SYN and FIN each count as one byte for the sequence numbering, but no actual byte is transferred in the payload.
67 CLOSED: this connection is cloed, all packets received will result in RST.
69 LISTEN: (= no connection yet): only allow SYN packets, it application does not accept, return RST|ACK, else SYN|ACK.
71 SYN_SENT: we sent a SYN, now expecting SYN|ACK
73 SYN_RECEIVED: we received a SYN, sent back a SYN|ACK, now expecting an ACK
75 ESTABLISHED: SYN is acked, we can now send/receive normal data.
77 FIN_WAIT_1: we want to close the connection, and just sent a FIN, waiting for it to be ACKed.
81 CLOSE_WAIT: we received a FIN, we sent back an ACK
83 CLOSING: we had already sent a FIN, and we received a FIN back, now waiting for it to be ACKed.
85 LAST_ACK: we are waiting for the last ACK before we can CLOSE
87 TIME_WAIT: connection is in princple closed, but our last ACK might not have been received, so just wait a while to see if a FIN gets retransmitted so we can resend the ACK.
92 - Put the packet in the send buffer.
93 - Decide how much to send:
94 - Not more than receive window allows
95 - Not more that congestion window allows
96 - Segmentize and send the packets
97 - At the end, snd.nxt is advanced with the number of bytes sent
98 - Set the rtrx and conn timers if they have not been set
103 - Decide how much to send:
104 - Not more than we have in the send buffer
105 - Not more than receive window allows
106 - Not more that congestion window allows
107 - Segmentize and send packets
108 - No advancement of sequence numbers happen
109 - Reset the rtrx timers
114 - Drop invalid packets:
115 - Invalid flags or state
116 - hdr.seq not within our receive window
117 - hdr.ack ahead of snd.nxt
120 - reset conn timer if so
121 - remove ACKed data from send buffer
122 - If snd.una == snd.nxt, clear rtrx and conn timer
123 - Process state changes due to SYN
124 - Send new data to application
125 - Process state changes due to FIN