Presentation is loading. Please wait.

Presentation is loading. Please wait.

CEN 4500 Data Communications Instructor: S. Masoud Sadjadi sadjadi At cs Dot fiu Dot edu Chapter 6: The Transport.

Similar presentations


Presentation on theme: "CEN 4500 Data Communications Instructor: S. Masoud Sadjadi sadjadi At cs Dot fiu Dot edu Chapter 6: The Transport."— Presentation transcript:

1 CEN 4500 Data Communications Instructor: S. Masoud Sadjadi http://www.cs.fiu.edu/~sadjadi/Teaching/ sadjadi At cs Dot fiu Dot edu Chapter 6: The Transport Layer

2 CEN 4500, S. Masoud Sadjadi2 Recap: Transport Layer Transport layer is not just another layer. It is the heart of the whole protocol hierarchy. Its task is to provide reliable, cost-effective data transport from source machine to the destination machine (hence, end- to-end), independently of the physical network or networks currently in use. Accepts data from above, split it up into smaller units if need be, pass these to the network layer, and ensures that the pieces all arrive correctly at the other end.

3 CEN 4500, S. Masoud Sadjadi3 Agenda The Transport Service Elements of Transport Protocol A Simple Transport Protocol The Internet Transport Protocol: UDP The Internet Transport Protocol: TCP Performance Issues Summary

4 CEN 4500, S. Masoud Sadjadi4 The Transport Service Services Provided to the Upper Layers Transport Service Primitives Berkeley Sockets An Example of Socket Programming: –An Internet File Server

5 CEN 4500, S. Masoud Sadjadi5 Services Provided to the Upper Layers Goal –To provide efficient, reliable, and cost-effective service to its users, normally processes in the application layer. –To achieve this, transport layer makes use of the services provided by the network layer. –The hardware/software within the transport layer that does the work is called the transport entity. Can be located in the operating system kernel, in a separate user process, in a library package bound into network applications, or on the network interface card.

6 CEN 4500, S. Masoud Sadjadi6 Services Provided to the Upper Layers The network, transport, and application layers.

7 CEN 4500, S. Masoud Sadjadi7 Services Provided to the Upper Layers Similar to the type of services in the network layer, there are two types of transport services: –Connection-Oriented Service Connection establishment, data transfer, and release. Addressing, flow control, etc. –Connectionless Service Also very similar to NL. Then why two layers? What is the difference? –The transport code runs entirely on the users’ machines, but the network layer mostly runs on the routers, which are typically operated by one or more carriers.

8 CEN 4500, S. Masoud Sadjadi8 A stream of packets from sender to receiver. Services Provided to the Upper Layers Relation between hosts on LANs and the subnet.

9 CEN 4500, S. Masoud Sadjadi9 Services Provided to the Upper Layers The OSI reference model.

10 CEN 4500, S. Masoud Sadjadi10 Services Provided to the Upper Layers So, what happens if the network layer provide inadequate service? For example, what if the subnet loses packets frequently. –The users have no real control over the network layer, so they cannot solve the problem of poor service by using better routers or putting more error handling in the data link layer! –The only possibility is to put on top of the network layer another layer that improves the quality of the service according to the users’ preference.

11 CEN 4500, S. Masoud Sadjadi11 Services Provided to the Upper Layers Why do we need transport layer? (cont.) –The network service calls may vary considerably from network to network. –Transport layer provides a network independent layer by hiding the network service behind a set of transport service primitives. –This way, changing the network service merely requires replacing one set of library procedures by another one that basically does the same thing, but with a different underlying service. –Therefore, application programmers can write code according to a standard set of primitives and portable on variety of networks.

12 CEN 4500, S. Masoud Sadjadi12 Services Provided to the Upper Layers Revisiting the hybrid reference model The bottom four layers are transport service provider, whereas the upper layer(s) are the transport service user. Therefore, the transport layer forms the major boundary between the provider and user of the reliable data transmission service. transport service provider transport service user

13 CEN 4500, S. Masoud Sadjadi13 The Transport Service Services Provided to the Upper Layers Transport Service Primitives Berkeley Sockets An Example of Socket Programming: –An Internet File Server

14 CEN 4500, S. Masoud Sadjadi14 Transport Service Primitives To allow users to access the transport service, the transport layer must provide some operations to application programs –That is, a transport service interface. Types of services –Connection-oriented service –Connectionless service

15 CEN 4500, S. Masoud Sadjadi15 Transport Service Primitives Example: A Connection-Oriented Client-Server App. –Connection Establishment The server executes a LISTEN primitive –Typically by calling a library procedure that make a system call to block the server until a client turns up. When a client wants to talk to the server, it executes a CONNECT primitive. –The transport entity blocks the caller and sends a packet to the server. –A CONNECTION REQUEST TPDU is sent to the server. The primitives for a simple transport service.

16 CEN 4500, S. Masoud Sadjadi16 Transport Service Primitives The nesting of transport protocol data units (TPDUs), packets, and frames.

17 CEN 4500, S. Masoud Sadjadi17 Transport Service Primitives Example: A Client-Server Application (cont.) –Connection Establishment (cont. When the CONNECTION REQUEST TPDU arrives at the server transport entity, it checks to see if the server is blocked on a LISTEN. It then unblocks the server and sends a CONNECTION ACCEPTED TPDU back to the client. When the client transport entity receives this TPDU, it unblocks the client and the connection is now established. –Data Exchange Data can now be exchanged using the SEND and RECEIVE primitives. –Either party can do a (blocking) RECEIVE to wait for the other party to do a SEND –When the TPDU arrives, the receiver is unblocked and … –This works as long as the two sides can keep track of the turns. –Connection Termination When a connection is no longer needed, it must be released to free table space within the two transport entities.

18 CEN 4500, S. Masoud Sadjadi18 Transport Service Primitives Connection Termination Types –Asymmetric Either of the two transport user can issue a DISCONNECT primitive. This results in a DISCONNECT TPDU being sent Upon its arrival, the connection is released –Symmetric Each direction is closed separately (independently). When one side is disconnected, it does not mean that the other side has no more data to transmit. So, a connection is released when both side disconnect.

19 CEN 4500, S. Masoud Sadjadi19 Transport Service Primitives Transitions are caused either by primitive execution ( ) or by packet arrivals (labeled in italics, ). The solid lines show the client's state sequence. The dashed lines show the server's state sequence. A state diagram for a simple connection management scheme.

20 CEN 4500, S. Masoud Sadjadi20 The Transport Service Services Provided to the Upper Layers Transport Service Primitives Berkeley Sockets An Example of Socket Programming: –An Internet File Server

21 CEN 4500, S. Masoud Sadjadi21 Berkeley Sockets The socket primitives used in Berkeley UNIX for TCP.

22 CEN 4500, S. Masoud Sadjadi22 Berkeley Sockets Sever Side –The first four primitives in the list are executed in that order by servers. 1.The SOCKET primitive –creates a new end point and allocates table space for it within the transport entity. –The parameters of the call specify the addressing format to be used, the type of service desired, and the protocol. –A successful SOCKET call returns an ordinary file descriptor for use in succeeding calls 2.The BIND primitive –assigns a newly-created socket to a network address –The reason for doing the address binding through as separate call is that some servers want to used a predefined (fixed) address and some do not really care. 3.The LISTEN primitive –would allocate space to queue incoming calls for the case that several clients try to connect at the same time. –It is not a blocking call.

23 CEN 4500, S. Masoud Sadjadi23 Berkeley Sockets Sever Side (cont.) 4.The ACCEPT primitive –Blocks the server for an incoming connection –When a TPDU asking for a connection arrives, the transport entity creates a new socket with the same properties as the original one and returns a file descriptor for it. –The server can then fork off a process or thread to handle the connection on the new socket and go back to waiting for the next connection on the original socket. –ACCEPT returns a normal file descriptor, which can be used for reading and writing in the standard way, the same as for files. Client Side –First the SOCKET and then CONNECT (BIND not necessary). Server and Client –Use SEND/RECV to transmit/receive data (full-duplex conn.) Or use WRITE/READ, if none of the special options are required. –Use CLOSE for releasing the connection (symmetric).

24 CEN 4500, S. Masoud Sadjadi24 The Transport Service Services Provided to the Upper Layers Transport Service Primitives Berkeley Sockets An Example of Socket Programming: –An Internet File Server

25 CEN 4500, S. Masoud Sadjadi25 Socket Programming Example: Internet File Server Client code using sockets. Command line: > cc –o client client.c –lsocket > client goliath.cs.fiu.edu \ /usr/sadjadi/passworkFile.txt > HeHeHe

26 CEN 4500, S. Masoud Sadjadi26 Socket Programming Example: Internet File Server (2) Server code using sockets. Command line: > cc –o server server.c –lsocket –lnsl > Server

27 CEN 4500, S. Masoud Sadjadi27 Agenda The Transport Service Elements of Transport Protocol A Simple Transport Protocol The Internet Transport Protocol: UDP The Internet Transport Protocol: TCP Performance Issues Summary

28 CEN 4500, S. Masoud Sadjadi28 Elements of Transport Protocols The transport service is implemented by a transport protocol used between the two transport entities. –It resembles the data link protocols –Both have to deal with error control, sequencing, and flow control, among other issues. What is the difference with the data link? –At the data link layer, two routers communicate directly via a physical channel. –At the transport layer, the physical channel is replaced by the entire subnet.

29 CEN 4500, S. Masoud Sadjadi29 Transport Protocol (a) Environment of the data link layer. (b) Environment of the transport layer.

30 CEN 4500, S. Masoud Sadjadi30 Elements of Transport Protocols What is the difference with the data link? 1.Addressing –Data link layer: it is not necessary for a router to specify which router it wants to talk to—each outgoing line uniquely specifies a particular router. –Transport layer: explicit addressing of destinations is required. 2.Connection Establishment –Data link layer: The process is simple as the other end is either always there or it is crashed! –Transport layer: Initial connection establishment is much more complicated. 3.Storage in the Subnet –Data link layer: When a router sends a packet, it may arrive or be lost, but it cannot bounce around for a while. –Transport layer: If the subnet uses datagrams and adaptive routing inside, there is a non-negligible probability that a packet may be stored for a number of seconds and then delivered later. 4.Flow Control and Buffering –Data link layer: required in both layers. –Transport layer: Presence of a large and dynamically varying number of connections.

31 CEN 4500, S. Masoud Sadjadi31 Elements of Transport Protocols Addressing Connection Establishment Connection Release Flow Control and Buffering Multiplexing

32 CEN 4500, S. Masoud Sadjadi32 Addressing When an application process wishes to set up a connection to a remote application process, it must specify which one to connect to. –The problem exists for a connectionless transport as it needs to know which process the messages should be delivered to. –The method normally used is to define transport addresses to which processes can listen for connection requests. –In the Internet, these end points are called ports. –The generic term is Transport Service Access Point (TSAP) for transport layer addresses and NSAP for network addresses. –This way, two or more processes using the same NSAP can be distinguished through TSAP.

33 CEN 4500, S. Masoud Sadjadi33 Addressing TSAPs, NSAPs and transport connections.

34 CEN 4500, S. Masoud Sadjadi34 Addressing Initial Connection Protocol –Problem: Assume that there are many server processes and most of which are rarely used; therefore, it is wasteful of resources to have each of them active and listening to a stable TSAP address all the time. –Solution: A special process server that acts as a proxy for less heavily used servers that receives all connections requests that no server is waiting for them. This process server spawns the requested server and allows it to inherit the existing connection with the user.

35 CEN 4500, S. Masoud Sadjadi35 Addressing How a user process in host 1 establishes a connection with a time-of-day server in host 2.

36 CEN 4500, S. Masoud Sadjadi36 Elements of Transport Protocols Addressing Connection Establishment Connection Release Flow Control and Buffering Multiplexing

37 CEN 4500, S. Masoud Sadjadi37 Connection Establishment Connection establishment is not as easy as it sounds! –If the network can lose, store, and duplicate packets, then we have a problem! –Example A user establishes a connection with a bank Sends a message to the bank asking to transfer a large amount of money to the account of a not-entirely- trustworthy person Then the user releases the connection. Assume that each packet is duplicated and stored in the subnet –The duplicate packets pop up in the bank with the right order!

38 CEN 4500, S. Masoud Sadjadi38 Connection Establishment (a) TPDUs may not enter the forbidden region. (b) The resynchronization problem.

39 CEN 4500, S. Masoud Sadjadi39 Connection Establishment Three-Way Handshake –Host1 chooses a sequence number, x, and sends a CONNECTION REQUEST TPDU to host 2. –Host2 replies with an ACK TPDU acknowledging x and announcing its own initial sequence number, y. –Host1 acknowledges Host2’s choice of an initial sequence number in the first data TPDU that is sends.

40 CEN 4500, S. Masoud Sadjadi40 Connection Establishment Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. (a) Normal operation, (b) Old CONNECTION REQUEST appearing out of nowhere. (c) Duplicate CONNECTION REQUEST and duplicate ACK.

41 CEN 4500, S. Masoud Sadjadi41 Elements of Transport Protocols Addressing Connection Establishment Connection Release Flow Control and Buffering Multiplexing

42 CEN 4500, S. Masoud Sadjadi42 Connection Release Releasing a connection is easier than establishing one Types of connection release –Asymmetric Like telephone system May result in data loss (see next slide). –Symmetric Treats the connection as two separate unidirectional connections. Each direction is released independent of the other one. Determining when all the work is done to disconnect is not obvious (two-army problem).

43 CEN 4500, S. Masoud Sadjadi43 Connection Release Abrupt disconnection with loss of data.

44 CEN 4500, S. Masoud Sadjadi44 Connection Release The two-army problem. –The white army is larger than either of the two blue armies. –The blue armies need to synchronize their attacks. –How about three-way handshake? How about four-way? –In practice, one is usually prepared to take more risks! Unreliable communication channel

45 CEN 4500, S. Masoud Sadjadi45 Connection Release Four protocol scenarios for releasing a connection. (a)Normal case of a three-way handshake. (b) final ACK lost. The situation is saved by a timer. 6-14, a, b

46 CEN 4500, S. Masoud Sadjadi46 Connection Release (c) Response lost. We use timeout. (d) Response lost and subsequent DRs lost. After N retries, the senders gives up and disconnects.

47 CEN 4500, S. Masoud Sadjadi47 Elements of Transport Protocols Addressing Connection Establishment Connection Release Flow Control and Buffering Multiplexing

48 CEN 4500, S. Masoud Sadjadi48 Flow Control and Buffering The main difference with data link is that the router has only a few lines, but a host may have numerous connections. –This difference makes it impractical to implement the data link buffering strategy in the transport layer. –The receiver may, for example, maintain a single buffer pool shared by all connections. –Recall that the sender cannot trust the network layer’s acknowledgement, because the acknowledgement means only that the TPDU arrive, not that it was accepted!

49 CEN 4500, S. Masoud Sadjadi49 Flow Control and Buffering (a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per connection.

50 CEN 4500, S. Masoud Sadjadi50 Flow Control and Buffering (2) Dynamic buffer allocation. The arrows show the direction of transmission. An ellipsis (…) indicates a lost TPDU.

51 CEN 4500, S. Masoud Sadjadi51 Elements of Transport Protocols Addressing Connection Establishment Connection Release Flow Control and Buffering Multiplexing

52 CEN 4500, S. Masoud Sadjadi52 Multiplexing Multiplexing several conversations onto connections, virtual circuits, and physical links plays a role in several layers. When a TPDU comes in, there should be a way to tell which process to give it to. –This situation is called upward multiplexing If a user needs more bandwidth than one virtual circuit can provide, a way out Is to open multiple network connections and distribute the traffic among them –This situation is call downward multiplexing

53 CEN 4500, S. Masoud Sadjadi53 Multiplexing (a) Upward multiplexing. (b) Downward multiplexing.

54 CEN 4500, S. Masoud Sadjadi54 Elements of Transport Protocols Addressing Connection Establishment Connection Release Flow Control and Buffering Multiplexing Crash Recovery

55 CEN 4500, S. Masoud Sadjadi55 Crash Recovery Different combinations of client and server strategy.

56 CEN 4500, S. Masoud Sadjadi56 Agenda The Transport Service Elements of Transport Protocol A Simple Transport Protocol The Internet Transport Protocol: UDP The Internet Transport Protocol: TCP Performance Issues Summary

57 CEN 4500, S. Masoud Sadjadi57 A Simple Transport Protocol To make the ideas discussed so far concrete, we will study an example transport layer in detail. We use the below connection-oriented abstract service primitives. –It is similar to, but simpler than TCP protocol

58 CEN 4500, S. Masoud Sadjadi58 A Simple Transport Protocol We will study –The Example Service Primitives How to express these transport primitives concretely? –The Example Transport Entity We see an example transport entity. –The Example as a Finite State Machine We model the transport entity using an FSM.

59 CEN 4500, S. Masoud Sadjadi59 The Example Service Primitives How to express these transport primitives concretely? –CONNECT A library procedure connect that can be called with the appropriate parameters necessary to establish a connection. The parameters are the local and remote TSAPs. During the call, the caller is blocked. If the connection succeeds, the caller is unblocked. The caller can start transmitting data. –LISTEN A process is willing to accept incoming calls, calls listen. It needs to specify a specific TSAP to listen to. The process the blocks until a process attempts to establish a connection to its TSAP. This model in highly asymmetric (active and passive sides).

60 CEN 4500, S. Masoud Sadjadi60 The Example Service Primitives –LISTEN (cont.) What if the caller starts sooner? –Call fails –Call blocks forever until a listener appears –Hold the connection request at the receiving end for a certain time interval in the hope that the listener will call listen before the time goes off (used here). –DISCONNECT When both sides have disconnected, the connection is released. Symmetric disconnection model is used! –SEND & RECEIVE Active call send; and passive call receive.

61 CEN 4500, S. Masoud Sadjadi61 The Example Service Primitives Concrete Service Definition: –connum = LISTEN (local) –connum = CONNECT (local, remote) –status = SEND (connum, buffer, bytes) –status = RECEIVE (connum, buffer, bytes) –status = DISCONNECT (connum)

62 CEN 4500, S. Masoud Sadjadi62 A Simple Transport Protocol We will study –The Example Service Primitives How to express these transport primitives concretely? –The Example Transport Entity We see an example transport entity. –The Example as a Finite State Machine We model the transport entity using an FSM.

63 CEN 4500, S. Masoud Sadjadi63 The Example Transport Entity Note that –This example is analogous to the early examples in Chapter 3 (data link layer). –Many of the details are omitted for simplicity. The transport layer makes use of the the network service primitives to send and receive TPDUs. –We need to choose the network service primitives to use. Unreliable datagram service: –A complex transport layer! –We discussed most of the issues in the previous chapter Connection-oriented, reliable network service: –This way, we only focus on the issues that do not occur in the lower layers (e.g. connection establishment and release).

64 CEN 4500, S. Masoud Sadjadi64 The Example Transport Entity The transport entity –may be part of the operating system –may be a package of library routines running within the user’s address space. –We assume the latter choice in our example. –We assume also that the application using our library is single-threaded.

65 CEN 4500, S. Masoud Sadjadi65 The Example Transport Entity The interface to the network layer –to-net(cid, q, m, pt, p, bytes), from-net(cid, q, m, pt, p, bytes) cid maps to network virtual-circuit q is the quantifier bit that indicate control message (0/1=data/credit) m is the more data bit Pt is packet type (next slide) p & bytes, are pointer to the data and an integer showing the length –On calls to to-net, the transport entity fills in all the parameters for the network layer to read –On calls to from-net, the network layer dismembers an incoming packet for the transport entity. –Thus, the transport layer is shielded from the details of network layer.

66 CEN 4500, S. Masoud Sadjadi66 The Example Transport Entity The types of network layer packets used in our example.

67 CEN 4500, S. Masoud Sadjadi67 The Example Transport Entity Each connection is in one of seven states: –Idle – Connection not established yet. –Waiting – CONNECT has been executed, CALL REQUEST sent. –Queued – A CALL REQUEST has arrived; no LISTEN yet. –Established – The connection has been established. –Sending – The user is waiting for permission to send a packet. –Receiving – A RECEIVE has been done. –DISCONNECTING – a DISCONNECT has been done locally.

68 CEN 4500, S. Masoud Sadjadi68 The Example Transport Entity Transition between states can occur when any of the following events occur: –A primitive is executed –A packet arrives –The timer expires Types of procedures in the example –Directly callable by user programs  –Packet_arrival and clock (interrupt routines) These are spontaneously triggered by external events: the arrival of a packet and the clock ticking, resp. Assumption: these are called when the user process is sleeping or executing outside the transport entity.

69 CEN 4500, S. Masoud Sadjadi69 The Example Transport Entity Flow Control in the example –To avoid having to provide and manage buffers within the transport entity, a different mechanism from the normal sliding window is employed When a user calls RECEIVE, a special credit message is sent to the transport entity on the sending machine and is recorded in the conn array. conn is the main data structure used by transport entity and has one record for each potential connection. When SEND is called, the transport entity checks to see if a credit has arrived on the specified connection (conn[k]). If so, the message is sent (in multiple packets if need be) and the credit is decremented. If not, the transport entity puts itself to sleep until a credit arrives.

70 CEN 4500, S. Masoud Sadjadi70 The Example Transport Entity (3)

71 CEN 4500, S. Masoud Sadjadi71 The Example Transport Entity (4)

72 CEN 4500, S. Masoud Sadjadi72 The Example Transport Entity (5)

73 CEN 4500, S. Masoud Sadjadi73 The Example Transport Entity (6)

74 CEN 4500, S. Masoud Sadjadi74 The Example Transport Entity (7)

75 CEN 4500, S. Masoud Sadjadi75 The Example Transport Entity (8)

76 CEN 4500, S. Masoud Sadjadi76 The Example Transport Entity (9)

77 CEN 4500, S. Masoud Sadjadi77 The Example Transport Entity (10)

78 CEN 4500, S. Masoud Sadjadi78 A Simple Transport Protocol We will study –The Example Service Primitives How to express these transport primitives concretely? –The Example Transport Entity We see an example transport entity. –The Example as a Finite State Machine We model the transport entity using an FSM.

79 CEN 4500, S. Masoud Sadjadi79 The Example as a Finite State Machine Writing a transport entity is difficult and exacting work, especially for more realistic protocols. In general, to reduce the chance of making errors and to deal with complexity, we use modeling. –In this case, we use a finite state machine to represent the states that a transport entity may have during its execution. –Our example has 7 states per connection.

80 CEN 4500, S. Masoud Sadjadi80 The Example as a Finite State Machine The example protocol as a finite state machine. Each entry has an optional predicate, an optional action, and the new state. The tilde indicates that no major action is taken. An overbar above a predicate indicate the negation of the predicate. Blank entries correspond to impossible or invalid events. Under what condition the action is taken Action being taken Next state

81 CEN 4500, S. Masoud Sadjadi81 The Example as a Finite State Machine The example protocol in graphical form. Transitions that leave the connection state unchanged have been omitted for simplicity. [predicate] event/action State1State2 Use the above convention in your projects when you develop the FSM for your protocols.

82 CEN 4500, S. Masoud Sadjadi82 Matrix Representation of a Protocol Advantages: –For testing: It is much easier for the programmer to systematically check each combination of state and event to see if an action is required. For testing, some of the states correspond to impossible and some correspond to illegal states. –For implementation: A two dimensional array could keep track of what procedure should be called when is a state and a specific event is triggered. –For protocol description: A protocol can be easily expressed using the matrix representation. Disadvantages: –Might be hard to understand, which can be complemented by the FSM graph.

83 CEN 4500, S. Masoud Sadjadi83 Agenda The Transport Service Elements of Transport Protocol A Simple Transport Protocol The Internet Transport Protocol: UDP The Internet Transport Protocol: TCP Performance Issues Summary

84 CEN 4500, S. Masoud Sadjadi84 The Internet Transport Protocols: UDP The Internet Main Transport Protocols –UDP A connectionless protocol Basically, just the IP with a short header added! –TCP A connection-oriented protocol Introduction to UDP Remote Procedure Call The Real-Time Transport Protocol

85 CEN 4500, S. Masoud Sadjadi85 Introduction to UDP User Datagram Protocol (UDP) –It provides a way for applications to send encapsulated IP datagrams and send them without having to establish a connection. –It transmits segments of 8-byte header followed by a payload (the header is shown below). The two ports serve to identify the end points within the source and destination machines. The UDP header. Optional: 0 for not computed!

86 CEN 4500, S. Masoud Sadjadi86 Introduction to UDP When a UDP packet arrives, its payload Is handed to the process attached to the destination port. This attachment occurs when BIND primitive or something similar is used (the binding process is the same as in TCP). In fact, the main value of UDP over just using raw IP is the addition of the source and destination ports.

87 CEN 4500, S. Masoud Sadjadi87 Introduction to UDP What UDP does NOT do? 1.Flow control 2.Error control 3.Retransmission upon receipt of a bad segment –All of what UDP does not do is up to the user process to take care of them. What UDP do? –Providing an interface to the IP protocol with the added feature of demultiplexing multiple processes using the ports.

88 CEN 4500, S. Masoud Sadjadi88 Introduction to UDP UDP Applications –Client-server situations Often, a client sends a short request to a server and expects a short reply back. If either the request or reply is lost, the client can just time out and try again. Not only the code is simple, but also fewer messages are required (one in each direction without initial setup) –Domain Name System (DNS) Uses UDP this way

89 CEN 4500, S. Masoud Sadjadi89 Remote Procedure Call In a certain sense, sending a request to a remote host and getting a reply back is similar to making a function call in a programming language. –In both cases, you start with one or more parameters and you get back some results. –The observation has led people to arrange request- reply interactions on networks to be cast in the form of procedure calls. –Such an arrangement, makes the network applications much easier to program and more familiar to deal with. –In this way, all the detail of networking is hidden from the programmer.

90 CEN 4500, S. Masoud Sadjadi90 Remote Procedure Call The key work in this area was done by Birrell and Nelson (1984) –Allowing programs to call procedures located on remote hosts. –When a process on machine 1 calls a procedure on machine 2, the calling process on 1 is suspended and execution of the called procedure takes place on 2. –Information can be transported from the caller to the callee in the parameters and can come back in the procedure results. –No message passing is visible to the programmer. –This technique is known as Remote Procedure Call (RPC) –The calling/called procedures is known as client/server

91 CEN 4500, S. Masoud Sadjadi91 Remote Procedure Call The idea is to make the RPC to look as a local one, as much as possible. –The client program is bound with a small library (generated) procedure, called the client stub. The client stub represents the server procedure in the client’s address space. –Similarly, the server is bound with a procedure called the server stub. The client and server stubs hide the fact that the procedure call from the server to the client is not a local call.

92 CEN 4500, S. Masoud Sadjadi92 Remote Procedure Call Steps in making a remote procedure call. The stubs are shaded.

93 CEN 4500, S. Masoud Sadjadi93 Remote Procedure Call The steps shown in the previous slide: –Step 1: the client is calling the client stub. This is a local call with the parameters pushed onto the stack in a normal way. –Step 2: the client stub is packing the parameters into a message and making a system call to send the message. Packing the parameters is called marshalling. –Step 3: the kernel is sending message from the client machine to the server machine –Step 4: the kernel passing the incoming packet to the server stub. –Step 5: the server stub calling the server procedure with the unmarshalled parameters. –The reply trace the same path in the other direction.

94 CEN 4500, S. Masoud Sadjadi94 Remote Procedure Call There are many problems left –“The devil is in details!” 1.Pointer parameters Call-by reference, shallow copy, complex data structure, etc. 2.Weakly-typed languages In a language like C, you can write a procedure that computes the inner product of two vectors (arrays), without specifying how large either one is. 3.Deducing the types of the parameters printf may have a number of parameters, at least one! 4.Global Variables!

95 CEN 4500, S. Masoud Sadjadi95 Remote Procedure Call Should we develop RPC on top of UDP or TCP? –RPC need not to use UDP packets, but RPC and UDP are a good fit and UDP is commonly used for RPC. –However, we use TCP When the parameters of results may be larger than the maximum UDP packet When the operation requested is not idempotent (i.e., cannot be repeated safely, such as when incrementing a counter).

96 CEN 4500, S. Masoud Sadjadi96 The Real-Time Transport Protocol Client-server RPC is one area in which UDP is widely used. Another area is real-time multimedia applications. As different multimedia applications have been emerging (e.g. Internet radios, Internet telephony, music-on-demand, video conferencing, and video- on-demand), people started to realize that they are reinventing the same real-time protocol. Therefore, the Real-Time Transport Protocol (RTP) was born as generic protocol for all these multimedia applications.

97 CEN 4500, S. Masoud Sadjadi97 The Real-Time Transport Protocol It was decided to put RTP in user space and have it (normally) run over UDP. –The multimedia application feeds the streams into the RTP library, which is in the user space. –The library then multiplexes the streams and encodes them in RTP packets, which then stuffs into a socket. –In the kernel, UDP packets are generated and embedded in IP packet, and then in Ethernet frames. (a) The position of RTP in the protocol stack. (b) Packet nesting.

98 CEN 4500, S. Masoud Sadjadi98 The Real-Time Transport Protocol Where is RTP? –RTP is a transport protocol that is implemented in the application layer. What is RTP’s function? –To multiplex several real-time data streams onto a single stream of UDP packets. –The UDP stream can be sent to a single destination (unicasting) or to multiple destinations (multicasting). –As RTP just uses normal UDP, its packets are not treated specially by the routers; there are no special guarantees about delivery, jitter, etc.

99 CEN 4500, S. Masoud Sadjadi99 The Real-Time Transport Protocol Each packet sent in an RTP stream is numbered –This way, the receiver can detect if a packet is lost –One action on the receiving side can be to estimate the packet contents (e.g., using interpolation). –Retransmission is not a practical option. –RTP has no flow control, no error control, no acknowledgements, and no mechanism to request retransmissions.

100 CEN 4500, S. Masoud Sadjadi100 The Real-Time Transport Protocol RTP payload and its encoding –Each RTP payload may contain multiple samples, and may be coded any way that the application may choose. –To allow for interworking, RTP defines several profiles and for each profile, multiple encoding formats may be allowed. e.g., a single audio stream may be encoded as 8-bit PCM samples at 8kHz, delta encoding, predictive encoding, GSM encoding, MP3, and so on. RTP provides a header filed in which their source can specify the encoding but is otherwise not involved in how encoding is done.

101 CEN 4500, S. Masoud Sadjadi101 The Real-Time Transport Protocol Timestaming –The idea is to allow the source to associate a timestamp with the first sample in each packet. –The timestamps are relative to the start of the stream, so only the differences between timestamps are significant (the absolute value has no meaning). –The destination can do a small amount of buffering and play each sample the right number of miliseconds after the start of the stream, independently of when the packet arrived. This reduces the jitter and allows multiple streams to be synchronized with each other. For example, a digital tv program supporting multiple languages.

102 CEN 4500, S. Masoud Sadjadi102 The Real-Time Transport Protocol The RTP header. At 2 Padding to 4 bytes Extension header Number of contributing source Application-specific marker bit (e.g., start of a video frame) Encoding scheme For detecting a lost packet Time from the first sample for reducing jitter and allowing synchronization Which stream the packet belongs to Id of the contributing sources

103 CEN 4500, S. Masoud Sadjadi103 The Real-Time Transport Control Protocol RTCP is the little sister of the RTP that handles –Feedback For delay, jitter, bandwidth, congestion, etc. –Synchronization For inter-stream synchronization for those streams using different clocks. – Naming the various sources E.g., in ASCII text This information can be displayed on the receiver’s screen to indicate who is talking at the moment.

104 CEN 4500, S. Masoud Sadjadi104 Agenda The Transport Service Elements of Transport Protocol A Simple Transport Protocol The Internet Transport Protocol: UDP The Internet Transport Protocol: TCP Performance Issues Summary

105 CEN 4500, S. Masoud Sadjadi105 The Internet Transport Protocols: TCP Introduction to TCP The TCP Service Model The TCP Protocol The TCP Segment Header TCP Connection Establishment TCP Connection Release TCP Connection Management Modeling TCP Transmission Policy TCP Congestion Control TCP Timer Management Wireless TCP and UDP Transactional TCP

106 CEN 4500, S. Masoud Sadjadi106 Introduction to TCP The User Datagram Protocol (UDP) –is a simple protocol and has its applications. –However, for most Internet applications, reliable, sequenced delivery is needed. –TCP is the answer! The Transport Control Protocol (TCP) –TCP was specifically designed to provide a reliable end- to-end byte stream over an unreliable internetwork. –An internetwork can have parts with wildly different topologies, bandwidths, delays, packet sizes, etc. –TCP was designed to dynamically adapt to properties of the internetwork and to be robust with many failures.

107 CEN 4500, S. Masoud Sadjadi107 Introduction to TCP TCP transport entity can be realized as –A library procedure –A user process –Part of the kernel. In all cases, TCP entity manages TCP streams and interfaces to the IP layer. A TCP entity –accepts user data streams from local processes –breaks them up into pieces not exceeding 64 KB (in practice, often 1460 data bytes for Ethernet) –sends each piece as a separate IP datagram. –When the pieces arrive on the other side, the original byte stream is reconstructed.

108 CEN 4500, S. Masoud Sadjadi108 Introduction to TCP TCP responsibilities –Time out and retransmit datagrams as need be –To reassembles the datagrams and deliver them in the correct order –Furnishing the reliability requested by the user, which is not provided by the IP layer.

109 CEN 4500, S. Masoud Sadjadi109 The TCP Service Model The service is obtained by both the sender and receiver creating end points, called sockets. Each socket has the socket number (address) consisting of the IP address of the host and a 16-bit number local to that host, called a port. A port is the TCP name for a TSAP. A socket might be used for multiple connections at the same time. Connections are identified by the sockets identifiers at both ends (socket1, socket2). No virtual circuit numbers or other identifiers are used.

110 CEN 4500, S. Masoud Sadjadi110 The TCP Service Model Port numbers below 1024 are called well-known ports and are reserved for standard services. –ftp: 21 –telnet: 23 –http: 80 Instead of having one daemon to listen to each of these port at startup, a single daemon, called inted (Internet daemon) in UNIX, attaches itself to multiple ports and wait for the first incoming connection. –When this occurs, inetd forks off a new process and executes the appropriate daemon in it, letting that daemon handle the request.

111 CEN 4500, S. Masoud Sadjadi111 The TCP Service Model Some assigned ports. All TCP connections are –full duplex: traffic goes in both directions. –point-to point: each connection has exactly two end points. PortProtocol Use 21 FTP File transfer 23 Telnet Remote login 25 SMTP E-mail 69 TFTP Trivial File Transfer Protocol 79 FingerLookup info about a user 80 HTTP World Wide Web 110 POP-3 Remote e-mail access 119 NNTP USENET news

112 CEN 4500, S. Masoud Sadjadi112 The TCP Service Model A TCP connection is a byte stream not message stream –message boundaries are not preserved. –Same as files in UNIX; the reader of a file cannot tell how the file was written! (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.

113 CEN 4500, S. Masoud Sadjadi113 The TCP Service Model Urgent Data –When an interactive user hits the DEL or CTRL-C key to break off a remote computation that has already begun, the sending application puts some control information in the data stream and gives it to TCP along with the URGENT flag. –This event causes TCP to stop accumulating data and transmit everything it has for that connection immediately. –When the urgent data is received at the destination, the receiving application is interrupted (e.g., given a signal in UNIX terms) so it can stop whatever it was doing and read the data stream to find the urgent data.

114 CEN 4500, S. Masoud Sadjadi114 The TCP Protocol Every byte on a TCP connection has its own 32-bit sequence number. –Separate 32-bit sequence numbers are used for acknowledgements and for the window mechanism. The sending and receiving entities exchange data in the form of segments A TCP segment consists of a fixed 20-byte header (plus an optional part) followed by zero or more data bytes. –The TCP software decides how big a TCP segment should be. –It can accumulate data from several writes into one segment or can split data from one write over multiple segments. 65,515 bytes of IP payload or 1500 bytes of Ethernet payload size?

115 CEN 4500, S. Masoud Sadjadi115 The TCP Protocol The basic protocol used by TCP entities is the sliding window protocol. –When a sender transmits a segment, it also starts a timer. –When the segment arrives at the destination, the receiving TCP entity sends back a segment (with data if any exist, otherwise without data) bearing an acknowledgement number equal to the next sequence number it expects to receive. –If senders timer goes off before the acknowledgement is received, the sender transmits the segment again.

116 CEN 4500, S. Masoud Sadjadi116 The TCP Protocol Issues –Segments can arrive out of order. –Segments can be delayed so long that the sender times out and retransmits them. –The retransmissions may include different byte ranges than the original transmission, requiring a careful administration to keep track of which bytes have been correctly received so far. As each byte in the stream has its own sequence number, this can be done!

117 CEN 4500, S. Masoud Sadjadi117 The TCP Segment Header TCP Header. The next byte expected How many 32-bit words Not Used ACK is valid or not Not to wait for the buffer to become full Reset a connection that has been confused due to a crash To establish a connection To release a connection For extra reliability Validity of urgent pointer Allows each host to specify the maximum TCP payload it is willing to accept!

118 CEN 4500, S. Masoud Sadjadi118 The TCP Segment Header Every segment begins with a fixed-format, 20-byte header. –It may be followed by header options. –After options, if any, up to 65,495 (65,535 – 20 IP Header – 20 TCP Header) data bytes may follow. Segments without any data are legal and are commonly used for acknowledgements and control messages. A port plus its host’s IP address forms a 48-bit unique end point. The source and destination end points together identify the connection

119 CEN 4500, S. Masoud Sadjadi119 The TCP Segment Header (2) The Checksum includes the header, the data, and the conceptual pseudoheader (see below)

120 CEN 4500, S. Masoud Sadjadi120 TCP Connection Establishment Three-Way Handshake (a) TCP connection establishment in the normal case. (b) Call collision. 6-31

121 CEN 4500, S. Masoud Sadjadi121 TCP Connection Establishment Normal case –When the first SYN segment arrives at the destination, the TCP entity there checks to see if there is a process that has done a LISTEN on the port given in the Destination port field. If not, it sends a reply with the RST bit on to reject the connection. –If so, the process is given the incoming TCP segment, and it can either accept or reject the connection. –If it accepts, an acknowledgement segment is sent back. Call Collision –The result of the events is that just one connection is established, not two because connections are identified by their end points.

122 CEN 4500, S. Masoud Sadjadi122 TCP Connection Release TCP connections are full duplex –We assume two simplex connections. –Each simplex connection is released independently. –Either party can send a TCP segment with the FIN bit set, which means that it has no more data to transmit. When the FIN is acknowledged, that direction is shut down for new data. –When both connections are shut down, the connection is rerleased. –Either three (FIN, FIN/ACK, ACK) or four (FIN, ACK, FIN, ACK) segments! –To avoid the two army problem, timers are used.

123 CEN 4500, S. Masoud Sadjadi123 TCP Connection Management Modeling The states used in the TCP connection management finite state machine.

124 CEN 4500, S. Masoud Sadjadi124 TCP Connection Management Modeling (2) TCP connection management finite state machine. The heavy solid line is the normal path for a client. The heavy dashed line is the normal path for a server. The light lines are unusual events. Each transition is labeled by the event causing it and the action resulting from it, separated by a slash.

125 CEN 4500, S. Masoud Sadjadi125 TCP Transmission Policy Window management in TCP.

126 CEN 4500, S. Masoud Sadjadi126 TCP Transmission Policy (2) Silly window syndrome.

127 CEN 4500, S. Masoud Sadjadi127 TCP Congestion Control (a) A fast network feeding a low capacity receiver. (b) A slow network feeding a high-capacity receiver.

128 CEN 4500, S. Masoud Sadjadi128 TCP Congestion Control (2) An example of the Internet congestion algorithm.

129 CEN 4500, S. Masoud Sadjadi129 TCP Timer Management (a) Probability density of ACK arrival times in the data link layer. (b) Probability density of ACK arrival times for TCP.

130 CEN 4500, S. Masoud Sadjadi130 Wireless TCP and UDP Splitting a TCP connection into two connections.

131 CEN 4500, S. Masoud Sadjadi131 Transitional TCP (a) RPC using normal TPC. (b) RPC using T/TCP.

132 CEN 4500, S. Masoud Sadjadi132 Agenda The Transport Service Elements of Transport Protocol A Simple Transport Protocol The Internet Transport Protocol: UDP The Internet Transport Protocol: TCP Performance Issues Summary

133 CEN 4500, S. Masoud Sadjadi133 Performance Issues Performance Problems in Computer Networks Network Performance Measurement System Design for Better Performance Fast TPDU Processing Protocols for Gigabit Networks

134 CEN 4500, S. Masoud Sadjadi134 Performance Problems in Computer Networks The state of transmitting one megabit from San Diego to Boston (a) At t = 0, (b) After 500 μsec, (c) After 20 msec, (d) after 40 msec.

135 CEN 4500, S. Masoud Sadjadi135 Network Performance Measurement The basic loop for improving network performance. Measure relevant network parameters, performance. Try to understand what is going on. Change one parameter.

136 CEN 4500, S. Masoud Sadjadi136 System Design for Better Performance Rules: CPU speed is more important than network speed. Reduce packet count to reduce software overhead. Minimize context switches. Minimize copying. You can buy more bandwidth but not lower delay. Avoiding congestion is better than recovering from it. Avoid timeouts.

137 CEN 4500, S. Masoud Sadjadi137 System Design for Better Performance (2) Response as a function of load.

138 CEN 4500, S. Masoud Sadjadi138 System Design for Better Performance (3) Four context switches to handle one packet with a user-space network manager.

139 CEN 4500, S. Masoud Sadjadi139 Fast TPDU Processing The fast path from sender to receiver is shown with a heavy line. The processing steps on this path are shaded.

140 CEN 4500, S. Masoud Sadjadi140 Fast TPDU Processing (2) (a) TCP header. (b) IP header. In both cases, the shaded fields are taken from the prototype without change.

141 CEN 4500, S. Masoud Sadjadi141 Fast TPDU Processing (3) A timing wheel.

142 CEN 4500, S. Masoud Sadjadi142 Protocols for Gigabit Networks Time to transfer and acknowledge a 1- megabit file over a 4000-km line.

143 CEN 4500, S. Masoud Sadjadi143 Agenda The Transport Service Elements of Transport Protocol A Simple Transport Protocol The Internet Transport Protocol: UDP The Internet Transport Protocol: TCP Performance Issues Summary

144 CEN 4500, S. Masoud Sadjadi144 Summary The transport layer is the key to understanding layered protocols. Among many services that it provides, the most important one is an end-to-end, reliable, connection-oriented byte stream from sender to receiver. Connection management –Connection establishment: three-way handshake –Connection release: symmetric & time out! UDP and TCP


Download ppt "CEN 4500 Data Communications Instructor: S. Masoud Sadjadi sadjadi At cs Dot fiu Dot edu Chapter 6: The Transport."

Similar presentations


Ads by Google