CS代考 COMP30023 – Computer Systems

PowerPoint Presentation

COMP30023 – Computer Systems

Copyright By PowCoder代写 加微信 powcoder

© University of Melbourne 24/04/22

Transmission Control Protocol

• 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

• = Connection establishment, data transfer, connection release (TCP)
• Like phone call

– Connectionless: data transfer (UDP)
• Like text messages

Recap – Transport Layer

© University of

• Introduction to Transmission Control Protocol (TCP)
– Connecting

(More basics of the transport layer will come later, but we
need TCP for project 2.)

© University of

• The Transmission Control Protocol lets applications transmit
and receive a stream of bytes, without worrying about
– Segmenting into IP datagrams (it is “stream oriented”)
– Bytes being dropped, or duplicated (it is “reliable”)
– Bytes arriving out of order (it is “in order”)

• TCP transport entity manages TCP streams and interfaces to the
– 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 • Recipient TCP entities reconstruct the original byte streams from the encapsulation TCP - Overview © University of • Primitives: core functions which allow interface with transport services (in particular TCP) “Select” is a non-TCP primitive allowing non-blocking receive Transport/TCP service primitives © University of Primitive Packet Sent Meaning LISTEN (none) Block until something tries to connect CONNECT CONNECTION REQ Actively attempt to establish a connection SEND DATA Send information RECEIVE (none) Block until DATA packet arrives DISCONNECT DISCONNECTION REQ This sides wants to release the connection • Example: – (a) Four 512-byte segments sent as separate IP datagrams – (b) The 2048 bytes of data delivered to the application in a single READ call TCP – Service Model © University of TN 6th 6-35 • The sender and receiver both create sockets – A kernel data structure, named by the 5-tuple of IP address and port 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) • Example: – 2 sockets on port 80 TCP – Service Model © University of • TCP connections are: – Full duplex - data in both directions simultaneously – End to end - exact pairs of senders and receivers – Byte streams, not message streams • message boundaries are not preserved – Buffer capable • TCP entity can choose to buffer prior to sending or not • Buffering reduces overhead (fewer headers), but increases delay Features of TCP connections © University of • 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: – IP payload < 65,515 byte – Maximum Transfer Unit (MTU) - generally 1500 bytes • Sliding window protocol – Initial use: reliable data delivery without overloading the receiver – Now also tied closely with congestion control – Described next week TCP Properties © University of TCP – Header © University of For sliding window TN 6th 6-36 32-bit words, Name 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 If ACK=1: next sequence number that the sender of the ACK is expecting Data offset Size of the TCP Header (20-60 bytes) Flags 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 TCP – Important Headers © University of • Remember that TCP is a connection orientated protocol running over a connectionless network layer (IP) • When networks can lose, store and duplicate packets, connection establishment can be complicated – congested networks may delay acknowledgements – incurring repeated multiple transmissions – any of which may not arrive at all or out of sequence – delayed duplicates Connection establishment issues © University of • Goals of reliable connection establishment: – Ensure one (and only one) connection is established, even if some set-up packets get lost – Establish initial sequence numbers for sliding window • Three-way handshake: – A proposed solution, which avoids problems that can occur when both sides allocate same sequence numbers by accident (e.g. after host/router crash) (cf. Tomlinson, 1975). – Sender and receivers exchange information about which sequencing strategy each will use, and agree on it before transmitting segments Three-way handshake © University of Normal operation Simultaneous connection attempts. – Two simultaneous connection attempts results in only one connection (uniquely identified by end points). • At end, Host 1 and Host 2 have agreed on respective sequence numbers Three-way handshake © University of TN 6th 6-37 • 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 – Offset by a random number – initial value is arbitrary, offset will be reflected in both Sequence and Acknowledgement numbers • Acknowledgement Number – next byte the sender expects to – Bytes received without gaps – a missing segment will stop this incrementing, even if later segments have been received Synchronisation © University of • 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 http://static.bbci.co.uk/weather/0.5.284/images/icons/individual_56_icons/en_on_light_bg/1.gif http://static.bbci.co.uk/weather/0.5.284/images/icons/individual_56_icons/en_on_light_bg/1.gif Wireshark Example © University of 104.83.244.56 • SYN bit is used to establish a connection – Connection request has SYN=1, ACK=0 – Connection reply has SYN=1, ACK=1 • SYN is used in both CONNECTION_REQUEST and CONNECTION_ACCEPTED, ACK bit distinguishes between the two • After connection setup: – Sequence Number –first byte of this segment payload (1 + data sent prior to this • Offset by a random number – initial value is arbitrary, offset will be reflected in both Sequence and Acknowledgement numbers – Acknowledgement Number – next byte the sender expects to receive (data successfully received + 1) • Bytes received without gaps – a missing segment will stop this incrementing, even if later segments have been received TCP Synchronization Recap © University of • Each segment sent has an associated retransmission timer – Initialised with a default value and updated based on network performance – If the timer expires before an ACK is received the segment is resent • Receiver receives segment with a sequence number higher than expected (i.e. segment has been lost) – Receiver sends ACK with sequence number it is expecting (i.e. the next byte it expects – also implies data it has received) – This is a duplicate of the previously sent acknowledgement (DupACK) – After receiving 3 DupACKs the sender resends the lost segment, this is known as fast retransmission Error recovery: TCP Retransmission © University of • The FIN flag is used to signify a request to close a connection • Each FIN is directional, once acknowledged no further data can be sent from the sender to the receiver – Data can continue to flow in the other direction – E.g. client could send FIN after making request, but before receiving the response – Sender of FIN will still retransmit unacknowledged segments • Typically requires 4 segments to close, 1 FIN and 1 ACK for each direction – Can be optimised: FIN, FIN/ACK, ACK TCP Closing © University of • The RST flag is used to signify a hard close of a connection – Basically states the sender is closing the connection and will not listen for any further messages – Sent in reply to a packet sent to a 5-tuple with no open connection • e.g., to invalid data being sent or a crashed process that left a remote socket open, that the OS is now cleaning up • 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 © University of • Google’s QUIC has shown that there is demand for a new transport protocol – Why is it only now being deployed? – Why does it run on top of UDP? • Although the transport layer is supposed to be “end to end”, there are many “middleboxes” that inspect and modify transport layer protocols – Firewalls, NAT (later lecture), intrusion detection systems, load balancers • 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. And finally… © University of • SYN Flooding – Popular attack in the 90’s to denial of service a server – Remember back to the arbitrary (random) initial Sequence number – This requires the server to remember an initial Sequence number for each received SYN request – An attacker would make initial SYN requests then not send the appropriate ACK, causing the server to gradually fill up its queue with sequence numbers for now defunct connections – One solution was SYN Cookies • Rather than store the sequence number it is derived from connection information and a timer that creates a stateless SYN queue using cryptographic • Incurs performance cost in validating SYN Cookies, but preferable to being unresponsive – typically only enabled when under attack (This time is final for sure…) © University of • The slides are based on slides prepared by based on material developed previously by: , , , and . • 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 Acknowledgement © University of https://ebookcentral.proquest.com/lib/unimelb/detail.action?docID=6481879 Transmission Control Protocol Recap – Transport Layer TCP - Overview Transport/TCP service primitives TCP – Service Model TCP – Service Model (2) Features of TCP connections TCP Properties TCP – Header TCP – Important Headers Connection establishment issues Three-way handshake Three-way handshake (3) Wireshark Example (2) TCP Synchronization Recap Error recovery: TCP Retransmission TCP Closing TCP Closing (2) And finally… (This time is final for sure…) Acknowledgement 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com