Communication and Networks Assignment
Communications and Networks
version 1.0
Diploma in Information Technology
Copyright © 2020 by Singapore Institute of Management Pte Ltd. All rights reserved.
Lesson 20: TCP and UDP Transport Service
1
Lesson 20 Learning Outcomes
Distinguish between UDP and TCP transport service
Identify the components in a UDP datagram
Explain how TCP handles congestions
Explain TCP three-way handshake
Identify the components in a TCP segment
2
Lesson 20 Outline
UDP Transport Service
TCP Transport Service
3
End-to-End Communication
IP cannot distinguish among multiple application programs running on a given host
Source and destination field identifies a host
Does not contain additional bits to identify an application
Treats a computer as endpoint of communication
Transport-layer protocols are end-to-end protocols
Allows an application to be an endpoint of communication
4
Transport Protocols
Two main transport protocols
User Datagram Protocol (UDP)
Transmission Control Protocol (TCP)
UDP is easy to understand
End-to-end: distinguish among multiple applications running on a given computer
Connectionless: does not requires connection to be establish before communicating
Message-oriented: sends and receives individual messages
5
UDP as Thin Protocol
UDP is less complex:
Best-effort Delivery: same best-effort delivery semantics as IP
Arbitrary Interaction: allows an application to send/receive to/from many other applications
Operating System Independent: provides means of identifying application programs that does not depend on identifiers used by the local OS
Thus, it is sometimes characterised as thin protocol
6
Message-Oriented
Each requests for UDP to send data places the data in a single message for transmission
Does not divide a message into multiple packets
Does not combine messages for delivery
On the positive side, applications preserve data boundaries as each message remains the same as transmitted
On the negative side, each UDP message must fit into a single IP datagram
7
Best-effort Delivery
Best-effort delivery means messages can be:
lost, duplicated and delivered out-of-order
Consequences for applications:
Must either be immune to the problems or take steps to detect and correct problems
8
UDP Application Limitations
Audio applications can tolerate packet errors
If sender places small amount of audio in each message, loss of a packet produces small gap
Gap will be heard as a pop or click
Online shopping application cannot use UDP
Packet errors can have serious consequences
Duplication of a message can result to duplicate orders or double charging
9
Endpoint Identification
UDP defines protocol port numbers that are independent of the OS
UDP provides mapping between protocol port numbers and program identifiers that OS uses
All computers running UDP recognise standard protocol port numbers, independent of the OS
10
UDP Datagram
Each UDP message is called a user datagram and consists of two parts:
Short header: specifies sending and receiving application
Payload: data being sent
Source: Douglas, C (2016) Computer Networks and Internets
11
Checksum & Encapsulation
UDP header contains 16-bit optional field named UDP checksum (like Internet checksum)
To verify headers
Each UDP datagram is encapsulated in an IP datagram for transmission across the Internet
Source: Douglas, C (2016) Computer Networks and Internets
12
Practice 20.1
What are the THREE (3) guarantees of message delivery of UDP that make it a best-effort protocol?
As a best-effort protocol, what are the applications that are suitable to use UDP and what are those that are unsuitable?
13
Lesson 20 Outline
UDP Transport Service
TCP Transport Service
Flow & Congestion Control
Three-way Handshake
TCP Segment Components
14
Transmission Control Protocol
A programmer assumes that data will arrive correctly, and OS guarantees that data will be delivered reliably
Transmission Control Protocol (TCP) provides reliable transport service
No lost, no duplication, on time and ordered delivery
15
TCP Characteristics
Connection Orientation: an application must first request a connection to a destination
Point-to-Point: each TCP connection has exactly two endpoints
End-to-End: distinguish among multiple applications running on a given computer
Complete Reliability: guarantees that the data sent across a connection will be delivered completely and in order
Full duplex: allows data to flow in either direction
16
TCP Services
Stream Interface: an application sends a continuous sequence of octets
Does not group data into records or messages
Reliable Connection Startup: allows two applications to reliably start communication
Graceful Connection Shutdown: ensures that both sides have agreed to shut down the connection
17
Virtual Connections
Connections in TCP are virtual connections as they are achieved in software
Two machine exchange messages to achieve the illusion of a connection
Uses IP to carry messages which each TCP message is treated as data
TCP software is needed at each end of a virtual connection but not on intermediate routers
18
TCP Illustration
Source: Douglas, C (2016) Computer Networks and Internets
19
Problems to Consider
Ensuring reliability: reliable transport service
End System Reboot: either of the two end systems might crash and reboot
Heterogeneous End Systems: a fast sender can overrun a slow receiver
Congestion in the Internet: intermediate switches and routers can become overrun by traffic
20
Handling Order & Duplicates
To handle duplicates and order, sender attach a sequence number to each packet
Receiver examines the sequence number to determine how the packet should be handled
Either use it to arrange packets in order
Or if the packet has already been delivered, discards the duplicated copy
21
Retransmission for Lost Packets
To handle packet loss, transport protocols use positive acknowledgement (ACK)
Receiver sends ACK message that reports successful reception
Sender starts a timer whenever it sends a packet
If ACK arrives before timer expires, cancels the timer
If timer expires before ACK, sender retransmit and starts timer again
22
Retransmission Illustration
Source: Douglas, C (2016) Computer Networks and Internets
23
Stop-and-go Flow Control
Flow control techniques are employed to handle a fast computer from sending so much data to overrun a slower receiver
Simplest flow control is stop-and-go
Sender waits after transmitting each packet
When receiver is ready, it sends a control message (usually ACK)
But result in extremely low throughput
24
Sliding Window Flow Control
Sliding window is another flow control technique
Window size: maximum amount of data that can be sent before an acknowledgement arrives
Source: Douglas, C (2016) Computer Networks and Internets
25
Flow Control Comparison
Source: Douglas, C (2016) Computer Networks and Internets
Stop-and-go
Sliding Window
26
Congestion
Congestion occurs when a network is unable to allow further packets from flowing through
Resulting in delay
Can cause intermediate network device to run out of memory and begin discarding packets
Retransmission for lost packets will sends more packets into the network
Network can become unusable which can result to congestion collapse
27
Congestion Control
To control congestion:
Network device sends a special message to the source of packets when congestion occurs
Receiver use increased delay or packet loss as estimate of congestion and inform sender
Congestions is mostly result of packet burst
Sudden increased in transmission or retransmission
28
Adaptive Retransmission
Rather than a fixed retransmission timeout, TCP monitors current delay on each connection
Adaptive retransmission: modify retransmission timeout according to network conditions
TCP estimates round-trip delay for each active connection by measuring time it receive a response
If delay is constant, adjusts timeout slightly longer than average round-trip delay
If delay varies, adjusts to a value greater/lower than average to accommodate peaks
29
Adaptive Retransmission Illustration
Source: Douglas, C (2016) Computer Networks and Internets
Congested Network
Less Congested Network
30
Lesson 20 Outline
UDP Transport Service
TCP Transport Service
Flow & Congestion Control
Three-way Handshake
TCP Segment Components
31
TCP 3-way Handshake
Source: https://www.youtube.com/watch?v=n-2YRCMX6Kc
32
Three-Way Handshake
To establish or terminate connections, TCP uses a technique call 3-way handshake
Handshake ensures that TCP will not open or close a connection until both ends have agreed
During the 3-way handshake to start a connection, each side sends a message that specifies
Initial buffer size for flow control and sequence number
33
Handshake Messages
Synchronization (SYN) segment: control message used in a 3-way handshake to create a connection
Finish (FIN) segment: control messages used in a 3-way handshake to close a connection
TCP also requires each end to generate a random 32-bit sequence number that becomes the initial sequence
34
Connection Establishment
Source: Douglas, C (2016) Computer Networks and Internets
35
Reconnection & Termination
If application re-establish a new TCP connection after a computer reboots, TCP will choose a new random number
Probability of selecting a random value that matches the value used previously is low
To close a connection, TCP uses FIN segments
An ACK is sent in each direction along with a FIN to guarantee all data has arrived before the connection is terminated
36
Connection Termination
Source: Douglas, C (2016) Computer Networks and Internets
37
Lesson 20 Outline
UDP Transport Service
TCP Transport Service
Flow & Congestion Control
Three-way Handshake
TCP Segment Components
38
TCP Segment Format
TCP uses a single format for all messages including data messages, ACKs, SYN and FIN
TCP uses the term segment to refer to a message
TCP connection contains two streams of data, one in each direction
Some fields in the segment refer to the data stream traveling in the forward direction
While others refer to data stream traveling in the reverse direction
39
TCP Segment Format Breakdown
Source: Douglas, C (2016) Computer Networks and Internets
40
TCP Segment Fields (1/2)
ACKNOWLEDGEMENT NUMBER: sequence number of the data that is expected next
WINDOW: how much additional buffer space is available beyond ACKed data
SEQUENCE NUMBER: sequence number of the first byte of data being carried in the segment
Receiver uses this to compute an acknowledgement number
41
TCP Segment Fields (2/2)
DESTINATION PORT: identifies which application program on the receiving computer should receive the data
SOURCE PORT: identifies the application program that sent the data
CHECKSUM: checksum that covers the TCP segment header and the data
42
Practice 20.2
How does TCP deals with flow control?
43
Reading
Douglas, C. (2016). Computer Networks and Internets, Global Edition (6th ed.). Pearson Education. ISBN: 978-1292061177 Chapter 25, 26
44
End of Lesson
45