---
tags: Intro. to Computer Networks
---
{%hackmd BkVfcTxlQ %}
# Intro. to Computer Networks Final Note
## Transport Layer
#### Go-Back-N
Sender maintains a windows of size $N$ containing packets sent but not yet ACKed.
Receiver only ACKs the last in-order packet.
When receiving ACK~n~, sender slides the left of his window to n+1.
#### Selective Repeat
Receiver ACKs all packets, maintains out-of-order ones in buffer and slides his window if in-order.
Sender adds timout for each packet to resend and slides the window when receiving base ACK in the window (the earlist packet not yet ACKed).
:::warning
\\[SW\leq\frac{Seq}{2}\\]
:::
### TCP
Seq.
: First byte in the segement
ACK
: Next expected Seq.
: Cumulative

#### Fast Retransmit
If sender receives triple duplicate ACK, then it should resend the smallest unACKed segment, which is likely to be lost.
#### Flow Control
If network layer delivers data faster the application layer consumes, then TCP transport layer buffer may overflow.
To avoid this scene, TCP receiver could ask sender contorl the flow.
#### Connection
3-way handshake
: :arrow_right: SYN
: :arrow_left: SYNACK
: :arrow_right: ACK
4-way termination
: :arrow_right: FIN
: :arrow_left: ACK
: :arrow_left: FIN
: :arrow_right: ACK
#### Congestion Control
Sender adjusts congestion windows size `cwnd` to limit TX rate. Congestions are inferred by _retransmission timout_ RTO and triple duplicate ACKs.
##### Tahoe
Slow Start
: Initially `cwnd`=1 (MSS)
: Double `cwnd` until:
- RTO: go back to inital _**Slow Start**_ (`cwnd`=1)
- `cwnd` reaches _slow start threshold_ `ssthres`: enter _**Congestion Avoidance**_
Congestion Avoidance
: Linearly increase `cwnd` until loss detected, then go back to inital _**Slow Start**_
##### Reno
On triple duplicate ACK, `cwnd`=`cwnd`/2+3, `ssthresh`=`ssthresh`/2.
Additive Increase, Multiplicative Decrease.
##### Cubic
Replace AIMD by cube curve.
## Network Layer
- Longest prefix matching
- Switching rate
-
## Link Layer
{%hackmd @nevikw39/signature %}