Fundamentals Of TCP And UDP
Fundamentals of TCP and UDP
|Connection-oriented/connectionless||Defines whether the protocol establishes correlation between 2 endpoints before data is sent.|
|Error recovery||The process of noticing errors or lost segments and resending the data.|
|Flow control||Controlling the speed of data transfer between two endpoints.|
|Segmenting||Application layer protocols may need to send large chunks of data. Segmenting is repackaging the data so that it can fit inside multiple packets.|
The Transmission Control Protocol (TCP)
TCP uses more bandwidth the UDP because it features error recovery, or more specifically, additional header fields.
- Multiplexing using multiple port numbers
- Error recovery (reliability)
- Flow control using windowing
- Connection establishment/termination (ACK and FIN)
- End-to-end ordered data transfer
TCP Header Fields
Multiplexing: Implies how a computer thinks when receiving data, enables the receiving computer the ability to know which app to give the data to.
- > Uses sockets --> 1. 10.1.1.1, TCP, 1030
1. IP addresses 2. Transport protocol 3. Port number
- Connection between 2 sockets should identify unique connection
- Well-known port numbers (HTTP, Telnet, etc). fpr Applications
- Unused port numbers for client machines
Error Recovery (Reliability): Use sequence number in 1 direction, acknowledgment in the other.
1000 Bytes of Data, SEQ = 1000 -------> 1000 Bytes of Data, SEQ = 2000 -------> Error Occurs Here 1000 Bytes of Data, SEQ = 3000 -------> No Data, ACK = 2000 <------- 1000 Bytes of Data, SEQ = 2000 ------->
Flow Control (Windowing): Uses window field; implies the max # of bytes allowed outstanding at any instant in time.
- Starts small and grows until error occurs.
- "Sliding Window" changes size accordingly
- Web server must wait for clients ACK before sending more than allowed
- If ACK received before Window exhausted, new window begins
- Positive Acknowledgement and Retransmission (PAR) describes the error recovery and windowing
Connection Establishment and Termination: Process of initializing sequence and acknowledgement fields and agreeing to the port numbers used.
- 3-way connection establishment
- SYN, or "synchronize" the sequence numbers
- ACK flag for acknowledgment
- Sequence # and ACK # can be any number that fits in 4-byte fields.
- 4-way connection termination
- Uses FIN flag
Connectionless and Connection-Oriented Protocols
Connection-oriented: A protocol that needs an exchange of messages before data transfer begins, or has a required pre-established correlation between 2 endpoints (like Frame Relay).
Connectionless: A protocol that doesn't need an exchange of messages or pre-established correlation.
|Yes||Yes||LLC Type 2, TCP, SPX|
|Yes||No||Frame Relay, ATM, PPP|
|No||Yes||TFTP, NetWare NCP|
|No||No||UDP, Most L3 protocols|
Data Segmentation and Ordered Data Transfer
Each type of data link protocol typically has a limit on maximum transmission unit (MTU) that can be sent - > the size of L3 packet that is inside Data-link frame
Segmenting = breaking data into smaller pieces
Ordered data transfer = is piecing segments on receiving end in the correct order since they may be sent out of order.
User Datagram Protocol (UDP)
- Much less overhead,
- No reordering of data/error recovery is possible, not reliable
- Multiplexes like TCP, can open same ports as TCP (although not typical).
- Not artificially slowed by ACK/Window, memory freed more quickly