Go-Back-N
- This is a "windowing" technique.
- All math on sequence numbers is done modulo n, where n is the maximum sequence number.
- This allows us to wrap around the sequence numbers and start again.
- So with a three bit sequence number 7 is followed by 0
- This is the same problem you have implementing a queue in an array
- A window is defined.
- This indicates the number of transmitted packets which can be unacknowledged.
- If the last acknowledged packet was 1 (referred to as the base), and the window is 4, packets with sequence numbers 2,3,4,5 can be unacknowledged and sent, but packet 6 must not be sent.
- The window must be smaller than the total size of the sequence.
- An ACK
- Has an associated sequence number.
- An ACK acknowledges all packets with that sequence number or lower.
- Thus an ACK per packet is not required.
- So from the above example:
- An ACK with a sequence number of 4 will ACK packets 2,3,4
- Thus the sender can now transmit packets 6, 7 and 0
- This is know as a sliding window protocol since the window slides along the packets in flight.
- The FSM for send is much more simple (sort of)
-
- The FSM for receive is more simple too (sort of)
-
- Notice, each packet is ACKed, but the sender can handle lost ACKs.
- Also notice, out of order packets are dropped. (the default case) and ACKed with the last good packet.
- This causes the sender to resend all intermediate packets after that ACK.
- Note the decision to not hold packets that arrive out of order.
- This will simplify the receiver.
- Much less requirement for buffer management.
Selective Repeat
- Go Back N will suffer when select packets are dropped.
- If we save out of order packets we can avoid this.
- But we will have to ACK every packet.
- Furthermore, for the sender, each outstanding packet needs an individual timer
- A window is used to place a limit on buffer sizes.
- Sender
- Send a packet and set the timer for that packet.
- When data arrives from above, (perhaps) buffer it if the window is full.
- When an ack is received
- If it is the base, slide the window
- This may move more data into the ready to send area
- The receiver
- If a good packet in the window is received
- ACK it (if we use it or not)
- If it was not previously received.
- store it
- Now send this and any other sequentially ordered packets after it to the application.
- Kurose notes that there is still a possibility of lost packets causing problems.
- The maximum assumed lifetime of a packet is 3 minutes (for TCP)
- Sequence numbers need to be high enough to handle this.
Credit Scheme
- Stallings discusses an additional scheme which seems well suited to TCP
- TCP views the entire transaction as a data stream.
- Individual packets are not numbered sequentially
but by their byte numbers.
- There is a Minimum Segment Size (MSS)
- This is the maximum size of the data portion of the TCP segment
- Either constant: 1460, 536 or 512
- Or based on MTU for underlying networks.
- The sequence number is the first byte of the message
- Assume a MSS of 500.
- The first segment will have sequence number 0
- The next will be 500 , ...
- Kurose has an example for telnet
- TCP is a full duplex service, or there is a pipe both directions.
- ACKs are piggybacked with data.
- Each character typed on the client is sent in a packet to the server.
- Each character received by the server is echoed back to the client.
- Each echo from the client is ACKed
- An Ethereal demo might be in order here.
- TCP has a 32 bit sequence number field.
- And a 32 bit ACK number.
- In this case an ACK is for a set of bytes, not a packet.
- The client can send back a window size, in bytes.
- This window size says how many bytes of buffer space the receiver has available.
- Or, with a slow network, can predict how many will be available in the future.
- This, by the way, is also flow control
- Note, that window size is one of the TCP fields. (16 bits)
- Note also that TCP is a mixture of Go-Back-N and Selective Repeat