Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Janice Regan, CMPT 128, 2007-2012 CMPT 371 Data Communications and Networking Principles of reliable data transfer 0.

Similar presentations


Presentation on theme: "© Janice Regan, CMPT 128, 2007-2012 CMPT 371 Data Communications and Networking Principles of reliable data transfer 0."— Presentation transcript:

1 © Janice Regan, CMPT 128, 2007-2012 CMPT 371 Data Communications and Networking Principles of reliable data transfer 0

2 Transport Layer  Common protocols TCP and UDP  UDP is best effort, no reliable delivery  TCP insures reliable delivery  Remember the Transport layer is above a network layer that does provides an unreliable transmission channel (when IP is used)  TCP must compensate for the underlying unreliable channel to provide reliable transmission. This makes TCP much more complicated Janice Regan © Sept 2007-2012 1

3 Delivery  No flow control (UDP, best effort transmission):  Send data and hope receiver can process fast enough or buffer (with no overruns) Packets are lost when queues/buffers overrun.  Slowing send speed enough to ensure reception will reduce utilization (efficiency) of the link  Flow control (TCP, reliable delivery)  TCP manages how fast packets are sent so that packet do not Arrive faster than they can be processed Overrun buffers / overwrite data Janice Regan © Sept 2007-2012 2

4 3 The transport layer  Processes use a transport protocol to communicate end to end. (reliably using TCP or best effort using UDP)  Data-link and network layer protocols communicate hop by hop, forming a communications channel for the transport layer  The transport layer shields the application processes from the details of the underlying communications channel  The transport layer specifies a particular application process as the source or destination. Lower layers specify at most the protocol in the next layer up Janice Regan © Sept 2007-2012

5 4 Transport layer protocols  Provide a logical (conceptual) link directly from the source to the receiver.  Applications using the transport layer interface see transport layer services that appear to connect them directly with applications on the destination host  The transport layer uses an interface to the network layer to initiate the physical transfer from host to host through the network to the destination. The details of these host to host transfers are not part of the transport layer.  The transport layer segments pass through multiple hosts on the way to the destination but the transport layer itself need not be directly aware of this since it is handled by lower layers in the protocol stack. Janice Regan © Sept 2007-2012

6 Using a relay (router) Janice Regan © Sept. 2007-2012 5 Physical Data link network transport application Network Data link Physical Data link network transport application

7 6 Relay through intermediate hosts  As the packet travels from the source to the destination it will be processed by intermediate hosts.  Intermediate hosts may be other systems (computers) that use a full protocol stack Only some layers in the stack will be used to relay the packet to its next destination along its path to the destination The transport and application layers will be used only for packets who originate or are destined for the host Janice Regan © Sept 2007-2012

8 Using a relay (switch) Janice Regan © Sept. 2007-2012 7 Physical Data link network transport application Data link Physical Data link network transport application

9 8 Relay through intermediate hosts  As the packet travels from the source to the destination it will be processed by intermediate hosts.  Intermediate hosts may be routers, switches, or hubs Such devices will have only a partial protocol stack (only the layers needed to relay the packet) Routers and network level switches will include the network layer and all layers below it. Link layer switches and hubs will include only the link and physical layers Janice Regan © Sept 2007-2012

10 9 Transport layer protocols  May provide best effort delivery of packets (UDP)  Application accepts responsibility for reliability, connectionless  May provide a connection oriented reliable communication channel (TCP) either  On top of a best effort packet switched network (IP with unacknowledged connectionless link layer)  On top of a reliable network service (IP with acknowledged connectionless services in link layer) Janice Regan © Sept 2007-2012

11 10 Transport layer protocols  Support multiplexing  Combine multiple low rate flows through 1 port  Spread high rate flow between multiple ports Janice Regan © Sept 2007-2012

12 11 Responsibilities: transport level protocols  Addressing  Multiplexing  Flow control  Logical connection establishment  Logical connection maintenance  Logical connection termination  error control  ordered delivery to the application Connection oriented only Connection oriented and connectionless Janice Regan © Sept 2007-2012

13 12 Addressing  User specified by:  User identification Specify Host and Port (socket or communication endpoint in TCP or UDP) Port represents particular process or protocol, or a particular connection inside a process with more than one connection Host is specified by an IP address Several processes on a given machine may be multiplexed together and use a single protocol port Janice Regan © Sept 2007-2012

14 13 Addressing  Each port is identified by an integer usually one port for of each protocol type (HTTP, FTP …). Note that many of these ports will use TCP or UDP since many of the messages from application level protocols are transported using TCP or UDP Janice Regan © Sept 2007-2012

15 14 Responsibilities: transport layer protocols  Addressing  Multiplexing  Flow control (for TCP only, none for UDP)  Logical connection management (TCP only)  Error control If underlying network is best effort  Assure ordered delivery to the application if the underlying network is packet oriented Janice Regan © Sept 2007-2012

16 15 Multiplexing: application layer  Each connection is made between two sockets (communications endpoints) that each consist of a port:IP address pair. To describe the connection we need two port:IP address pairs.  Usually one port is used for of each application level protocol type on each host. So all segments for the particular application level protocol will pass through the same port (even if they are destined for different processes).  Determining which process (and connection within process) is done by the server for that process in the application layer of the host Janice Regan © Sept 2007-2012

17 16 Multiplexing: transport layer to application layer  Within the transport layer the UDP (or TCP) segments all arrive at the protocol process that processes UDP (or TCP) segments.  This process (part of the protocol stack) will demultiplex (separate) the TCP segments or UDP packets by port (protocol)  The segments or packets can then be sent to the correct server for the particular application level protocol. (sent through the correct port to the application layer) Janice Regan © Sept 2007-2012

18 17 Multiplexing: Janice Regan © Sept 2007-2012 Transport layer Application layer Network layer UDP process in protocol stack Protocol 3 Port C Application X Port B Protocol 1 Port A Arriving UDP packets are sent to the correct application or protocol implementation based on port #

19 18 Multiplexing: transport layer to application layer  Many application level protocols are transported using UDP (or TCP). When segments arrive in the transport layer by UDP (or TCP) the port number may indicate that contents of the segment are destined for a particular application protocol.  Usually one port is used for of each application level protocol type on each host. So all segments for the particular application level protocol will leave the transport layer through the same port Janice Regan © Sept 2007-2012

20 19 Finding Port Addresses: 1  Static configuration:  Know address ahead of time  Universal assignment:  Central authority (IANA) assigns port numbers to common protocols. The list is published  All software should use this list of protocols/ports  Any host receiving a particular application layer protocol will have a server process for that protocol running in its application layer. This server can be accessed through the assigned protocol port number  Ports 0-1023 are reserved for this IANA list  Ports 1024-49151 are registered (use list exists) not reserved Janice Regan © Sept 2007-2012

21 20 Finding Port Addresses: 2  Name server: Server on a well known port can be queried to determine the port for the particular application. Name servers are generally used for providing different kinds of directory service Janice Regan © Sept 2007-2012

22 21 Well Know port numbers Janice Regan © Sept 2007-2012

23 TCP server (Python) for socket import * serverPort = 1200 serverSocket = socket.socket(AF_INET, SOCK_STREAM) serverSocket.bind((‘ ‘,serverPort)) serverSocket.listen(1) print ‘The server is ready to receive’ while 1; connectionSocket.addr = serverSocket.accept() sentence = connetionSocket.recv(1024) capitalizedSentence = sentence.upper() connectionSocket.send(capitalizedSentence) connection Socket.close() : Janice Regan © 2007-2013 22

24 TCP client (Python) from socket import * serverName = ‘servername’ serverPort = 1200 clientSocket = socket.socket( AF_INET, SOCK_STREAM ) clientSocket.connect (serverName,serverPort) clientSocket.send (sentence) modifiedSentence = clientSocket.recv(1024) clientSocket.close; Janice Regan © 2007-2013 23

25 24 Sequential server:  Server on a well know port that will process one request at a time. Requests will be queued as they arrive at the server. Useful for applications with low CPU needs or infrequent usage  timeserver, just returns the present time, low cpu usage Janice Regan © Sept 2007-2012

26 25 Instance or threaded server  Connect to Server through a well know port  Server creates an instance of itself to service the request  Server returns the appropriate port for the client to attach to that instance.  Many instances created by the instance server may run simultaneously.  Useful for heavily used applications and applications with significant processing needs  One example: FTP server, each instance may run for a significant length of time if it transfers a large file Janice Regan © Sept 2007-2012

27 26 client1 Child server server Child server 206.168.112.219 12.106.32.254 *:21 *:* 12.106.32.254 :21 206.168.112.2.19.: 1500 12.106.32.254 :21 206.168.112.2.19.: 1501 client2 206.168.112.2.19.: 1501 12.106.32.254 :21 206.168.112.2.19.: 1500 12.106.32.254 :21 Ephemeral port 1500, or 1501 is assigned by the protocol’s software Janice Regan © Sept 2007-2012

28 27 Responsibilities: transport layer protocols  Addressing  Multiplexing  Flow control (for TCP only, none for UDP)  Logical connection management (TCP only)  Error control If underlying network is best effort  Assure ordered delivery to the application if the underlying network is packet oriented Janice Regan © Sept 2007-2012

29 28 Error control  Error control includes the list of rules that tell us what to do if a packet contains an error.  Can we correct the error If so correct the error and continue, otherwise  If the packet contains an error it should not be forwarded The error may be in the address, it may get to the wrong destination Janice Regan © Sept 2007-2012

30 29 Error control  Error control includes the list of rules that tell us what to do if a packet contains an error.  Should we request that the source host retransmit the packet so we can obtain a correct copy of the packet A good approach for reliable transport but not necessary for best effort transport may be more complicated than it first appears  Should we just drop the packet OK for best effort transport Janice Regan © Sept 2007-2012

31 30 Error detection  Before we can approach error control we need to know how to determine if there has been an error introduced into our packet during transmission  In the transport layer we use a checksum to determine if out packet contains errors.  The checksum is calculated at the source, and placed in the header of the packet  The packet is transmitted  The checksum is recalculated and compared with the checksum from inside the packet. If they match our packet usually does not contain errors. Janice Regan © Sept 2007-2012

32 31 Error detection  The mathematical theory behind the checksum allows us to assume that if the checksum is unchanged at the destination then the packet does not contain errors  a good assumption but in rare cases it can be false Janice Regan © Sept 2007-2012

33 Why Checksum in Transport layer  Error detection is used by Ethernet, in the data link layer, to check that packets are not corrupted as they travel between hosts  Other protocols in the data link layer may or may not use error detection  Therefore it is possible that some links are not error checked.  Also errors can occur after reception as when the packet is stored in the routers memory Janice Regan © Sept 2007-2012 32

34 33 Structure of a TCP packet Comer 2000: fig 13.7 SOURCE PORT DESTINATION PORT CHECKSUM Janice Regan © Sept 2007-2012

35 34 Structure of a UDP Packet Janice Regan © Sept 2007-2012

36 35 The pseudo header: UDP, TCP  The constructed pseudo header is prepended to the TCP segment or UDP datagram before the checksum is calculated  The pseudo header is used to check that the segment has arrived at the correct address on the correct connection  Protocol can be TCP (6) or UDP (17)  Length is the length of the TCP segment including the TCP header or the UDP packet including header Janice Regan © Sept 2007-2012

37 36 Header + Pseudoheader  The TCP or UDP Header is transmitted with the datagram. The Pseudo header is not transmitted.  The checksum is the ones complement sum of all the 16 bit words in the datagram (data header and pseudo header)  Information in the pseudo header is calculated from information in the header, and from the IP address of the source and receiver from the IP layer (encapsulation?) Janice Regan © Sept 2007-2012

38 37 CheckSum  The checksum for a TCP segment is calculated in the same manner as the checksum for a UDP packet  The fields in the TCP or UDP header and pseudo header are divided into 16 bit words. These 16 bit words start on all 16 bit boundaries in the pseudo header the header and the data  A ones complement sum of all the 16 bit words in the packet header, the data, and the packet pseudo header is calculated  While this sum is being calculated the contents of the checksum field in the TCP header is set to 0  The ones complement of the ones complement sum is inserted into the checksum field Janice Regan © Sept 2007-2012

39 38 the ones complement sum (1)  To find the ones complement sum of a series of binary numbers  Do a binary addition 1110 0011 1000 1110 0101 0101 0101 0101 10011 1000 1110 0011  Shift the sum 16 places to the right (gives 1 for this example) Janice Regan © Sept 2007-2012

40 39 the ones complement sum (2)  Add the shifted value (1 in this case) to the binary sum  10011100011100011 + 1 = 10011100011100100  Take the least significant 16 digits to give the ones complement sum 0011100011100100  The ones complement of this ones complement sum is the checksum 1100011100011011 Janice Regan © Sept 2007-2012


Download ppt "© Janice Regan, CMPT 128, 2007-2012 CMPT 371 Data Communications and Networking Principles of reliable data transfer 0."

Similar presentations


Ads by Google