Professional Documents
Culture Documents
COMP 416 Internet Protocols and Software: Instructor: Zhijun Wang
COMP 416 Internet Protocols and Software: Instructor: Zhijun Wang
User Datagram
Protocol
Objectives
UDP uses port number to identify processes. A port number has 16 bits, the
range is from 0 to 65,535.
The client process defines itself with a port number, called ephemeral port
number which is recommended to be greater than 1023.
The server process also defines itself with a port number which is a
well-known port number in the range 0-1023.
UDP packets are called user datagrams and have a fixed-size header of 8
bytes.
There are one outgoing and one incoming queues used for sending
and receiving datagrams.
The queues usually are identified by the port numbers.
RFC4340: http://www.read.cs.ucla.edu/dccp/rfc4340.txt
Transmission
Control Protocol
Objectives
The bytes of data being transferred in each connection are numbered by TCP.
The number starts with a randomly generated number.
The value in the sequence number field of a segment defines the number of the
first data byte contained in that segment.
The value of the acknowledgement field in a segment defines the number of the
next byte a party expects to receive.
The acknowledgement is cumulative.
Solution
The following shows the sequence number for each segment:
(1) The client first sends a SYN segment, in which only SYN flag is set.
A SYN segment cannot carry data, but it consumes one sequence number.
The sequence number is called the initial sequence number (ISN).
(2) After the server receives the SYN segment, it sends a SYN+ACK segment back
The segment has 2 flag bits set: SYN and ACK, and also contains receiver window
size which indicates the maximal number of bytes can be sent.
A SYN+ACK segment cannot carry data, but does consume one sequence number.
(3) After receiving SYN+ACK, the client sends an ACK segment to the server.
The ACK segment, if carrying no data, consume no sequence number.
The connection establishment procedure in TCP has SYN flooding attack problem.
A malicious attacker sends a large number of SYN segments to a server using faked
IP addresses. The server, assuming that the clients are issuing an active open,
allocates the necessary resources. During the time, a lot of resources are allocated
without being used. Then the server sends the faked clients SYN+ACK segments
which are lost. During this period, the server may run out of resource, and even
crash. Such attacks known as denial of service attack.
After connections
is established,
bidirectional data
transfer can take
place. The
acknowledgement
is piggyback with
data.
(1) The client first sends a FIN segment, in which the FIN flag is set.
The segment can include the last chunk of data sent by the client or it can be
just a control package.
The FIN segment consumes one sequence number if it does not carry data.
(2) After receiving the FIN segment, the server informs its process of the situation
and send a FIN+ACK segment to confirm the receipt of the FIN segment from the
client and also announce the closing of the connection in the other direction.
The FIN+ACK consumes one sequence number if it does not carry data.
(3) The client sends the last ACK segment to the server.
The ACK segment cannot carry data and consumes no sequence number.
Solution
The value of rwnd = 5,000 − 1,000 = 4,000. Host B can receive
only 4,000 bytes of data before overflowing its buffer. Host B
advertises this value in its next segment to A.
cwnd rwnd
Solution
The value of rwnd is less than cwnd, so the size of the window
is 12. Figure below shows the new window. Note that the
window has been opened from the right by 7 and closed from
the left by 4; the size of the window has increased.
Rule 1: When one end sends data segment to the other end, it must include
an acknowledgement giving the next sequence number it expects to receive.
Rule 2: If the receiver has no data to send, it receives an in-order segment and the
previous one has acknowledged, it delays sending ACK until another segment
arrives or until a period of time has passed. That means there should be no
more than 2 in-order unacknowledged segments in any-time.
Rule 3: When a segment arrives with a sequence number that is expected, and the
previous one is in –order and has not acknowledged, it immediately
sends an ACK.
Rule 4: When a segment arrives is out-of-order number, the receiver immediately
sends an ACK announcing the expected sequence number to be received.
Rule 5: When a missing segment arrives, the receiver sends an ACK to announce
the next sequence number expected.
Rule 6: If a duplicated segment arrives, the receiver immediately sends an ACK to
solve missing ACK case.
In TCP, the sender starts a retransmission time-out (RTO) for each segment sent.
A retransmission occurs if any of the cases is true:
Data may arrive out of order and be temporarily stored by the receiving TCP,
but TCP guarantees that no out-of-order segment is delivered to the process.
A protocol must be fair for every user and must be stable for the whole
system.
TCP provides fairness (e.g., max-min, proportional fairness).
However, TCP is not efficient, cannot provide QoS features.
Window size=
min (rwnd, cwnd)
TCP has a slow start phase. In this phase, the size of the congestion window
increases exponentially until it reaches a threshold.
After the cwnd reaches the threshold, the size of the congestion
window increases additively until the congestion is detected
Start cwnd=1
After 1 RTT cwnd=2
After 2 RTTs cwnd =3
….
TCP/IP Protocol Suite 52
Congestion detection
In today’s Internet, only way the sender can guess that congestion has occurred
is the need to retransmit a segment. There are two cases:
(1) The retransmission timer expires
(2) Three duplicated ACK segments have arrived
congestion detected
reduced to half
cwnd=1
cwnd=threshold=6
RTT: round trip time
5.
6.