The TCP/IP Protocol Suite: TCP
Derek Bridge
Department of Computer Science,
University College Cork
The TCP/IP Protocol Suite: TCP
Aims:
- to know what a protocol is
- to know what packet switching is
- to know how TCP achieves reliable data transmission
Protocols
- A communication protocol is an agreement that specifies how two
computers will exchange messages
- It will specify:
- the exact format of the messages
- the meaning of the messages, and
- the conditions under which a message should be sent
- Programmers must ensure that the software that runs on the
devices that are connected to the network follow the rules of the protocol:
so that they send the right messages at the right time in
the right format
The TCP/IP Protocol Suite
The Internet uses several dozen protocols, referred to collectively
as the TCP/IP Protocol Suite or just TCP/IP in honour
of the two key protocols:
- The Tranmission Control Protocol (TCP)
- This protocol is about reliable data transmission
- The Internet Protocol (IP)
- This protocol is about routing
The Layers of the TCP/IP Protocol Suite
Diagram of TCP/IP Protocols from The TCP/IP Guide by Charles M. Kozierok
Circuit-Switching versus Packet-Switching
- The telephone network is a circuit-switched network
- When you make a call, a circuit is dedicated to you for the whole duration
- But,
- your use of this circuit excludes others, and
- the failure of any portion terminates communication
Circuit-Switching versus Packet-Switching
- The Internet is a packet-switched network
- When two devices communicate, no specific path is allocated to them
- The data is chopped up into packets
- Each packet is sent separately by the best available route
- Since the packets may not take the same path,
- some may get lost, or
- they may arrive out of order
- But, the weaknesses of circuit-switching are overcome
The Transmission Control Protocol (TCP)
- TCP specifies how to establish and terminate a 'connection'
(using
hand-shaking
messages)
- It also specifies how to take a stream of data and divide it
into packets, called TCP segments
- The segments are transmitted separately, and TCP specifies how to achieve
a level of reliability:
- how to cope if segments arrive out of order (or if duplicates arrive)
- how to cope if segments get lost (including load management), and
- how to cope if segments get corrupted
TCP segments
Each TCP segment will consist of two parts:
- a header, which includes:
- the destination port number
- a sequence number
- a checksum
- the data (or payload)
Class exercise: How does this help the recipient cope when
segments arrive out of order? What about duplicate segments?
Why segments might get lost
- A connection or a device such as a router may fail
- A router may become overrun
- For another reason, see the lecture on IP
TCP's sliding window acknowledgment system
- When a segment reaches its ultimate destination, the recipient device
sends an acknowledgment
- If the sender does not receive an acknowledgment, it retransmits the
segment
Class exercise:Why is this not sufficient? (Two reasons)
TCP's sliding window acknowledgment system
- When the sender sends a segment, it starts a timer
- If an acknowledgment is received before the timer expires, all is OK
- If no acknowledgment is received before the timer expires, a segment
may have been lost, in which case it is retransmitted (with a new timer)
Class exercise: We've seen how to handle duplicates. But
why might they occur? (Two reasons)
TCP's sliding window acknowledgement system
- The acknowledgment messages will contain the segment's sequence number.
Why?
- But they may also contain information about how busy the recipient is.
Why?
Why segments might get corrupted
E.g.
- Lightning can cause random electrical signals to
appear on wires
- Electrical signals on wires can become distorted when the wire
passes through a strong magnetic field
TCP's checksums
- Sender:
- Compute a sum based on the data you wish to send
- Include this sum in the header
- Recipient:
- Compute the same sum based on the data you have received
- Compare it with the checksum you have received (in the header)
- If they are the same, all is well. (Really?)
- If they are different, the data has been corrupted.
Class exercise:So then what will the recipient do?
Checksums
Suppose all seems well: your checksum is correct.
Class exercise: Give examples of ways the data could be corrupted
without affecting the checksum
The User Datagram Protocol (UDP)
- TCP's reliability comes at a cost in time and bandwidth
- UDP is an alternative used for applications that cannot afford or do not
need TCP's reliability
- In UDP, there are no connections, there are no acknowledgments, and checksums
are optional
TCP versus UDP
Class exercise: TCP or UDP?
- Sending an email
- Your browser requests a web page
- The web server sends back the web page
- Downloading a music file to playback later
- Streaming a radio show to listen to now