Download 1. Foundation

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Parallel port wikipedia , lookup

CAN bus wikipedia , lookup

Lag wikipedia , lookup

SIP extensions for the IP Multimedia Subsystem wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Deep packet inspection wikipedia , lookup

Remote Desktop Services wikipedia , lookup

I²C wikipedia , lookup

IEEE 1355 wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

UniPro protocol stack wikipedia , lookup

Real-Time Messaging Protocol wikipedia , lookup

Internet protocol suite wikipedia , lookup

TCP congestion control wikipedia , lookup

Transcript
1
5. END-TO-END
PROTOCOLS (PART 1)
Rocky K. C. Chang
Department of Computing
The Hong Kong Polytechnic University
10 April 2017
2
1. The transport problem
• Problem: How to extend the host-to-host packet
delivery service to a process-to-process
communication channel?
• Best-effort service provided by IP:
• drops messages
• re-orders messages
• delivers duplicate copies of a given message
• limits messages to some finite size
• delivers messages after an arbitrarily long delay
3
1. The transport problem
• Expectations from transport layer services:
• guarantee message delivery
• deliver messages in the same order they are sent
• deliver at most one copy of each message
• support arbitrarily large messages
• support synchronization between the sender and receiver
• allow the receiver to apply flow control to the sender
• support multiple application processes on each host
4
2. Types of transport protocols
• Different transport protocols provide different sets of
services:
• User Datagram Protocol (UDP): Mainly provide a demultiplexing
service.
• Transmission Control Protocol (TCP): Provide a reliable byte-stream
service
• Remote Procedure Call (RPC): Provide services to transactionbased applications.
• Real Time Protocol (RTP): Provide services for transporting real-time
data over UDP.
5
3. UDP (RFC 768)
• UDP adds a demultiplexing service to IP.
• UDP optionally provides error detection but it becomes mandatory
for UDP over IPv6.
• UDP provides the demultiplexing service through UDP
ports.
• The idea is for a source process to send a message to a port and
for a destination process to receive the message from a port.
• Process IDs can also be used if all systems run on the same OS.
6
3. UDP (RFC 768)
• A process is uniquely identified by (Port number, IP address), which
is usually referred to as a socket.
• A port is usually implemented by a message queue.
• How does a process learn the port for the other party?
• For a server process, it will know the client’s port whenever the
client gets connected.
• For a client process, one approach to learn server’s port is through
the well-known port.
7
3.1 UDP message queues
Application
process
Application
process
Ports
Queues
Packets
demultiplexed
UDP
Packets arrive
Application
process
8
3.2 UDP packet
• UDP header format
0
16
31
SrcPort
DstPort
Checksum
Length
Data
• When a sender computes the optional checksum, a pseudo-
header is first prepended to the UDP header. Why?
9
4. TCP (RFC 793)
• TCP uses connection as its fundamental abstraction.
• A TCP connection is specified by a pair of sockets, each of which
identifies an endpoint, i.e. <SrcPort, SrcIPAddr, DstPort,
DstIPAddr>
• Unlike UDP, TCP requires both endpoints to agree to connect.
• TCP provides a connection-oriented, reliable, byte stream
service to the upper layer.
• Need to obtain an explicit agreement from the other side before
sending data.
10
4. TCP (RFC 793)
• The TCP sender provides a reliable service using a sliding window
mechanism, positive acknowledgment, and retransmission.
• TCP considers the data passed from applications as streams of
bytes.
• Each byte is therefore identified by a number.
• A TCP receiver does not understand the relationship among bytes.
• TCP supports full-duplex connections.
• TCP also provides congestion control and flow control services.
11
4. TCP (RFC 793)
Application process
Application process
…
…
Write
bytes
Read
bytes
TCP
TCP
Send buffer
Receive buffer
Segment
Segment … Segment
Transmit segments
12
4.1 End-to-end issues
• Sliding Window Protocol in TCP
• Potentially connects many different hosts
• need explicit connection establishment and termination
• Potentially different RTT
• need adaptive timeout mechanism
• Potentially long delay in network
• need to be prepared for arrival of very old packets
• Potentially different capacity at destination
• need to accommodate different amounts of buffering
• Potentially different network capacity
• need to be prepared for network congestion
13
4.2 TCP connection establishment
• TCP connection setup is asymmetric.
• The one initiates the connection does an active open.
• The other end does a passive open.
• It involves a total of three special TCP messages (SYN
segments): A three-way handshaking (1.5 round-trip time).
• Connection establishment timeout
• TCP client resends a SYN segment with exponential backoff up
to a certain time.
14
4.2 TCP connection establishment
• Information exchange during connection establishment:
• Initial Sequence Numbers (ISN), which are the first SNs used by
the two sides.
• The SYN segment also advertises window size (buffer available
for receiving data).
• Each side may optionally announce the Maximum Segment Size
(MSS) it expects to receive.
• If the destination IP address is local, set MSS to the local network’s
MTU  40 bytes.
• Otherwise, usually set MSS to 536 bytes.
15
4.3 An example
Client
Server
16
4.4 TCP connection termination
• TCP connection termination is symmetric: Each side
has to close the connection independently.
• At most four FIN segments are needed.
• By closing the connection, it means that no more data will be
sent, but can still receive data.
• A connection in the TIME_WAIT state cannot move to
the CLOSED state until it has waited for 2Maximum
Segment Lifetime (MSL).
• Reasons for this?
17
4.5 An example
Client
Server
close()
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_2
close()
LAST_ACK
TIME_WAIT
CLOSED
CLOSED
18
4.6 TCP state transition diagram
CLOSED
Active open/SYN
Passive open
Close
Close
LISTEN
SYN_RCVD
SYN/SYN + ACK
Send/SYN
SYN/SYN + ACK
ACK
Close/FIN
SYN_SENT
SYN + ACK/ACK
ESTABLISHED
Close/FIN
FIN/ACK
FIN_WAIT_1
CLOSE_WAIT
FIN/ACK
ACK
Close/FIN
FIN_WAIT_2
CLOSING
FIN/ACK
ACK Timeout after two
segment lifetimes
TIME_WAIT
LAST_ACK
ACK
CLOSED
19
4.7 TCP segments
0
10
4
16
31
SrcPort
DstPort
SequenceNum
Acknow ledgment
HdrLen
0
Flags
AdvertisedWindow
Checksum
UrgPtr
Options (variable)
Data
20
4.7 TCP segments
• Data field is optional.
• SN, AN, and window size are all involved in the sliding
window algorithm.
• SN refers to the number of the first data byte.
• The TCP header is not of fixed length due to the options
(MSS, timestamp, window scale, etc).
• The checksum covers the header and the payload, i.e.,
end-to-end checksum.
• A pseudo-header is first prepended to the TCP header before
computing the checksum.
21
4.7 TCP segments
• Both urgent pointer and PUSH can be used to serve as a
signal to the receiver about the “record boundary.”
• The receiving process needs to be notified when the URG bit or
PUSH bit is set.
• These mechanisms serve as end-of-record markers.
• The PUSH bit can also be used to allow the sending process to
send whatever bytes in the buffer (for interactive applications).