Data Communications w04 - OSI Layer 4.pdf

Full Transcript

Data Communications LECTURE: TRANSPORT LAYER (UDP AND TCP) Macquarie University This Week In The Lectures 1. Summary of Workshop Tasks 2. Lecture: Transport Layer (Looking at UDP) Why do we need yet another layer of addressing? Reminder about the semantics of IP Problems we are addressing at the tra...

Data Communications LECTURE: TRANSPORT LAYER (UDP AND TCP) Macquarie University This Week In The Lectures 1. Summary of Workshop Tasks 2. Lecture: Transport Layer (Looking at UDP) Why do we need yet another layer of addressing? Reminder about the semantics of IP Problems we are addressing at the transport layer UDP and TCP at a glance. UDP (not host to host delivery, process to process delivery) Transport layer address mechanism (ports) 3. Lecture: Transport Layer (Looking at TCP) TCP Reminder about ports and address space Rationale for TCP 3 way handshake Sequence numbers Acknowledgement numbers Note: we are not doing sliding window in this unit Segmentation Flags? What do the six flags do? Macquarie University - Data Communications 2 YOUR WEEKLY PRACTICAL TASKS WEEK 4: SUBNETTING WEEK 5: TCP AND FTP Do we alwayshappening have to start with an in IP Range that has an 8, What’s binary? 16, or 24 bit Net Mask? No! We could start with a “/17” FOR THE SLIDE WE CREATED 4 SUBNETS network orPREVIOUS a “/23” network or a… 177.122.0.0 Written in binary Network address: Broadcast address: Net Mask: 10110001.01111010.00000000.00000000 10110001.01111010.11111111.11111111 11111111.11111111.00000000.00000000 This is the network 177.122.0.0/16 Let’s create 4 subnetworks (so use 2 extra bits for the network) Network 1 address: Broadcast address: Net Mask: 10110001.01111010.00000000.00000000 10101100.01111010.00111111.11111111 11111111.11111111.11000000.00000000 Network 2 address: Broadcast address: Net Mask: 10110001.01111010.01000000.00000000 10101100.01111010.01111111.11111111 11111111.11111111.11000000.00000000 Network 3 address: Broadcast address: Net Mask: 10110001.01111010.10000000.00000000 10101100.01111010.10111111.11111111 11111111.11111111.11000000.00000000 Network 4 address: Broadcast address: Net Mask: 10110001.01111010.11000000.00000000 10101100.01111010.11111111.11111111 11111111.11111111.11000000.00000000 Macquarie University - Data Communications Note that the subnets will now be /18 networks rather than /16 networks because they use 18 bits to define the network address. If we wanted to be “polite”, but still need 4 usable subnets, how many subnets do we actually need to create? So how many MORE bits do we need for the network? 4 Week 4 Workshop: Subnetting A note about the subnetting workshop this week… We don’t normally provide solutions to weekly pracs as they don’t really change from year to year… however, we have provided a worked solution to your subnetting workshop and two other subnetting exercises. We will post them on the weekend. Week 5 Workshop: TCP and FTP (Transport Layer) This workshop is about understanding the structure of the TCP header and the purpose of the component fields, observe the TCP three-way handshake in operation, gain a basic understanding of TCP sequence numbers. Understand how TCP supports applications. Macquarie University - Data Communications 5 Transport Layer PROTOCOLS: TCP AND UDP Transport Layer “PROCESS TO PROCESS” VS “HOST TO HOST” COMMUNICATION The IP layer is responsibly for “trying” to get the message to the destination IP address, but which “process” on the destination host needs to receive it? IP address (Source) Macquarie University - Data Communications IP address (Destination) 7 Transport Layer “PROCESS TO PROCESS” VS “HOST TO HOST” COMMUNICATION The IP layer is responsibly for “trying” to get the message to the destination IP address, but which “process” on the destination host needs to receive it? There might also be multiple “conversations” going on between these two hosts… so how do they keep track about which message is for which conversation? IP address (Source) Extra “From” details here Macquarie University - Data Communications IP address (Destination) Extra “To” details here 8 The Transport Layer LOCATION AND FUNCTIONS 1. Linking to the Application layer 2. Segmentation 3. Sessions management protocol data unit data data Host Layers data segment datagram Media Layers frame bit Macquarie University - Data Communications layer application Network process to application presentation Data Representation and Encryption session Internet Communication transport End-to-end Connections and Reliability network Path determination and Logical Addressing data-link Physical Addressing and Media Access physical Media, Signal, and Binary Tranmission 9 Transport Layer WHAT IS IT GENERALLY RESPONSIBLE FOR? 1. Linking to the Application layer The Network (IP) layer delivered to the destination machine. Now what? 2. Segmentation When we want a more reliable “connection”, then it can also be responsible for “segmentation” and “reassembly” (Not UDP!) Breaking the message into several smaller pieces at the sending end Reconstructing the original message into a single whole at the receiving end 3. Session management Responsible for end-to-end delivery of messages (UDP, TCP, …) Sets up connections (also called sessions or virtual circuits) Macquarie University - Data Communications 10 Multiple conversations? 1. WHO IS IT FOR? ::80 ::22 Port: uniquely identifies a connection endpoint 177.122.0.53::80 :: Macquarie University - Data Communications 11 A reminder of addressing schemes WHAT IS USED AT EACH OF THE LOWER LAYERS? Layer Address Kind Computer Representation Human Representation Application Application Dependent HTTP - URLs String String Transport [Layer 4] Port - destination application 16 bit field Number 0-65,535 24 IPv4 32 bit field 4 decimals 0-255 134.57.33.2 IPv6 128 bit field 8x4 hex digits 4534:4EF3:4AFD:A43F:4567:E34F:236B:453F Data Link [Layer 2] MAC address (Ethernet) 48 bit field (6 bits) 6x2 hex digits AE:56:23:F4:65:D3 Physical [Layer 1] Bits put in one end come out the N/A other! N/A Bits are broadcast on link, i.e.., flood. Example … IP Address Network [Layer 3] Macquarie University - Data Communications 12 IP address + Port = where to go? “PROCESS TO PROCESS” 177.122.0.53::80 :: Port numbers are 16 bits. There are 3 types of ports… Well-known [system] ports (0 to 1023) Registered [user] ports (1024 to 49151) Dynamic [private] ports (49152 to 65535) IANA guideline: https://www.iana.org Question: Does anyone know what services use these ports off the top of your head? Also, which transport protocol do each of them use… TCP or UDP or both? Ports: 22, 25, 80, 110, 443, 3389? Macquarie University - Data Communications 13 Transport Layer 2. SEGMENTATION AND RECONSTRUCTION Let’s think about a http response packet being managed at the transport layer by TCP. Note UDP doesn’t do this… An application wants to send some data [HTTP header[response data]] TCP will go through and “break it up” into multiple segments… but there needs also needs some header information for TCP so the destination knows what “order” to assemble them and pass up to the upper layers. Macquarie University - Data Communications 14 Transport Layer 2. SEGMENTATION AND RECONSTRUCTION Once we’ve done this (and some other things in the transport layer headers for each segment), then we can pass each of these segments down to the network layer and beyond… Also, the re-assembly process happens at the other end too. With TCP, the order is managed so that the upper layers receive the reassembled data in order. Macquarie University - Data Communications 15 Reminder What does the IP layer give us? WHAT WE NEED TO “COPE WITH” AT THE TRANSPORT LAYER Question IP LAYER IP handles network and machine addressing… Should the IP layer worry about delivering the message to the recipient process? (e.g. web browser, email client, game, web server, zoom, …) Why / why not? Do we (choose one: at no time, sometimes, always) care if the message is successfully delivered? Macquarie University - Data Communications 17 Semantics of IP IP LAYER IP handles network and machine addressing… It is an unreliable, connectionless, packet delivery service It also does not generally handle errors Applications / services need to receive messages designated for them… so it might make sense to give a bit more information in the packets about where the message needs to go once it reaches the host. Macquarie University - Data Communications 18 Transport Layer OK, “IT” IS AT THE DESTINATION HOST, NOW WHAT? protocol data unit data data Host Layers data segment datagram Media Layers frame bit Macquarie University - Data Communications layer application Network process to application presentation Data Representation and Encryption session Internet Communication transport End-to-end Connections and Reliability network Path determination and Logical Addressing data-link Physical Addressing and Media Access physical Media, Signal, and Binary Tranmission 19 Two problems for the transport layer 1) WE NEED “PROCESS TO PROCESS” DELIVERY RATHER THAN HOST TO HOST 2) WE MIGHT (IN SOME CASES) WANT TO MAKE IT A “RELIABLE CONNECTION” SEMANTIC UDP deals with 1, TCP deals with 1 and 2 Transport Layer WHAT IS IT GENERALLY RESPONSIBLE FOR? To solve those 2 problems we have a layer between the IP layer and the Application layer Responsible for end-to-end delivery of messages (UDP, TCP, …) Sets up connections (also called sessions or virtual circuits) When we want a more reliable “connection”, then it can also be responsible for “segmentation” and “reassembly” (Not UDP!) Breaking the message into several smaller pieces at the sending end Reconstructing the original message into a single whole at the receiving end Macquarie University - Data Communications 21 Two common protocols UDP: (RFC 768) USER DATAGRAM PROTOCOL TCP: (RFC 793) TRANSMISSION CONTROL PROTOCOL Transport Layer: Part 1 UDP User Datagram Protocol (UDP) UDP IS A LIGHT-WEIGHT TRANSPORT PROTOCOL Provides connectionless service that offers unreliable, “best effort” delivery. (Same as IP) No guarantee of arrival of the datagrams No guarantee of order of delivery No acknowledgement (ACK) of received messages No flow control (order of arrival is the order it is passed up to the upper layers) Provides application programs with the ability to send and receive datagrams Header has an optional checksums on transport packets are available (if not used, just put all zeros). Each message identifies the receiver using the port number UDP messages are encapsulated in IP datagrams so the IP layer has the destination, then the transport layer indicates where in the destination it needs to go. The RFC is only about 3 pages long! Macquarie University - Data Communications 23 IP address + Port = where to go? “PROCESS TO PROCESS” What’s in the header? [ UDP Source Port | => 16 bits UDP Destination Port | => 16 bits UDP Message Length | => 16 bits (representing length in bytes) Optional UDP checksum | => 16 bits (if zero, then assumed not used) … then comes the message data which can potentially be quite large ] Question: what happens if the UDP datagram ends up being larger than what can be handled by IP? Macquarie University - Data Communications 24 Sockets and socket pairs ENABLING PROCESS TO PROCESS COMMUNICATION Note: sockets are NOT part of UDP or TCP, but are what we use to set up the communication lines in the applications Sockets (IP, PORT) There can be many different processes running on each machine, but the combination of port numbers and ip addresses means that we now have a complete picture of how an application can receive some data. A “Socket Pair” (Source[ip, port], Destination[ip,port]) defines a conversion line between processes. IP address (Source) Port number (Source) Macquarie University - Data Communications IP address (Destination) Port number (Destination) Image sources: Firefox Logo: Mozilla Foundation https://mozilla.design/firefox/logos-usage/ Apache Logo: The Apache Software Foundation https://www.apache.org/logos/ 26 Sockets (IP, PORT) So, in this case, the Apache http web server process registers on the destination transport layer that it is ready to accept messages on port 80. This is a static, well known port for http. IP address (Source) Port number (Source) Macquarie University - Data Communications 172.217.167.99 (Destination) 80 (Destination) Image sources: Firefox Logo: Mozilla Foundation https://mozilla.design/firefox/logos-usage/ Apache Logo: The Apache Software Foundation https://www.apache.org/logos/ 27 Sockets (IP, PORT) So, in this case, the Apache http web server process registers on the destination transport layer that it is ready to accept messages on port 80. This is a static, well known port for http. A client process can then create a socket by requesting the transport layer to assign a port for communication, and then use it to create a socket pair (source, destination) so that the application can send the message. The source port in this example is a dynamically assigned port from the transport layer, 177.122.5.23 (Source) Dynamically assigned port for the connection (Source) Macquarie University - Data Communications 172.217.167.99 (Destination) 80 (Destination) Image sources: Firefox Logo: Mozilla Foundation https://mozilla.design/firefox/logos-usage/ Apache Logo: The Apache Software Foundation https://www.apache.org/logos/ 28 Sockets MORE FORMALLY… Sockets are the programming interface (API) between the Application and Transport layers Similar in concept to a file handle Functions as an endpoint for network communication. An application creates a socket by specifying three items: Type of service reliable connection-oriented transport service – TCP unreliable connectionless transport service – UDP IP address of the host Port the application is using. Application can create a socket And use it to send connectionless traffic to remote applications OR connect it to another application’s socket for reliable delivery of data. Macquarie University - Data Communications 29 Transport Layer PORTS VS SOCKETS Port: Identifies service / application Does not specify the protocol Unique number (0 - 65535) Socket: API (represents communication channel) Specifies the protocol (IP address, Port number, Protocol) Macquarie University - Data Communications 30 A reminder of addressing schemes WHAT IS USED AT EACH OF THE LOWER LAYERS? Layer Address Kind Computer Representation Human Representation Application Application Dependent HTTP - URLs String String Transport [Layer 4] Port - destination application 16 bit field Number 0-65,535 24 IPv4 32 bit field 4 decimals 0-255 134.57.33.2 IPv6 128 bit field 8x4 hex digits 4534:4EF3:4AFD:A43F:4567:E34F:236B:453F Data Link [Layer 2] MAC address (Ethernet) 48 bit field (6 bits) 6x2 hex digits AE:56:23:F4:65:D3 Physical [Layer 1] Bits put in one end come out the N/A other! N/A Bits are broadcast on link, i.e.., flood. Example … IP Address Network [Layer 3] Macquarie University - Data Communications 31 Big Ideas from Layer 4 (UDP) WHAT HAVE WE BEEN FOCUSING ON? 1. We now know how processes can talk to one another using sockets! They can leverage the ports at the Transport layer. Depending on the transport protocol being used, the message may be transmitted using a reliable connection-oriented transport service or an unreliable connectionless transport service Macquarie University - Data Communications 32 Big Ideas from today WHAT HAVE WE BEEN FOCUSING ON? 1.Transport Layer Ports! What are they, and what are the different types? (Note, these are NOT describing the hardware ports like USB, Ethernet, ….) Main purposes of transport layer protocols 1. We need “process to process” delivery rather than host to host 2. We might (in some cases) want to make it a “reliable connection” semantic Two main protocols we’ll look at: TCP, UDP… What are the differences? What are the commonalities? What do the headers look like? Macquarie University - Data Communications 33 Transport Layer: Part 2 TCP TRANSMISSION CONTROL PROTOCOL Transport Layer OK, “IT” IS AT THE DESTINATION HOST, NOW WHAT? protocol data unit data data Host Layers data segment datagram Media Layers frame bit Macquarie University - Data Communications layer application Network process to application presentation Data Representation and Encryption session Internet Communication transport End-to-end Connections and Reliability network Path determination and Logical Addressing data-link Physical Addressing and Media Access physical Media, Signal, and Binary Tranmission 35 Sending a message A MESSAGE CAN GO THROUGH MANY LINKS - WHAT HAPPENS AT EACH STAGE? WE’RE ALMOST READY TO ANSWER THIS! Macquarie University - Data Communications 36 Two problems for the transport layer 1) WE NEED “PROCESS TO PROCESS” DELIVERY RATHER THAN HOST TO HOST 2) WE MIGHT (IN SOME CASES) WANT TO MAKE IT A “RELIABLE CONNECTION” SEMANTIC UDP deals with 1, TCP deals with 1 and 2 Reminder of two common protocols UDP: (RFC 768) USER DATAGRAM PROTOCOL TCP: (RFC 793) TRANSMISSION CONTROL PROTOCOL There are other Transport layer protocols we are NOT covering in this unit e.g. SCTP, DCCP, RUDP, … Transport Control Protocol (TCP) ADDS MORE GUARANTEES ABOUT WHAT GETS DELIVERED TCP is a heavy-duty, reliable, connection-oriented service TCP packets are called segments. They are encapsulated in network layer (IP) protocol packets. Connection-oriented: a session must be established before hosts can exchange data Like UDP, it also uses ports The RFC for TCP is about 85 pages long! So we’ll look at what it does and how it does it in next week’s lecture! Macquarie University - Data Communications 39 TCP WHAT WE’LL LOOK AT FOR TCP Reminder about ports and address space Rationale for TCP 3 way handshake Sequence numbers Acknowledgement numbers Sliding window (only covered at surface level) Segmentation Flags: What do the six flags do in the TCP header? Macquarie University - Data Communications 40 A reminder of addressing schemes WHAT IS USED AT EACH OF THE LOWER LAYERS? Layer Address Kind Computer Representation Human Representation Application Application Dependent HTTP - URLs String String Transport [Layer 4] Port - destination application 16 bit field Number 0-65,535 24 IPv4 32 bit field 4 decimals 0-255 134.57.33.2 IPv6 128 bit field 8x4 hex digits 4534:4EF3:4AFD:A43F:4567:E34F:236B:453F Data Link [Layer 2] MAC address (Ethernet) 48 bit field (6 bits) 6x2 hex digits AE:56:23:F4:65:D3 Physical [Layer 1] Bits put in one end come out the N/A other! N/A Bits are broadcast on link, i.e.., flood. Example … IP Address Network [Layer 3] Macquarie University - Data Communications 41 Rationale for TCP WHAT DOES IT GIVE US THAT UDP DOESN’T? What we are looking at in TCP Transmission Control Protocol (TCP) 1. Connection-oriented reliable communication 2. Packetisation 3. Reliability and flow control User Datagram Protocol (UDP) Simplest possible transport-layer protocol Connectionless communication with no guarantee Reliable delivery and packetisation is the responsibility of application There are others too, but we aren’t covering them in COMP2250 Macquarie University - Data Communications 43 Transport Layer SEGMENTATION AND RECONSTRUCTION Let’s think about a http response packet being managed at the transport layer by TCP. Note UDP doesn’t do this… An application wants to send some data [HTTP header[response data]] TCP will go through and “break it up” into multiple segments… but there needs also needs some header information for TCP so the destination knows what “order” to assemble them and pass up to the upper layers. Macquarie University - Data Communications 44 What we are looking at in TCP WHAT’S IN A TCP SEGMENT? [16 bits | 16 bits | 32 bits | 32 bits | 4 bits | 6 bits | 6 * 1 bits | 16 bits | 16 bits | 16 bits | 32 bits] = 192 bits (24 bytes) Source Port - 16 bits Destination Port - 16 bits Sequence Number - 32 bits Acknowledgement Number - 32 bits Header Length - 4 bits Reserved - 6 bits 6 flags (each flag is 1 bit) - 6 bits TCP Checksum - 16 bits (to make sure no errors during transmission) Window Size - 16 bits Urgent Pointer - 16 bits TCP Options - 32 bits (optional) We’ll talk more about these flags in a bit… Macquarie University - Data Communications Flag Bit Meaning when = 1 URG Urgent data delivery ACK Acknowledgement packet PSH Request a push RST Reset connection SYN Synchronize sequence numbers FIN Sender has reached end of byte stream 45 3 way handshake TCP “RELIABILITY" Rather than just sending the “data”, let’s send some “agreement” about how to communicate for this session first… TCP Reliability 3 WAY HANDSHAKE Since physical networks and IP are unreliable – how can we provide reliability on top of these unreliable foundations? The answer is like in a mail system – A return receipt In TCP this is a returned packet confirming successful receipt. A TCP session is initialised through a 3-way handshake process. The purpose of the 3-way handshake is to: Synchronise the sending and receiving of segments. Inform the other host of the amount of data it is able to receive at once (flow control) Establish a virtual connection. Macquarie University - Data Communications 47 SYN - SYN/ACK - ACK THE HANDSHAKE TO GET STARTED WITH COMMUNICATIONS The return receipt is called an ACK packet ACK is just techie speak for Acknowledgement ACK is signalled by one of those bits in the TCP header flags (representation and implementation detail) Macquarie University - Data Communications 48 SYN - SYN/ACK - ACK THE HANDSHAKE PROCESS 1) The initiating host requests a session by sending out a segment with the synchronisation (SYN) set to on. (SYN segment) The client chooses a random sequence number and sends this to the server. A sequence number to indicate the starting byte for a segment it may send. 2) The server acknowledges the request by sending back a segment (SYN/ACK segment) with: The synchronisation flag set to on. A sequence number to indicate the starting byte for a segment it may send. An acknowledgement with the byte sequence number of the next segment it expects to receive from the client (The sequence number in SYN segment +1) That is, the tcp seq number + the number of bytes + 1 3) The client sends the ACK segment. It acknowledges the receipt of the second segment with the ACK flag and the acknowledgement number field. Note that the sequence number in this segment is same as the SYN segment. A FIN and FIN/ACK segments are needed to close a TCP connection. Macquarie University - Data Communications 49 A B Connection State Time Macquarie University - Data Communications 50 The idea CONNECT A B SYN Requests a TCP connection (session) and negotiates packet size with B Macquarie University - Data Communications Connection State SYN/ACK ACK Connection Establishment 51 The idea TRANSMIT A B SYN Requests a TCP connection (session) and negotiates packet size with B Connection State SYN/ACK Connection Establishment ACK Data 1 Data 2 Sends data packets one by one (in order) … … Data 3 ACK Data Transfer … Data 4 … Macquarie University - Data Communications 52 The idea CLOSE A B SYN Requests a TCP connection (session) and negotiates packet size with B Connection State SYN/ACK Connection Establishment ACK Data 1 Data 2 Sends data packets one by one (in order) … … Data 3 ACK Data Transfer … Data 4 … FIN FIN/ACK Closes session Macquarie University - Data Communications ACK Connection Termination 53 Handshake… that’s the concept HOW DOES IT HAPPEN WITH MULTIPLE COMMUNICATIONS? What happens with: 1. Lost Packets? 2. “Timer expired”, and retransmitting the packet 3. Sending a simple “Ack” -> sliding window (just surface level) 4. Packets arrive at destination out of order Macquarie University - Data Communications 54 TCP Reliability THE IDEA A B Send packet 1 Wait for ACK 1 Receive packet 1 Send ACK 1 Time Receive ACK 1 Send packet 2 Wait for ACK 2 Receive packet 2 Send ACK 2 Receive ACK 2 Macquarie University - Data Communications 55 TCP Reliability LOST PACKETS? SOLUTION: RESEND THE PACKET! Refinement: add a timer / timeout! A B Send packet 1 Wait for ACK 1 X Packet “lost” Timeout to receive ACK 1 Time Resend packet 1 Wait for ACK 1 Receive packet 1 Send ACK 1 Receive ACK 1 Macquarie University - Data Communications 56 TCP Reliability RESENDING? CAN CREATE A PROBLEM What happens if the timer expires before the ACK is received? A B Send packet 1 Wait for ACK 1 Receive packet 1 Timeout to receive ACK 1 Receive ACK 1 Send ACK 1 Time Resent packet 1 Wait for ACK 1 Receive packet 1 Send ACK 1 Receive ACK 1 Macquarie University - Data Communications 57 TCP Reliability RESENDING? CAN CREATE A PROBLEM What happens if the timer expires before the ACK is received? A B Send packet 1 Solution: B can check the sequence number of the received packet to see if it has already been received. Wait for ACK 1 Receive packet 1 Check packet sequence number Timeout to receive ACK 1 Receive ACK 1 Send ACK 1 Time Resent packet 1 Wait for ACK 1 Don’t have it – add it Receive packet 1 Send ACK 1 Check packet sequence number Receive ACK 1 Already have it Drop the duplicate packet Macquarie University - Data Communications 58 TCP Reliability THERE’S A LOT OF WAISTED TIME… THOUGHTS? Notice in this time, we’ve only sent two segments between A and B… can we do better? A B Send packet 1 Wait for ACK 1 Receive packet 1 Send ACK 1 Time Receive ACK 1 Send packet 2 Wait for ACK 2 Receive packet 2 Send ACK 2 Receive ACK 2 Macquarie University - Data Communications 59 TCP Reliability THERE’S A LOT OF WAISTED TIME… THOUGHTS? Notice in this time, we’ve only sent two segments between A and B… can we do better? A Send packet 1 Set Timer 1 Send packet 2 Set Timer 2 There are many other optimisations that can be applied, but you don’t need to know this for COMP2250! Send packet 3 Set Timer 3 Macquarie University - Data Communications Receive ACK 1 Receive ACK 2 Receive packet 1 Send ACK 1 Receive packet 2 Time Refinement: “Sliding Window” The idea of “sliding window” is that as the packets are received, the “window” of packets being transmitted changes. B Send ACK 2 Receive packet 3 Send ACK 3 Receive ACK 3 60 TCP Reliability PACKETS ARRIVED OUT OF ORDER? EASY! B receives the packets out of order… A Easy! Just re order the packets when assembling them before passing up to the Application layer. Send packet 1 Set Timer 1 This is where the “sequence number” helps in assembling the data to be passed up to the application layer. Send packet 2 Set Timer 2 B Send packet 2 Set Timer 2 Receive ACK 1 Send ACK 2 Receive packet 1 Time Receive ACK 2 Receive packet 2 Send ACK 1 Receive packet 3 Send ACK 3 Receive ACK 3 Macquarie University - Data Communications 61 TCP and Reliability SUMMARY - HELPS TO MAKE THE UNDERLYING NETWORK “RELIABLE” Assign sequence number to each segment transmitted. An acknowledgment from the receiver confirms data was received correctly. For each packet received undamaged, the receiving entity must return an acknowledgment (ACK) Sender retransmits if acknowledgment not returned within reasonable time period (timeout) What is reasonable time? This might need to be dynamically calculated based on: Network traffic Round trip timing estimates, … Recent changes in network traffic / routes / … Macquarie University - Data Communications 62 Segmentation Overview FROM THE APPLICATION LAYER’S PERSPECTIVE We send a stream of bytes representing the entirety of the conversation between the client and the server. (Think of it like an array of bytes). BUT, for a reasonably large stream, we can’t fit it all in one datagram (IP packet). So we need a way to break the stream into chunks that will fit into the maximum packet size of the lower layers (IP Layer and also the Data Link Layer) This sounds a little bit like fragmentation… but the difference is that fragmentation is about what can fit over a link (largest packet that can go over a single link), whereas, segmentation is about what can fit end-to-end. The TCP segment size (what can fit inside a TCP payload) will be determined by the largest payload that the network and data-link layers can support. Macquarie University - Data Communications 64 Segmentation Example MTU (Maximum Transmission Unit) of Ethernet is typically 1500 bytes. - IPv4 header is 20 bytes - TCP header is 20 bytes MSS (Maximum Segment Size) = 1500 - 20 - 20 = 1460 bytes. This is usually the MSS on a local area network. But of course, the MSS can vary depending on the Data-Link technology used (other layer 2 technologies will have different MTUs). Macquarie University - Data Communications 65 Transport Layer SEGMENTATION AND RECONSTRUCTION Let’s think about a http response packet being managed at the transport layer by TCP. Note UDP doesn’t do this… An application wants to send some data [HTTP header[response data]] TCP will go through and “break it up” into multiple segments… but there needs also needs some header information for TCP so the destination knows what “order” to assemble them and pass up to the upper layers. Macquarie University - Data Communications 66 Transport Layer SEGMENTATION AND RECONSTRUCTION Once we’ve done this (and some other things in the transport layer headers for each segment), then we can pass each of these segments down to the network layer and beyond… Macquarie University - Data Communications 67 So… in a nutshell TCP IN THE BROADER PICTURE Application layer sees message as a single block of data TCP puts them back together at the destination (reassembly) and then passes up to the application layer TCP breaks large message into smaller pieces (packetisation) What size packet to use? Done through negotiations. sender FTP FTP TCP TCP IP IP receiver Packets are transmitted to the receiver. Then once all the parts are assembled on the other end, they are passed up to the application layer for further processing / other actions done at the application layer Macquarie University - Data Communications 68 Sequence and Acknowledgement Numbers Sequence Numbers HOW CAN WE USE THEM? [16 bits | 16 bits | 32 bits | 32 bits | 4 bits | 6 bits | 6 * 1 bits | 16 bits | 16 bits | 16 bits | 32 bits] = 192 bits (24 bytes) Source Port - 16 bits Destination Port - 16 bits Sequence Number - 32 bits Acknowledgement Number - 32 bits Header Length - 4 bits Reserved - 6 bits 6 flags (each flag is 1 bit) - 6 bits TCP Checksum - 16 bits (to make sure no errors during transmission) Window Size - 16 bits Urgent Pointer - 16 bits TCP Options - 32 bits (optional) Sequence number starts with random number established by SYN Each TCP segment after this one is an OFFSET in bytes + the original SYN Macquarie University - Data Communications 70 Acknowledgement Numbers HOW CAN WE USE THEM? [16 bits | 16 bits | 32 bits | 32 bits | 4 bits | 6 bits | 6 * 1 bits | 16 bits | 16 bits | 16 bits | 32 bits] = 192 bits (24 bytes) Source Port - 16 bits Destination Port - 16 bits Sequence Number - 32 bits Acknowledgement Number - 32 bits Header Length - 4 bits Reserved - 6 bits 6 flags (each flag is 1 bit) - 6 bits TCP Checksum - 16 bits (to make sure no errors during transmission) Window Size - 16 bits Urgent Pointer - 16 bits TCP Options - 32 bits (optional) An acknowledgement number is the byte sequence number of the next segment the recipient expects to receive The ACK number is the the next offset from the beginning of the stream that is expected to be received by the receiver. …. ACK can also be used to acknowledge more than one segment… Macquarie University - Data Communications 71 Acknowledgment Numbers WE HAVEN’T TOLD YOU THE WHOLE STORY… We chose random payload sizes for the example to help outline what seq and ack numbers are The ACK number is the the next offset A from the beginning of the stream that Send chunk SEQ# 1 is expected to be received by the Bytes 0 to 109 Set Timer 1 receiver. B Send chunk SEQ#110 Bytes 110 to 234 Set Timer 2 Receive chunk SEQ# 1 Acknowledgments are an “offset” of Send chunk SEQ# 235 the number of bytes. Bytes 235 to 346 Send ACK 110 Receive chunk SEQ# 110 Set Timer 3 An Acknowledgement only needs toSend chunk SEQ# 347 Bytes 347 to 803 Set Timer 4 be the “next expected byte offset” Receive ACK 235 Let’s see this in action using a sliding window example Macquarie University - Data Communications Time Receive ACK 110 Send ACK 235 Receive chunk SEQ# 235 Receive chunk SEQ# 347 Send ACK 804 Receive ACK 804 72 Acknowledgment Numbers WE HAVEN’T TOLD YOU THE WHOLE STORY… Segment 1 = some random 32 bit A number selected during the 3 way chunk SEQ# 0 handshake. For here, we’ll use 0 as Send Bytes 0 to 109 the index of the first byte, but in reality, Set Timer 1 it will be the 32 bit number. All other numbers are then calculated from that sequence number. B Receive chunk SEQ# 0 Time Macquarie University - Data Communications 73 Acknowledgment Numbers WE HAVEN’T TOLD YOU THE WHOLE STORY… B receives the first segment and then A sends an acknowledgement number SEQ# 0 indicating it is ready to receive byte Send chunk Bytes 0 to 109 Set Timer 1 offset 110 B Send chunk SEQ#110 Bytes 110 to 234 Set Timer 2 Receive chunk SEQ# 0 Send ACK 110 Time Macquarie University - Data Communications 74 Acknowledgment Numbers WE HAVEN’T TOLD YOU THE WHOLE STORY… … A B Send chunk SEQ# 0 Bytes 0 to 109 Set Timer 1 Send chunk SEQ#110 Bytes 110 to 234 Set Timer 2 Receive chunk SEQ# 0 Send ACK 110 Receive chunk SEQ# 110 Macquarie University - Data Communications Time Receive ACK 110 75 Acknowledgment Numbers WE HAVEN’T TOLD YOU THE WHOLE STORY… … A B Send chunk SEQ# 0 Bytes 0 to 109 Set Timer 1 Send chunk SEQ#110 Bytes 110 to 234 Set Timer 2 Receive chunk SEQ# 0 Send ACK 110 Send chunk SEQ# 235 Bytes 235 to 346 Set Timer 3 Macquarie University - Data Communications Time Receive ACK 110 Receive chunk SEQ# 110 Send ACK 235 Receive chunk SEQ# 235 76 Acknowledgment Numbers WE HAVEN’T TOLD YOU THE WHOLE STORY… At this point here, we’ve acknowledged up to byte 235… but we’ve since received and validated 2 more TCP segments… A B Send chunk SEQ# 0 Bytes 0 to 109 Set Timer 1 Send chunk SEQ#110 Bytes 110 to 234 Set Timer 2 Receive chunk SEQ# 0 Send ACK 110 Send chunk SEQ# 235 Bytes 235 to 346 Set Timer 3 Send chunk SEQ# 347 Bytes 347 to 803 Set Timer 4 What should B send back as an acknowledgment number now? Macquarie University - Data Communications Receive ACK 235 Time Receive ACK 110 Receive chunk SEQ# 110 Send ACK 235 Receive chunk SEQ# 235 Receive chunk SEQ# 347 Send ??????? 77 Acknowledgment Numbers WE HAVEN’T TOLD YOU THE WHOLE STORY… We can just acknowledge BOTH the A seq # 235 and the SEQ# 347 chunks SEQ# 0 by just sending an ACK of the next Send chunk Bytes 0 to 109 Set Timer 1 byte we expect to receive (in this Send chunk SEQ#110 case, 804) Bytes 110 to 234 B Receive chunk SEQ# 0 Set Timer 2 Send ACK 110 Send chunk SEQ# 235 Bytes 235 to 346 Set Timer 3 Send chunk SEQ# 347 Bytes 347 to 803 Set Timer 4 Receive ACK 235 Time Receive ACK 110 Receive chunk SEQ# 110 Send ACK 235 Receive chunk SEQ# 235 Receive chunk SEQ# 347 Send ACK 804 Receive ACK 804 Macquarie University - Data Communications 78 TCP Flags WHAT DO THE SIX FLAGS DO? What we are looking at in TCP WHAT’S IN A TCP SEGMENT? [16 bits | 16 bits | 32 bits | 32 bits | 4 bits | 6 bits | 6 * 1 bits | 16 bits | 16 bits | 16 bits | 32 bits] = 192 bits (24 bytes) Source Port - 16 bits Destination Port - 16 bits Sequence Number - 32 bits Acknowledgement Number - 32 bits Header Length - 4 bits Reserved - 6 bits 6 flags (each flag is 1 bit) - 6 bits TCP Checksum - 16 bits (to make sure no errors during transmission) Window Size - 16 bits Urgent Pointer - 16 bits TCP Options - 32 bits (optional) Macquarie University - Data Communications Flag Bit Meaning when = 1 URG Urgent data delivery ACK Acknowledgement packet PSH Request a push RST Reset connection SYN Synchronize sequence numbers FIN Sender has reached end of byte stream 80 6 flags in TCP segment WHAT DO THEY DO? Each flag is either set to 1 or set to 0 depending on if the flag is activated. Below are the details for what happens if each flag is activated (set to 1). Flag Bit Meaning when = 1 More detail When the destination receives this segment, forward it to the application layer even if more segments are on the way. URG Urgent data delivery If this is set to 1, then If URG flag is set to 1, then this 16-bit “urgent pointer” field contains an offset from the sequence number. ACK Acknowledgement packet Validate the acknowledgement number in this segment PSH Request a push “Send immediately, even if the buffer isn't full” RST Reset connection “Let’s reset the connection, as there appears to be some confusion with out sequence numbers” SYN Synchronize sequence numbers Used to indicate the sequence number should be synchronised FIN Sender has reached end of byte stream Nothing more to send! Macquarie University - Data Communications 81 Big Ideas from today WHAT HAVE WE BEEN FOCUSING ON? 1.TCP Comparisons with UDP What is segmentation? Describe the SYN, SYN/ACK, ACK 3-way handshake Describe the way to end a TCP session How do the SYN and ACK numbers get calculated? What do they represent? What are the 6 flags in the TCP header? What do they represent? Macquarie University - Data Communications 82 Module 2: Putting this all together WHAT HAVE WE COVERED? A reminder of addressing schemes WHAT IS USED AT EACH OF THE LOWER LAYERS? Layer Address Kind Computer Representation Human Representation Application Application Dependent HTTP - URLs String String Transport [Layer 4] Port - destination application 16 bit field Number 0-65,535 24 IPv4 32 bit field 4 decimals 0-255 134.57.33.2 IPv6 128 bit field 8x4 hex digits 4534:4EF3:4AFD:A43F:4567:E34F:236B:453F Data Link [Layer 2] MAC address (Ethernet) 48 bit field (6 bits) 6x2 hex digits AE:56:23:F4:65:D3 Physical [Layer 1] Bits put in one end come out the N/A other! N/A Bits are broadcast on link, i.e.., flood. Example … IP Address Network [Layer 3] Macquarie University - Data Communications 84 Sending a message CONSIDER A MESSAGE TRAVERSING THIS SETUP… Macquarie University - Data Communications 85 Sending a message If I were to look at a packet going from The Macquarie Uni Lab PC to the Web Server, how would the message (and headers wrapped around it) change as it goes between different network devices? Note, we are not doing any network address translation (NAT) yet inside networks. Looking at the message (and headers it is wrapped in) while traversing along link 1: Transport layer: Source and destination port are defined depending on the service required and ports available. Network Layer: Source IP (lab pc) and Destination IP (server). Data Link Layer: Source Mac Address (Lab PC interface 11 Mac address) and destination Mac address (Macquarie Uni Router interface 21 Mac address). What about the message when it is traversing links 6, 7, or 8? What stays the same and what changes? Macquarie University - Data Communications 86 Sending a message If I were to look at a packet going from The Macquarie Uni Lab PC to the Web Server, how would the message (and headers wrapped around it) change as it goes between different network devices? Note, we are not doing any network address translation (NAT) yet inside networks. Looking at the message (and headers it is wrapped in) while traversing along link 2: Transport layer: Source and destination port are defined depending on the service required and ports available. Network Layer: Source IP (lab pc) and Destination IP (server). Data Link Layer: Source Mac Address (Lab PC interface 11 Mac address) and destination Mac address (Macquarie Uni Router interface 21 Mac address). What about the message when it is traversing links 6, 7, or 8? What stays the same and what changes? Macquarie University - Data Communications 87 Sending a message If I were to look at a packet going from The Macquarie Uni Lab PC to the Web Server, how would the message (and headers wrapped around it) change as it goes between different network devices? Note, we are not doing any network address translation (NAT) yet inside networks. Looking at the message (and headers it is wrapped in) while traversing along link 3: Transport layer: Source and destination port are defined depending on the service required and ports available. Network Layer: Source IP (lab pc) and Destination IP (server). Data Link Layer: Source Mac Address (Macquarie Uni Router interface 31 Mac address) and destination Mac address (AARNET Router interface 32 Mac address) What about the message when it is traversing links 6, 7, or 8? What stays the same and what changes? Remember your workshop in week 2? Source and destination Mac address? Have a look over that submission again and see if things are clicking now Macquarie University - Data Communications 88 COMP2250 context THERE ARE A FEW DETAILS WE HAVE NOT COVERED We’ve given you a look at the upper layers to give you enough context to understand how one process on one network-attached device can talk with another process on another network-attached device. There are MANY “what if” scenarios, improvements, refinements, and deeper concepts that the third year networking units cover. For this unit, we want you to be able to: ✅ ULO1: Explain the importance and the role of network protocols including why they are organised into protocol stacks and how protocol stacks function. ✅ ULO2: Demonstrate an understanding of IP addressing, routing and subnetting by for example computing routing outcomes and determining effective and actual IP addresses. ULO3: Differentiate among LAN components, and describe and, in particular instances calculate, how MAC addresses, address resolution and the ethernet protocol interact. ULO4: Evaluate different network designs based on an awareness of different major network technologies including wireless, backbone, wide area networks, and the Internet ULO5: Demonstrate technical networking proficiency including ability to configure, construct, and document, and in simple cases, design networks, as well as the ability to perform traffic analysis on local area networks. ULO6: Develop plans for dealing with network security and management. Macquarie University - Data Communications 89

Use Quizgecko on...
Browser
Browser