COMP30023 – Computer Systems
Transmission Control Protocol
© University of Melbourne 24/04/22
Copyright By PowCoder代写 加微信 powcoder
Recap – Transport Layer
• Provides services to the Application (or Session) layer using services from the Network layer.
The Transport layer entities (the hardware or software which actually does the work e.g. OS kernel, processes, NIC) can exist in multiple locations.
Services provide “logical” communication channels between processes running on different hosts:
– Connection-oriented
• =Connectionestablishment,datatransfer,connectionrelease(TCP) • Likephonecall
– Connectionless: data transfer (UDP) • Liketextmessages
© University of 2 4/24
/22 Melbourne
Introduction to Transmission Control Protocol (TCP) – Connecting
– Sending – Closing
(More basics of the transport layer will come later, but we need TCP for project 2.)
© University of 5 4/24
/22 Melbourne
The Transmission Control Protocol lets applications transmit and receive a stream of bytes, without worrying about
– SegmentingintoIPdatagrams (itis“streamoriented”) – Bytes being dropped, or duplicated (it is “reliable”)
– Bytesarrivingoutoforder (itis“inorder”)
TCP transport entity manages TCP streams and interfaces to the IP layer
– TCP entity accepts user data streams, and segments them into pieces <64Kb (often 1460 bytes in order to fit the IP and TCP headers into a single Ethernet frame), and sends each piece as a separate IP datagram
TCP - Overview
• Recipient TCP entities reconstruct the original byte streams from the encapsulation
© University of 6 4/24
/22 Melbourne
Primitives: core functions which allow interface with transport services (in particular TCP)
Transport/TCP service primitives
Packet Sent
Block until something tries to connect
CONNECTION REQ
Actively attempt to establish a connection
Send information
Block until DATA packet arrives
DISCONNECT
DISCONNECTION REQ
This sides wants to release the connection
“Select” is a non-TCP primitive allowing non-blocking receive
© University of 7 4/24
/22 Melbourne
TCP – Service Model
– (a)Four512-bytesegmentssentasseparateIPdatagrams
TN 6th 6-35
– (b)The2048bytesofdatadeliveredtotheapplicationinasingleREADcall
© University of 8 4/24
/22 Melbourne
TCP – Service Model
– A kernel data structure, named by the 5-tuple of IP address and port
The sender and receiver both create sockets number of sender and receiver, and the protocol
– For TCP service to be activated, connections must be explicitly established between a socket at a sending host (src-host, src-port) and a socket at a receiving host (dest-host, dest-port)
– 2sockets on port 80
© University of 9 4/24
/22 Melbourne
TCP connections are:
– Fullduplex-datainbothdirectionssimultaneously
– Endtoend-exactpairsofsendersandreceivers – Bytestreams,notmessagestreams
• messageboundariesarenotpreserved
Features of TCP connections
• TCPentitycanchoosetobufferpriortosendingornot
• Bufferingreducesoverhead(fewerheaders),butincreasesdelay
Buffer capable
© University of 11 4/24
/22 Melbourne
TCP Properties
Data is exchanged between TCP entities in segments each has a 20– 60 byte header, plus zero or more data bytes
TCP entities decide how large segments should be, given two constraints:
– IPpayload<65,515byte
Maximum Transfer Unit (MTU) - generally 1500 bytes
Sliding window protocol
– Initialuse:reliabledatadeliverywithoutoverloadingthereceiver
– Nowalsotiedcloselywithcongestioncontrol
Described next week
© University of 12 4/24
/22 Melbourne
TCP – Header
TN 6th 6-36
32-bit words, not bytes
For sliding window
© University of 13 4/24
/22 Melbourne
TCP – Important Headers
Description
Source port
Sending port
Destination port
Receiving port
Sequence Number
If SYN=1: initial sequence number
if SYN=0: is accumulated sequence number of the first data byte of this segment
Acknowledgement number
If ACK=1: next sequence number that the sender of the ACK is expecting
Data offset
Size of the TCP Header (20-60 bytes)
Single bit flags (SYN, ACK, RST, FIN, etc.)
Window size
Size of receive window – how much data the sender of this segment is willing to receive
© University of 14 4/24
/22 Melbourne
Remember that TCP is a connection orientated protocol running over a connectionless network layer (IP)
Connection establishment issues
When networks can lose, store and duplicate packets, connection establishment can be complicated
– congestednetworksmaydelayacknowledgements
– incurringrepeatedmultipletransmissions
– anyofwhichmaynotarriveatalloroutofsequence–delayed
duplicates
© University of 15 4/24
/22 Melbourne
Three-way handshake
– Ensureone(andonlyone)connectionisestablished,evenifsome
– Establishinitialsequencenumbersforslidingwindow Three-way handshake:
– Aproposedsolution,whichavoidsproblemsthatcanoccurwhen both sides allocate same sequence numbers by accident (e.g. after host/router crash) (cf. Tomlinson, 1975).
– Senderandreceiversexchangeinformationaboutwhichsequencing strategy each will use, and agree on it before transmitting segments
Goals of reliable connection establishment: set-up packets get lost
© University of 16 4/24
/22 Melbourne
Three-way handshake
Normal operation Simultaneous connection attempts.
– Twosimultaneousconnectionattemptsresultsinonlyoneconnection (uniquely identified by end points).
• At end, Host 1 and Host 2 have agreed on respective sequence numbers
TN 6th 6-37
© University of 18 4/24
/22 Melbourne
Acknowledgement Number – next byte the sender expects to receive
– Bytesreceivedwithoutgaps–amissingsegmentwillstopthis incrementing, even if later segments have been received
Synchronisation
SYN is used for synchronization during connection establishment
Sending SYN or FIN causes sequence number to be incremented by 1 Sequence Number – first byte of this segments payload
– Offsetbyarandomnumber–initialvalueisarbitrary,offsetwillbe
reflected in both Sequence and Acknowledgement numbers
© University of 19 4/24
/22 Melbourne
Request for single image file:
http://static.bbci.co.uk/weather/0.5.284/images/icons/indiv idual_56_icons/en_on_light_bg/1.gif
, HTTP (connection:close)
Wireshark Example
© University of 20 4/24
/22 Melbourne
Wireshark Example
104.83.244.56
© University of 21 4/24
/22 Melbourne
TCP Synchronization Recap
• SYN bit is used to establish a connection – ConnectionrequesthasSYN=1,ACK=0
– ConnectionreplyhasSYN=1,ACK=1
• SYN is used in both CONNECTION_REQUEST and CONNECTION_ACCEPTED, ACK bit distinguishes between the two
• After connection setup:
– SequenceNumber–firstbyteofthissegmentpayload(1+datasentpriortothis segment)
• Offset by a random number – initial value is arbitrary, offset will be reflected in both Sequence and Acknowledgement numbers
– AcknowledgementNumber–nextbytethesenderexpectstoreceive(data successfully received + 1)
• Bytes received without gaps – a missing segment will stop this incrementing, even if later segments have been received
© University of 22 4/24
/22 Melbourne
Each segment sent has an associated retransmission timer (RTO)
– Initialisedwithadefaultvalueandupdatedbasedonnetwork performance
– IfthetimerexpiresbeforeanACKisreceivedthesegmentisresent
Receiver receives segment with a sequence number higher than expected (i.e. segment has been lost)
– ReceiversendsACKwithsequencenumberitisexpecting(i.e.the next byte it expects – also implies data it has received)
– Thisisaduplicateofthepreviouslysentacknowledgement(DupACK)
– Afterreceiving3DupACKsthesenderresendsthelostsegment,thisis known as fast retransmission
Error recovery: TCP Retransmission
© University of 23 4/24
/22 Melbourne
TCP Closing
The FIN flag is used to signify a request to close a connection
Typically requires 4 segments to close, 1 FIN and 1 ACK for each direction
– Can be optimised: FIN, FIN/ACK, ACK
Each FIN is directional, once acknowledged no further data can be sent from the sender to the receiver
– Datacancontinuetoflowintheotherdirection
– E.g.clientcouldsendFINaftermakingrequest,butbeforereceiving
the response
– SenderofFINwillstillretransmitunacknowledgedsegments
© University of 24 4/24
/22 Melbourne
Can be used to close a connection, but FIN is greatly preferred because it is an orderly shutdown of the connection, as opposed to a reset
TCP Closing
– Basicallystatesthesenderisclosingtheconnectionandwillnot
The RST flag is used to signify a hard close of a connection listen for any further messages
• e.g.,toinvaliddatabeingsentoracrashedprocessthatleftaremote
Sent in reply to a packet sent to a 5-tuple with no open connection
socket open, that the OS is now cleaning up
© University of 25 4/24
/22 Melbourne
And finally...
• Google’s QUIC has shown that there is demand for a new transport protocol
– Whyisitonlynowbeingdeployed? – WhydoesitrunontopofUDP?
Although the transport layer is supposed to be “end to end”, there are many “middleboxes” that inspect and modify transport layer protocols
– Firewalls,NAT(laterlecture),intrusiondetectionsystems,loadbalancers These all accept TCP and UDP, but typically drop all other
transport layer protocols.
Stream Control Transport Protocol is a carefully designed protocol that achieves many of the goals of QUIC, but it hasn’t been widely deployed because of these middleboxes.
©4/24 University of
/22 Melbourne
(This time is final for sure...)
• SYN Flooding
– Popularattackinthe90’stodenialofserviceaserver
– Rememberbacktothearbitrary(random)initialSequencenumber
– ThisrequirestheservertorememberaninitialSequencenumberforeach
received SYN request
– AnattackerwouldmakeinitialSYNrequeststhennotsendtheappropriate ACK, causing the server to gradually fill up its queue with sequence numbers for now defunct connections
– OnesolutionwasSYNCookies
• Ratherthanstorethesequencenumberitisderivedfromconnection information and a timer that creates a stateless SYN queue using cryptographic hashing
• IncursperformancecostinvalidatingSYNCookies,butpreferabletobeing unresponsive – typically only enabled when under attack
© University of 27 4/24
/22 Melbourne
The slides are based on slides prepared by based on material developed previously by: , , , and .
Acknowledgement
Some of the images included in the notes were supplied as
part of the teaching resources accompanying the text books
listed in lecture 1.
– (And also) Computer Networks, 6th Edition, Tanenbaum A., Wetherall. D.
https://ebookcentral.proquest.com/lib/unimelb/detail.action?docID=6481879
Textbook Reference: Sections 3.1,3.2, 3.5, pp.314-319
© University of 28 4/24
/22 Melbourne
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com