Responsible for process-to-process/end-to-end/port-to-port delivery of the entire message
Functionality
Port addressing => The network layer gets each packet to the correct computer, the transport layer gets the entire message to the correct process on that computer
Segmentation and Reassembly => A message is divided into transmittable segments, each having a sequence number
Connection Control => The transport layer can be either connection-less or connection-oriented
Flow Control
Control the Flow at Destination
Error Control (Checksum)
Socket Address
Both IP & Port address is used for Connection
Headers
The unit is divided into K sections, each of n bits
Section 1 and 2 are added together using one’s complement
Section 3 is added to the result of the previous step
Section 4 is added to the result of the previous step
The process repeats until section k is added to the result of the previous step
The final result is complemented to make the checksum
Protocols
TCP (Transmission Control Protocol)
Byte Streaming
TCP creates segments (Segmentation) of bytes from the continuous stream of data (in bits) received from the application layer
Segment is a collection of bytes
Connection Oriented
Reliability => Makes sure that the number of data sent is equal to data received => No loss of data
Makes connection before sending the message
Uses 3-way handshaking => Makes request, Gets response, Sends data
In-order => Message are sent and received in order
Full Duplex
Both can transmit data at the same time
Piggybacking
Uses Go-back-N and selective repeat for sliding window
Error Control
Checksum
Flow Control
Controls the flow of data
Congestion Control
Uses AIMD algorithm to avoid congestion
Cases of Congestion detection
Timeout occur (Severe)
Restart from stage 1 with initial value
3 ACK received (Light)
Restart from stage 2 with Threshold value
Stages
Slow start > Exponential growth => Increase in the power of 2 till reached Threshold
Threshold = Window Size during Congestion/2
Linear (Congestion avoidance) => Increase linearly till reached Maximum window size
Constant
Multiplexing/De-multiplexing
While sending does many-to-one, and while receiving does one-to-many of multiple data form channel to sender/receiver
Header
Source/Destination port
Port of the application of sender/receiver
Possible ports = 0 to 65535
Well known port numbers = 0 to 1023
Sequence number
Number given to each byte in the segment
Generally TCP uses random sequence number => Starts from a random number
Acknowledgement number
Next expected byte number
If the senders byte number is "x" then receiver sends the Acknowledgement "x+1"
Header Length (HLEN)
Maximum bit can be (1111) = 15 => 15 x 4 = 60
Minimum can be (0101) = 5
We multiply by 4 => Minimum should be 20
Flags
URG (Urgent) => If data is urgent then bit value is 1
ACK (Acknowledgement) => If data is acknowledgement then bit value is 1
PSH (Push) => Buffer (Storing data before sending) is not created
RST (Reset) => Resetting the connection
SYN (Synchronization) => First byte when making connection
FIN (Finish) => Last byte, Connection terminated
Window Size
Receiving window => Maximum size (Total capacity) of data that can be received
Checksum
Urgent pointer
Range of data (Bytes) that is urgent in the segment
Options & Padding
Extra data
Maximum segment size (MSS) => Size of 1 segment
Connection Establishment
SYN => Active open (Client) > Sends header to server > Passive open (Server)
SYN + ACK => Sends header to client > Active open (Server)
ACK => Send header to server, No sequence number consumed
Data transfer
Clients sends data to server with acknowledgement and sequence number
Server sends back data to client with acknowledgement and sequence number
Piggybacking => Sending acknowledgement and data together
Pure acknowledgement
Connection Termination
Client sends FIN packet, with ot without data
Half close => Server releases reserved resources, Client cans still send acknowledgement but not data
Server sends acknowledgement and FIN > Client releases reserved resources
Client sends acknowledgement to server, No sequence number consumed
UDP (User Datagram Protocol)
Connection less protocol => Unreliable
Less overhead => Less header => Fast transmission
Stateless
No flow control and Congestion control
Header
Source & Destination port
Length
Header (8 byte) + Payload
Checksum
UDP Header + UDP Data + Pseudo header of IP
Optional field in IPv4 => Error control is optional
Application
Query response protocol => DNS, DHCP
Speed => Online gaming, Voice over IP
Broadcasting/Multicast => Routing information protocol