Announcements
• Quiz2–Mar31
• PA#3 due on Mar 29
• PA#4 available on Mar 31
Copyright By PowCoder代写 加微信 powcoder
• Discussions resume this week (end)
Transport Protocols
End-to-End Protocols
• Underlying network is best-effort
– drop messages
– re-orders messages
– delivers duplicate copies of a given message
– limits messages to some finite size
– delivers messages after an arbitrarily long delay
• Common end-to-end 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
– allow the receiver to flow control the sender
– support multiple application processes on each host
Basic function of transport layer
• How can processes on different systems get the right messages?
• Ports are numeric locators which enable messages to be demultiplexed to proper process.
– Ports are addresses on individual hosts, not across the Internet.
• Ports are established using well-know values first – Port 80 = http, port 53 = DNS
• Ports are typically implemented as message queues
• Simplest function of the transport layer: multiplexing/demultiplexing of messages
– Enables processes on different systems to communicate
– End-to-end since only processes on end hosts invoke this protocol
Other transport layer functions (TCP)
• Connection control
– Setting up and tearing down communication between processes
• Error detection within packets – our first focus – Checksums
• Reliable, in order delivery of packets – our second focus
– Acknowledgement schemes
• Flow control
– Matching sending and receiving rates between end hosts
• Congestion control
– Managing congestion in the network
User Datagram Protocol (UDP)
• Unreliable and unordered datagram service
• Adds multiplexing/demultiplexing
• Adds reliability through optional checksum
• No flow or congestion control
• Endpoints identified by ports
– servers have well-known ports
– see /etc/services on Unix
• Header format
• Optional checksum
– Computed over psuedo header + UDP header + data
Simple Demultiplexer (UDP)
• Extends host-to-host delivery service of the underlying network into a process-to-process communication service
• Adds a level of demultiplexing which allows multiple application processes on each host to share the network
Simple Demultiplexer (UDP)
UDP Message Queue
UDP Checksums
• Optional in current Internet
– Computed over UDP header + body (data) + pseudo header
• Psuedoheader consists of 3 fields from IP header: protocol number (TCP or UDP), IP src, IP dst and UDP length field
– Psuedoheader enables verification that message was delivered between correct source and destination.
– IP dest address was changed during delivery, checksum would reflect this
• UDPusesthesamechecksumalgorithmasIP – Internet checksum
UDP in practice
• Minimal specification makes UDP very flexible
– Any kind of end-to-end protocol can be implemented • TCP can be implemented using UDP
• Examples
– Most commonly used in multimedia applications • These are frequently more robust to loss
– Many others…
TCP Overview
• TCP is the most widely used Internet protocol – Web, Peer-to-peer, FTP, telnet, …
• A two way, reliable, byte stream oriented end-to-end protocol
– Includes flow and congestion control
• Closely tied to the Internet Protocol (IP)
• A focus of intense study for many years
– Our goal is to understand the RENO version of TCP
• RENO is most widely used TCP today
• RFC 2001 (now expired)
• RENO mainly specifies mechanisms for dealing with congestion
• Connection-oriented
• Byte-stream
– app writes bytes
– TCP sends segments
– app reads bytes
• Reliable data transfer
Full duplex
Flow control: keep sender from overrunning receiver
Congestion control: keep sender from overrunning network
Application process
Application process
Write bytes
Read bytes
TCP Features
Send buffer
Receive buffer
Segment … Transmit segments
• SequenceNum: First byte in data
• Acknowledgement: Next expected byte in reverse direction
• Flags: SYN, FIN, RESET, PSH, URG, ACK
• HdrLen: Length of header in 32-bit words
• AdvertisedWindow: Amount of room to receive data
Segment Format
SequenceNum
Acknowledgment
AdvertisedWindow
Options (variable)
Segment Format (cont)
• Each connection identified with 4-tuple:
– (SrcPort, SrcIPAddr, DsrPort, DstIPAddr)
– Used as the demuxing key
– Port can be reused after connection tear down – “another incarnation”
• Sliding window + flow control
– acknowledgment, SequenceNum, AdvertisedWinow Data(SequenceNum)
Acknowledgment + AdvertisedWindow
– SYN, FIN, RESET, PUSH, URG, ACK • Checksum is the same as UDP
– pseudo header + TCP header + data CS 640
Connection establishment
• Both sender and receiver must be ready before we start sending data
– Sender and receiver needs to agree on a set of parameters
– Most important: sequence number space in each direction
– Lots of other parameters, e.g., Size
• Handshake protocols: setup state between two oblivious endpoints
– Need to deal with delayed, duplicated, and re-ordered packets
Sequence Numbers
• 32 bit sequence numbers – Wrap around supported
• TCP breaks byte stream from application into packets (limited by Max. Segment Size)
• Each byte in the data stream is considered
• Each packet has a sequence number
– Initial number selected at connection time
– Subsequent numbers indicate first data byte number in packet
• ACK’sindicatenextbyteexpected
Two-way handshake?
• Opens both directions for transfer
Active participant (client)
Passive participant (server)
Is this sufficient? +data What’s wrong here?
CSE 123 – Lecture 10: Transport Layer
SYN, SequenceNum = x
SYN, SequenceNum = y ,
Active participant (client)
Passive participant (server)
Delayed old SYN
CSE 123 – Lecture 10: Transport Layer
Two-way handshake?
Old SYN, SequenceNum = x
YN, SequenceNum = q
, SYN, SequenceNum = y
Connection Establishment
• This diagram shows the (client) typical “3-way (client) handshake”. SYN_SENT
• Each side picks a random initial sequence number.
Active participant
Passive participant
Active participant
Passive participan
• This avoids the problem ESTABLISHED
of segment from earlier incarnation interfering with later incarnation.
CSE 123 – Lecture 10: Transport Layer
SYN, SequenceNum = x
SYN, SequenceNum = x
SYN + ACK, SequenceNum = y,
Acknowledgment = x + 1
SYN + ACK, SequenceNum = y,
Acknowledgment = x + 1
ACK, Acknowledgment = y + 1
ACK, Acknowledgment = y + 1
Data transfer
Active participant (client)
Passive participant (server)
• As much data as each side wants to send
Acknowledgment = x + 101 Data (50), SequenceNum = y+1
Acknowledgment = x + 101
Data (100), SequenceNum = x+1
ACK, Acknowledgment = y + 1
Initial Sequence Number?
• Thisisalsoimportant
– Consider a host sent a SYN and then crashed
– It reboots and then sends another new SYN
• Need to avoid confusion between the previous SYN and the new SYN
– How to choose ISNs?
• Maximize period between re-use • Minimizeabilitytoguess
Connection Termination
• Orderly release by sender and receiver when done – Delivers all pending data and ”hangs up”
• Cleans up state in sender and receiver
• TCPprovidesa“symmetric”close – Both sides shutdown independently
Connection Termination
Active participant (server)
Passive participant (client)
• “This side closes first” – i.e. close is invoked by server side of the connection.
• Visualized in the state
transition diagram as: ESTABLISHED => FIN_WAIT_1 => FIN_WAIT_2 => TIME_WAIT
CLOSE_WAIT LAST_ACK
FIN_WAIT2 TIME_WAIT
• Other possibilities can
similarly be observed using …
the state transition diagram
FIN,SequenceNum= x
Acknowledgment = x + 1 FIN, SequenceNum= y
Acknowledgment =y + 1
TIME_WAIT State
• We wait 2 * MSL (max segment lifetime of 60 seconds) before completing the close
• ACK might have been lost and so FIN will be resent
– Could interfere with a subsequent connection
• Reason for TIME_WAIT.
• Local side’s ACK in response to a FIN may not be successfully delivered.
• If the local side had immediately closed and reassigned the port to another incarnation, the older other sides retransmitted FIN segment may wrongly terminate the new connection.
Passive open
State Transition Diagram
Active open/SYN
SYN/SYN + ACK
SYN/SYN + ACK
Close/FIN FIN/ACK
Send/SYN SYN + ACK/ACK
ESTABLISHED
FIN_WAIT_1
CLOSE_WAIT
FIN_WAIT_2
ACK Timeoutaftertwo ACK segment lifetimes
ACK + FIN/ACK
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com