datacommchapter 6 part 2
TRANSCRIPT
-
8/14/2019 DataCommChapter 6 Part 2
1/57
1
Part 2
6.4 User6.4 UserDatagramDatagramProtocol (UDP)Protocol (UDP)
6.5 Transmission Control Protocol (TCP)6.5 Transmission Control Protocol (TCP)
-
8/14/2019 DataCommChapter 6 Part 2
2/57
2
The Internet model has three protocols at theThe Internet model has three protocols at the
transport layer: UDP, TCP & SCTPtransport layer: UDP, TCP & SCTP
The UDP is the simplest of the three.The UDP is the simplest of the three.
The TCP is a complex transport layer protocol.The TCP is a complex transport layer protocol.
The SCTP is the new transport layer protocolThe SCTP is the new transport layer protocol
that is designed for that is designed formultihomedmultihomed,, multistreammultistreamapplications such as multimedia.applications such as multimedia.
-
8/14/2019 DataCommChapter 6 Part 2
3/57
3
Position of UDP, TCP, and SCTP in TCP/IP suite
-
8/14/2019 DataCommChapter 6 Part 2
4/57
4
6.4: USER DATAGRAM PROTOCOL (UDP)6.4: USER DATAGRAM PROTOCOL (UDP)
The User Datagram Protocol (UDP) is called aThe User Datagram Protocol (UDP) is called a connectionless, unreliable transport protocol. It connectionless, unreliable transport protocol. It
does not add anything to the services of IP does not add anything to the services of IP
except to provide processexcept to provide process--toto--processprocess communication instead of host communication instead of host--toto--hosthost
communication.communication.
-
8/14/2019 DataCommChapter 6 Part 2
5/57
5
UDP is a simpler protocol compared to TCP.
It has no connection, flow control, congestion control, sequencing,
packet acknowledgement and reliability. There is no control mechanism for detecting lost packets, out-of-order
packets and duplicate packets.
It only provides error control for detecting corrupted packets using
checksum. Processes which involved sending small message or do not care about
reliability can use UDP.
It is used by application protocols such as TFTP, SNMP, RTP and etc.
UDP is also a suitable transport protocol for multicasting of real timemultimedia.
In transport layer of TCP/IP model.
-
8/14/2019 DataCommChapter 6 Part 2
6/57
6
Well-known ports used with UDP
Some ports number can be used by both UDP and TCP.
-
8/14/2019 DataCommChapter 6 Part 2
7/57
7
User datagram format
Source port number: the port number used by the process running on the source host.
Destination port number: the port number used by the process running on the
destinationCheck sum: detects errors over the entire user datagram, (header+data)
Length: defines the total length of the user datagram, (header+data)
-
8/14/2019 DataCommChapter 6 Part 2
8/57
8
UDP length
= IP length IP headers length
Note
-
8/14/2019 DataCommChapter 6 Part 2
9/57
9
Pseudoheader for checksum calculation
The pseudoheader is a part of the header of the IP packet in which the user datagram
is to be encapsulated with some fields filled with 0s.
-
8/14/2019 DataCommChapter 6 Part 2
10/57
10
The next figure shows the checksum calculation for a
very small user datagram with only 7 bytes of data.
Because the number of bytes of data is odd, padding is
added for checksum calculation. The pseudoheader as
well as the padding will be dropped when the user
datagram is delivered to IP.
Example 1
-
8/14/2019 DataCommChapter 6 Part 2
11/57
11
Checksum calculation of a simple UDP user datagram
-
8/14/2019 DataCommChapter 6 Part 2
12/57
12
6.5: TCP6.5: TCP
TCP is a connectionTCP is a connection--oriented protocol; it createsoriented protocol; it creates
a virtual connection between two a virtual connection between two TCPsTCPs to send to send
data. In addition, TCP uses flow and error data. In addition, TCP uses flow and error
control mechanisms at the transport level.control mechanisms at the transport level.
-
8/14/2019 DataCommChapter 6 Part 2
13/57
13
Well-known ports used by TCP
Like UDP, TCP provides process to process communication using port numbers.
-
8/14/2019 DataCommChapter 6 Part 2
14/57
14
Stream delivery
TCP creates an environment in which the two processes seem to be connected by
an imaginary tube that carries their data across the Internet.
The sending process produces (write to) the stream of bytes, and the receiving
Produces consumes (reads from) them.
-
8/14/2019 DataCommChapter 6 Part 2
15/57
15
Sending and receiving buffers
TCP needs buffers for storage because the sending and receiving may not write or
read data at the same speed.
-
8/14/2019 DataCommChapter 6 Part 2
16/57
16
TCP segments
The IP layer needs to send data in packets, not as stream of bytes.
At the transport layer- TCP groups a number of bytes together into a packet:segment,
adds a header to each segment (for control purposes) and delivers the segment to the
IP layer for transmission.
-
8/14/2019 DataCommChapter 6 Part 2
17/57
17
The bytes of data being transferred ineach connection are numbered by TCP.
The numbering starts with a randomly
generated number.
Note
-
8/14/2019 DataCommChapter 6 Part 2
18/57
18
Solution:
The following shows the sequence number for each segment:
Example 2
Suppose a TCP connection is transferring a file of 5000
bytes. The first byte is numbered 10,001. What are the
sequence numbers for each segment if data are sent infive segments, each carrying 1000 bytes?
-
8/14/2019 DataCommChapter 6 Part 2
19/57
19
The value in the sequence number field of asegment defines the number of the first data byte
contained in that segment.
Note
-
8/14/2019 DataCommChapter 6 Part 2
20/57
20
The value of the acknowledgment field in asegment defines the number of the next byte a
party expects to receive.
The acknowledgment number is cumulative.
Note
-
8/14/2019 DataCommChapter 6 Part 2
21/57
21
TCP segment format
-
8/14/2019 DataCommChapter 6 Part 2
22/57
22
Control field
These bits enable flow control, connection establishment and termination,
connection abortion, and the mode of data transfer in TCP.
-
8/14/2019 DataCommChapter 6 Part 2
23/57
23
Description of flags in the control field
-
8/14/2019 DataCommChapter 6 Part 2
24/57
24
TCP Connection
Connection oriented transmission requires three phases:connection
establishment, data transfer and connection termination.
Connection establishment requires three-way handshaking;
connection termination requires three- or four-wayhandshaking with a half-close option.
-
8/14/2019 DataCommChapter 6 Part 2
25/57
25
Connection establishment using three-way handshaking
Phase 1:Phase 1:
-
8/14/2019 DataCommChapter 6 Part 2
26/57
26
A SYN segment cannot carry data, but it
consumes one sequence number.
Note
-
8/14/2019 DataCommChapter 6 Part 2
27/57
27
A SYN + ACK segment cannotcarry data, but does consume one
sequence number.
Note
-
8/14/2019 DataCommChapter 6 Part 2
28/57
28
An ACK segment, if carrying no data, consumes
no sequence number.
Note
-
8/14/2019 DataCommChapter 6 Part 2
29/57
29
Data transfer
Phase 2:Phase 2:
-
8/14/2019 DataCommChapter 6 Part 2
30/57
30
Connection termination using three-way handshaking
Phase 3:Phase 3:
-
8/14/2019 DataCommChapter 6 Part 2
31/57
31
The FIN segment consumes one sequencenumber if it does not carry data.
Note
-
8/14/2019 DataCommChapter 6 Part 2
32/57
32
The FIN + ACK segment consumesone sequence number if it
does not carry data.
Note
-
8/14/2019 DataCommChapter 6 Part 2
33/57
33
Half-close
Half-close: One end can stop sending data while still receiving data
-
8/14/2019 DataCommChapter 6 Part 2
34/57
34
Flow Control
The size of the window at one end is determined by the lesser of two values:receiver window (rwnd) or congestion window (cwnd)
The sliding window is of TCP is of variable size and a byte-oriented.
-
8/14/2019 DataCommChapter 6 Part 2
35/57
35
A sliding window is used to make transmissionmore efficient as well as to control the flow of data
so that the destination does not becomeoverwhelmed with data.
TCP sliding windows are byte-oriented.
Note
-
8/14/2019 DataCommChapter 6 Part 2
36/57
36
What is the value of the receiver window (rwnd) for host A if
the receiver, host B, has a buffer size of 5000 bytes and 1000
bytes of received and unprocessed data?
Example 3
Solution
The value of rwnd = 5000 1000 = 4000. Host B can receive only 4000 bytes of data before
overflowing its buffer. Host B advertises this value
in its next segment to A.
-
8/14/2019 DataCommChapter 6 Part 2
37/57
37
What is the size of the window for host A if the value of rwnd
is 3000 bytes and the value of cwnd is 3500 bytes?
Example 4
Solution
The size of the window is the smaller of rwnd andcwnd, which is 3000 bytes.
-
8/14/2019 DataCommChapter 6 Part 2
38/57
38
The next figure shows an unrealistic example of a
sliding window. The sender has sent bytes up to 202.
We assume that cwnd is 20 (in reality this value is thousands of bytes). The receiver has sent an
acknowledgment number of 200 with an rwnd of 9
bytes (in reality this value is thousands of bytes). The
size of the sender window is the minimum of rwnd and
cwnd, or 9 bytes. Bytes 200 to 202 are sent, but not
acknowledged. Bytes 203 to 208 can be sent without
worrying about acknowledgment. Bytes 209 and abovecannot be sent.
Example 5
-
8/14/2019 DataCommChapter 6 Part 2
39/57
39
-
8/14/2019 DataCommChapter 6 Part 2
40/57
40
Some points about TCP sliding windows:The size of the window is the lesser of rwnd and cwnd.
The source does not have to send a full window sworth ofdata.
The window can be opened or closed by the receiver, butshould not be shrunk.
The destination can send an acknowledgment at any time aslong as it does not result in a shrinking window.
The receiver can temporarily shut down the window; thesender, however, can always send a segment of 1 byte afterthe window is shut down.
Note
-
8/14/2019 DataCommChapter 6 Part 2
41/57
41
ACK segments do not consume sequence
numbers and are not acknowledged.
Note
-
8/14/2019 DataCommChapter 6 Part 2
42/57
42
In modern implementations, a retransmissionoccurs if the retransmission timer expires or three
duplicate ACK segments have arrived.
Note
-
8/14/2019 DataCommChapter 6 Part 2
43/57
43
No retransmission timer is set for an ACKsegment.
Note
-
8/14/2019 DataCommChapter 6 Part 2
44/57
44
Data may arrive out of order and be temporarilystored by the receiving TCP,
but TCP guarantees that no out-of-order segmentis delivered to the process.
Note
-
8/14/2019 DataCommChapter 6 Part 2
45/57
45
Error Control
Error control is handled by the checksum,
acknowledgement, and time-out.
Corrupted and lost segments are retransmitted, and
duplicate segments are discarded.
Data may arrive out of order and are temporarily stored by
the receiving TCP, but TCP guarantees that no out-of-
order segment is delivered to the process.
N l i
-
8/14/2019 DataCommChapter 6 Part 2
46/57
46
Normal operation
-
8/14/2019 DataCommChapter 6 Part 2
47/57
47
Lost segment
-
8/14/2019 DataCommChapter 6 Part 2
48/57
48
The receiver TCP delivers only ordered data to theprocess.
Note
-
8/14/2019 DataCommChapter 6 Part 2
49/57
49
Fast retransmission
-
8/14/2019 DataCommChapter 6 Part 2
50/57
50
Congestion control refers to techniques and mechanisms
that can either prevent congestion, before it happens, orremove congestion, after it has happened.
Congestion Control
-
8/14/2019 DataCommChapter 6 Part 2
51/57
51
Slow start, exponential increase
-
8/14/2019 DataCommChapter 6 Part 2
52/57
52
In the slow-start algorithm, the size of thecongestion window increases exponentially until
it reaches a threshold.
Note
-
8/14/2019 DataCommChapter 6 Part 2
53/57
53
Congestion avoidance, additive increase
-
8/14/2019 DataCommChapter 6 Part 2
54/57
54
In the congestion avoidance algorithm, the size ofthe congestion window increases additively until
congestion is detected.
Note
-
8/14/2019 DataCommChapter 6 Part 2
55/57
55
An implementation reacts to congestion
detection in one of the following ways:If detection is by time-out, a new slow start
phase starts.If detection is by three ACKs, a new
congestion avoidance phase starts.
Note
-
8/14/2019 DataCommChapter 6 Part 2
56/57
56
TCP congestion policy summary
TCP vs UDP
-
8/14/2019 DataCommChapter 6 Part 2
57/57
57
TCP vs. UDP
TCP provides a reliable connection-oriented service,
whereas UDP provides an unreliable connectionless
service by delivering the UDP datagrams on a best-effort basis.
UDP is simpler than TCP. There is no connection, flow
control, congestion control, sequencing, packet
acknowledgement, and reliability required by UDP
transmission.