1.23k likes | 1.57k Vues
Networking. Transport Layer. Networking – Transport Layer. The Transport Layer is part of the Internet Protocol stack The Transport Layer sits between the Application Layer and the Network Layer The Transport Layer provides communication services to the application processes in a network.
E N D
Networking Transport Layer
Networking – Transport Layer • The Transport Layer is part of the Internet Protocol stack • The Transport Layer sits between the Application Layer and the Network Layer • The Transport Layer provides communication services to the application processes in a network
Networking – Transport Layer • Main properties of Transport Layer • Provides logical (not physical) connection between processes • Implemented in end system (processes), not in e.g. routers • The data unit at the Transport Layer level is a segment, not a full message • Two common Transport layer protocls are TCP and UDP
Networking – Transport Layer • Transport Layer vs. Network Layer • Transport Layer transports data between processes running of different hosts • Network Layer transports data between hosts • A Transport Layer protocol can offer services that the underlying Network Layer protocol does not offer
Networking – Transport Layer • Multiplexing/demultiplexing Transport Layer Network Layer
Networking – Transport Layer • Multiplexing/demultiplexing • How does it work in the letter analogy? Source person Jim Carpenter High Road 112 2209 Smallville Sue Miller School Street 207 8865 Silvertown A stamp… Source location Destinationperson Destinationlocation
Networking – Transport Layer • Multiplexing/demultiplexing • Remember • A host is specified by its IP address • A process is specified by its port number Transport Layer segment
Networking – Transport Layer • Client side process • ”I run on port 55” • ”I wish to talk to a server running on port 23” • Remember IP address of client host is also included in the segment (at IP level) 55 23
Networking – Transport Layer • Server side process • ”I run on port 23” • ”I wish to reply to the client running on port 55” 23 55
Networking – Transport Layer • What if two different clients – running on different hosts – use the same port number (for different processes)? • No problem, since the two hosts will have different IP addresses! • It is the combination of IP address and port number that must be unique (just as name and address for a plain letter…)
Networking – Transport Layer • Specific Transport Layer protocols – UDP • UDP – User Datagram Protocol • In the context of the Internet Protocol Stack, it is built on top the IP Network Protocol • Adds just two ”services” to the IP protocol • Multiplexing/demultiplexing • Lightweight data validation
Networking – Transport Layer • Multiplexing/demultiplexing is done using the source and destination port numbers, as explained previously • Length field specifies the length (in bytes) of the actual data • Checksum field is used for data validation
Networking – Transport Layer • Data validation uses a so-called checksum calculation • Data is binary – consists of 0s and 1s (bits) • Binary numbers can be added together, just as decimal numbers
Networking – Transport Layer • Adding two 16-bit binary numbers also produces a 16-bit binary number • All the 16-bit ”words” in the data fields are added together, producing a single 16-bit binary number • The 16-bit binary number in the checksum field is now chosen in a clever way…
Networking – Transport Layer 0100101011011101 + (16-bit checksum) 1111111111111111
Networking – Transport Layer • This is 1-complement checksum • If we add… • All the 16-words of the data field, plus • The 16-bit checksum • …we always get 1111111111111111
Networking – Transport Layer • Server side • Given the data, calculate the corresponding checksum • Put the checksum in the checksum field • Send to client • Clientside • Receive from server • Add up all data and the chekcsum • If the result is not 1111111111111111, we have discovered an error!
Networking – Transport Layer • How does UDP handle a data error…? • Some UDP implementations simply throw away damaged segments • Other deliver them to the application, with an indicating that the data is damaged • Higher-level error handling must be done by the receiving application!
Networking – Transport Layer • Specific Transport Layer protocols – TCP • TCP – Transmission Control Protocol • In the context of the Internet Protocol Stack, it is built on top the IP Network Protocol • TCP adds significant non-trivial services to the IP protocol!
Networking – Transport Layer • Main TCP features • Reliable data transfer – data is guaranteed to arrive without errors, and in the correct order • Flow control – match the transmission speed of sender and receiver • Congestion control – makes sure that no single connection is allowed to flood the network with data traffic (a benefit for the Internet as a whole, not so much for the individual connection…)
Networking – Transport Layer • How can you implement ”reliable data transfer”? • A complex task! • Not only at the Transport Layer level, but also at the ”deeper” levels • We will explore the problem in general
Networking – Transport Layer • Abstract look at data transfer: Application Layer Sender Reliable channel Receiver Reliable! Data Transport Layer
Networking – Transport Layer • Data transfer seen from the Transport Layer: Transport Layer Sender Unreliable channel Receiver Reliable! Data Network Layer
Networking – Transport Layer • Levels of unreliability • Level 0 - perfect reliability (no loss of data packets, no errors in data packets) • Level 1 - partial reliability (no loss of data packets, possible errors in data packets) • Level 2 – no reliability (possible loss of data packets, possible errors in data packets)
Networking – Transport Layer • Level 0 – perfect reliability • Essentially trivial to implement • Data from the Application Layer is divided into segments, headers are added, and data is sent • Similarly, data is extracted on the server side, and handed to the Application Layer
Networking – Transport Layer • Level 1 – Partial reliability • Packets are guaranteed to arrive at their destination… • …but the content of a packets may be damaged • We need a mechanism for retransmission of a damaged packet
Networking – Transport Layer • Main steps involved • Checking whether or not (the data in) a packet is damaged • Informing the sender of the packet whether or not the received packet was intact • Known as an ARQ protocol (Automatic Repeat reQuest)
Networking – Transport Layer • Error detection • We already saw an example (1-complement checksum) • More sophisticated techniques exist (error detection and correction) • Exact technique not important here • All techniques require sending extra data
Networking – Transport Layer • Receiver feedback • Receiver must provide explicit feedback to the sender, about the successful/failed outcome of receiving a packet • Receiver sends a packet back to sender • ACK (acknowledge) packet – all went well • NAK (not acknowledge) packet - failure
Networking – Transport Layer • Step 1: Send data packet n from Sender to Receiver Receiver Sender Data (n)
Networking – Transport Layer • Step 2a: Receiver finds data to be OK Receiver Sender Data (n)
Networking – Transport Layer • Step 3a: Receiver sends ACK packet to Sender Receiver Sender ACK
Networking – Transport Layer • Step 4a: Receiver gets ACK packet Receiver Sender ACK
Networking – Transport Layer • Step 1 (again): Send next piece of data from Sender to Receiver Receiver Sender Data (n+1)
Networking – Transport Layer • Step 2b: Receiver finds data to be damaged Receiver Sender Data (n)
Networking – Transport Layer • Step 3b: Receiver sends NAK packet to Sender Receiver Sender NAK
Networking – Transport Layer • Step 4b: Receiver gets NAK packet Receiver Sender NAK
Networking – Transport Layer • Step 1 (again): Send same piece of data from Sender to Receiver Receiver Sender Data (n)
Networking – Transport Layer • Packets are sent in order • Next packet is not sent before the current packet has been correctly received (a stop-and-wait protocol) • Sender thus always knows which data a ACK/NAK packet refers to
Networking – Transport Layer • Can anything go wrong…? • Data packet keeps getting damaged…at some point we must give up (timeout) • The ACK/NAK packets themselves could also become damaged!
Networking – Transport Layer • Possible solutions • Introduce ”acknowledge to acknowledge” packets – hard to decide when to stop… • Better error correction – can only partially solve the problem • Assume the worst – only consider a correctly received ACK packet as meaning ”acknowledge”. Everything else is interpreted as NAK
Networking – Transport Layer • Problematic scenario • Receiver receives data, and confirms it to be OK • Receiver sends ACK to Sender • Sender receives a damaged packet, and interprets this as a NAK (”assume the worst”) • Sender thus decides to to resend data • Receiver gets data. Data is OK, BUT is it • Resent data, or • New data?
Networking – Transport Layer • To resolve the problem, we intro-duce a data packet sequence number • All data packets are marked with an incremental sequence number • Receiver keeps track of the sequence number of the last correctly received package
Networking – Transport Layer • Step 1: Send data packet n from Sender to Receiver Receiver Sender Data (n)
Networking – Transport Layer • Step 2: Receiver finds data to be OK Receiver Sender Data (n)
Networking – Transport Layer • Step 3: Receiver sends ACK packet to Sender, and remembers sequence number n Receiver Sender ACK
Networking – Transport Layer • Step 4: Receiver gets damaged ACK packet n Receiver Sender !C¤
Networking – Transport Layer • Step 5: Resend data packet n from Sender to Receiver n Receiver Sender Data (n)
Networking – Transport Layer • Step 6: Receiver looks at sequence number, and discovers that this is resent data n Receiver Sender Data (n)