Module 6 - The Transport Layer PDF
Document Details
Uploaded by Deleted User
SAMCIS
Tags
Summary
This document provides an overview of the Transport Layer in computer networking, including its role, services, and protocols such as TCP and UDP. It also touches upon related topics such as sockets.
Full Transcript
The Transport Layer Module 6 IT & CS Departments - SAMCIS Short Term AY 2022 - 2023 Module 6 Topic Learning Outcomes De ne the main function of the Transport Layer De ne design issues of the Transport Layer fi fi Role of the Transport Layer TL is the heart of the protocol...
The Transport Layer Module 6 IT & CS Departments - SAMCIS Short Term AY 2022 - 2023 Module 6 Topic Learning Outcomes De ne the main function of the Transport Layer De ne design issues of the Transport Layer fi fi Role of the Transport Layer TL is the heart of the protocol hierarchy. The network layer provides end-to-end packet delivery using datagrams or virtual circuits. The transport layer builds on the network layer to provide data transport from a process on a source machine to a process on a destination machine with a desired level of reliability that is independent of the physical networks cur- rently in use. It provides the abstractions that applications need to use the network. Without the transport layer, the whole concept of layered protocols would make little sense. Key Topics / Outline of Discussion Section A: Introduction to the TRANSPORT LAYER Section B: Socket Section C: Transmission Control Protocol Section D: User Datagram Protocol Introductory Concepts on the Transport Layer The transport layer is an end-to-end layer – this means that nodes within the subnet do not participate in transport layer protocols – only the end hosts. As with other layers, transport layer protocols send data as a sequence of packets (segments). Transport Layer: Multiplexing Services The network layer provides communication between two hosts. The transport layer provides communication between two processes running on di erent hosts. A process is an instance of a program that is running on a host. There may be multiple processes communicating between two hosts – for example, there could be a FTP session and a Telnet session between the same two hosts. ff Transport Layer: Multiplexing Services The transport layer provides a way to multiplex / demultiplex communication between various processes. To provide multiplexing, the transport layer adds an address to each segment indicating the source and destination processes. Note these addresses need only be unique locally on a given host. In TCP/IP these transport layer addresses are called port-numbers. The 5-tuple: (sending port, sending IP address, destination port, destination IP address, transport layer protocol) uniquely identi es a process-to-process connection in the Internet. fi Intro: TPDU Nesting of Transport Protocol Data Unit (TPDU), packets, and frames. Intro: Connection Establishment Intro: Transport Service Primitives Intro: Protocol Stacks Section B: SOCKET Software interface designed to communicate between the user program and TCP/IP protocol stack Implemented by a set of library function calls Socket is a data structure inside the program Both client and server programs communicate via a pair of sockets Socket Framework Socket Families There are several signi cant socket domain families: Internet Domain Sockets (AF_INET) - implemented via IP addresses and port numbers Unix Domain Sockets (AF_UNIX) - implemented via lenames (think “named pipe”) Novell IPX (AF_IPX) AppleTalk DDS (AF_APPLETALK) fi fi Type of Socket Stream (SOCK_STREAM) Uses TCP protocol. Connection-oriented service Datagram (SOCK_DGRAM) Uses UDP protocol. Connectionless service Raw (SOCK_RAW) Used for testing Creating a Socket #include #include int socket(int domain, int type, int protocol); domain is one of the Protocol Families (PF_INET, PF_UNIX, etc.) type de nes the communication protocol semantics, usually de nes either: –SOCK_STREAM: connection-oriented stream (TCP) –SOCK_DGRAM: connectionless, unreliable (UDP) protocol speci es a particular protocol, just set this to 0 to accept the default fi fi fi TCP Client/Server SERVER Create socket bind a port to the socket CLIENT listen for incoming Create socket connections accept an connect to server's incoming port connection read from the write to the connection connection loop loop write to the read from the connection connection close connection TCP Server & System Calls SEQUENCE OF SYSTEM CALLS EXECUTED: sock_init() Create the socket bind() Register port with the system listen() Establish client connection accept() Accept client connection read/write read/write data close() shutdown TCP Client & System Calls SEQUENCE OF SYSTEM CALLS EXECUTED: sock_init () Create socket connect() Set up connection write/read write/read data close() Shutdown Server Side Socket Details SERVER Create socket int socket(int domain, int type, int protocol) sockfd = socket(PF_INET, SOCK_STREAM, 0); bind a port to the int bind(int sockfd, struct sockaddr *server_addr, socklen_t length) socket bind(sockfd, &server, sizeof(server)); listen for incoming int listen( int sockfd, int num_queued_requests) connections listen( sockfd, 5); accept an incoming int accept(int sockfd, struct sockaddr *incoming_address, socklen_t length) connection newfd = accept(sockfd, &client, sizeof(client)); read from the int read(int sockfd, void * buffer, size_t buffer_size) connection read(newfd, buffer, sizeof(buffer)); write to the int write(int sockfd, void * buffer, size_t buffer_size) connection write(newfd, buffer, sizeof(buffer)); Server Side Socket Details CLIENT Create socket int socket(int domain, int type, int protocol) sockfd = socket(PF_INET, SOCK_STREAM, 0); connect to Server int connect(int sockfd, struct sockaddr *server_address, socklen_t length) socket connect(sockfd, &server, sizeof(server)); write to the int write(int sockfd, void * buffer, size_t buffer_size) connection write(sockfd, buffer, sizeof(buffer)); read from the int read(int sockfd, void * buffer, size_t buffer_size) connection read(sockfd, buffer, sizeof(buffer)); Section C: Transmission Control Protocol connection oriented. full duplex. TCP Services: Reliable transport Flow control Congestion control UDP does not provide any of these services TCP Services TCP converts the unreliable, best e ort service of IP into a reliable service, i.e., it ensures that each segment is delivered correctly, only once, and in order. Converting an unreliable connection into a reliable connection is basically the same problem we have considered at the data link layer, and essentially the same solution is used: TCP numbers each segment and uses an ARQ protocol to recover lost segments. Some versions of TCP implement Go Back N and other versions implement Selective Repeat. ff TCP Services However, there are a few important di erences between the transport layer and the data link layer. At the data link layer, we viewed an ARQ protocol as being operated between two nodes connected by a point-to-point link. At the transport layer, this protocol is implemented between two hosts connected over network. ff The TCP Header Sample TCP Packet TCP Connection Establishment Closing a TCP Connection Closing a TCP Connection(continuation…) The two-army problem. Symmetric release (Does it really work?) Who will be victorious? White Army or Blue Army? Four protocol scenarios for releasing a connection (a) Normal case of three-way handshake. (b) Final ACK lost. Four protocol scenarios for releasing a connection (c) Response lost. (d) Response lost and subsequent DRs lost. Section D: User Datagram Protocol Àn unreliable, connectionless; No TCP’s ow control; applications where prompt delivery more important than accurate delivery (speech, video, …) Metaphor: postal service fl UDP Datagram protocol it does not have to establish a connection to another machine before sending data. There is no way to guarantee that the packet will reach its destination. UDP Packet Basically all UDP provides is a multiplexing capability on top of IP. The length eld gives the length of the entire packet including the header. The checksum is calculated on the entire packet (and also on part of the IP header). Calculating the checksum is optional, and if an error is detected the packet may be discarded or may be passed on to the application with an error ag. fi fl End of Module 6