APPLICATION LAYER Application software issues • Transport layer software supports the reliable transfer of data between applications • Application layer software supports: 1. 2. 3. 4. 5. Initiating connections An application programming interface (API) Encoding data User friendly naming Definition of specific applications The client server paradigm • A widely used form of communication • Server application waits passively for contact from clients • A server provides a specific service • Client application actively initiates contact with the server • Information can flow in both directions • Typical situation is many clients interacting with each server Characteristics of clients • General application that becomes a client when remote access is needed • Invoked by the user • Runs on users local computer • Actively initiates contact with the server • Can access multiple services as needed Characteristics of servers • Special purpose program to provide one service • can handle multiple clients at one time • invoked when the system boots • runs on a relatively powerful shared computer • waits passively for contact from various kinds of client Transport protocols and client-server interaction • Clients and servers communicate using a transport protocol - unaware of underlying layers Server class computers • Often a single server class computer runs several servers Identifying a particular service • Transport protocols assign a unique identifier to each service – server registers its ID with protocol software when it boots – client specifies the desired ID when it makes a connection • TCP uses protocol port numbers Concurrency and servers • Concurrent server offers supports multiple clients at the same time • Uses multiple threads of control • Core part of server accepts new requests and dynamically creates new servers as separate threads to handle them • Each thread deals with its client’s requests • N concurrent clients => N + 1 threads • TCP uses a combination of destination port and source port to identify the right thread Complex client-server interactions • A client is not restricted to accessing a single service • A server can itself become a client of another server • Watch out for circular dependencies Distributed programming • Extend client-server paradigm to more general distributed programming • Provide greater transparency for programmers – remote procedure calls (RPC) – distributed objects and components • Provide standard services for locating and manufacturing other services – traders – factories Traders trader 2. Request service 1. export service offer client service 3. use service Factories trader 2. request create service factory 1. Request service 3. create service client service 4. use service Other forms of communication peer peer Peer to peer communication peer peer Dynamic Host Configuration Protocol (DHCP) Dynamic Host Configuration Protocol (DHCP) Provides four pieces of information : 1. The IP address of the computer 2. The subnet mask of the computer 3. The IP address of a router 4. The IP address of a name server DHCP operation • The DHCP client and server can 1. Same network 2. Different networks o Same network the administrator may put the client and the server on the same network as shown in Figure Same Network 1. 2. 3. The DHCP server issues a passive open command on UDP port number 67 and waits for a client. A booted client issues an active open command on port number 68 . The message is encapsulated in a UDP user datagram, using the destination port number 67 and the source port number 68. The UDP user datagram, in turn, is encapsulated in an IP datagram. The reader may ask how a client can send an IP datagram when it knows neither its own IP address (the source address) nor the server’s IP address (the destination address). The client uses all 0s as the source address and all 1s as the destination address. The server responds with either a broadcast or a unicast message using UDP source port number 67 and destination port number 68. The response can be unicast because the server knows the IP address of the client. It also knows the physical address of the client, which means it does not need the services of ARP for logical to physical address mapping. However, some systems do not allow the by passing of ARP, resulting in the use of the broadcast address. Different Networks A client can be in one network and the server in another, separated by several other networks. Figure shows the situation. However, there is one problem that must be solved. The DHCP request is broadcast because the client does not know the IP address of the server. A broadcast IP datagram cannot pass through any router. A router receiving such a packet discards it. Recall that an IP address of all 1s is a limited broadcast address. To solve the problem, there is a need for an intermediary. One of the hosts (or a router that can be configured to operate at the application layer) can be used as a relay. The host in this case is called a relay agent. The relay agent knows the unicast address of a DHCP server and listens for broadcast messages on port 67. When it receives this type of packet, it encapsulates the message in a unicast datagram and sends the request to the DHCP server. The packet, carrying a unicast destination address, is routed by any router and reaches the DHCP server. The DHCP server knows the message comes from a relay agent because one of the fields in the request message defines the IP address of the relay agent. The relay agent, after receiving the reply, sends it to the DHCP client. DHCP packet format 1. Operation code. This 8-bit field defines the type of DHCP packet: request (1) or reply (2). 2. Hardware type. This is an 8-bit field defining the type of physical network. Each type of network has been assigned an integer. For example, for Ethernet the value is 1. 3. Hardware length. This is an 8-bit field defining the length of the physical address in bytes. For example, for Ethernet the value is 6. 4. Hop count. This is an 8-bit field defining the maximum number of hops the packet can travel. 5. Transaction ID. This is a 4-byte field carrying an integer. The transaction identification is set by the client and is used to match a reply with the request. The server returns the same value in its reply. 6. Number of seconds. This is a 16-bit field that indicates the number of seconds elapsed since the time the client started to boot. 7. Flag. This is a 16-bit field in which only the leftmost bit is used and the rest of the bits should be set to 00s, e.i:(0000000000000001). A leftmost bit specifies a forced broadcast reply (instead of unicast) from the server. 8. Client IP address. This is a 4-byte field that contains the client IP address. If the client does not have this information, this field has a value of 0. 9. Your IP address. This is a 4-byte field that contains the client IP address. It is filled by the server (in the reply message) at the request of the client. 10. Server IP address. This is a 4-byte field containing the server IP address. It is filled by the server in a reply message. 11. Gateway IP address. This is a 4-byte field containing the IP address of a router. It is filled by the server in a reply message. 12. Client hardware address. This is the physical address of the client. Although the server can retrieve this address from the frame sent by the client, it is more efficient if the address is supplied explicitly by the client in the request message. 13.Server name. This is a 64-byte field that is optionally filled by the server in a reply packet. It contains a null-terminated string consisting of the domain name of the server. If the server does not want to fill this field with data, the server must fill it with all 0s. 14.Boot filename. This is a 128-byte field that can be optionally filled by the server in a reply packet. It contains a null-terminated string consisting of the full pathname of the boot file. The client can use this path to retrieve other booting information. If the server does not want to fill this field with data, the server must fill it with all 0s. 15.Options. This is a 64-byte field. It can carry either additional information such as the network mask or default router address File Transfer Protocol (FTP) FTP uses the services of TCP. It needs two TCP connections. The well-known port 21 is used for the control connection and the well-known port 20 for the data connection. FTP File Transfer Protocol (FTP) is a TCP/IP clientserver application for copying files from one host to another. FTP requires two connections for data transfer: a control connection and a data connection. 1- Control Connection 1. The server issues a passive open on the well-known port 21 and waits for a client. 2. The client uses an ephemeral port and issues an active open. The connection remains open during the entire process. The service type, used by the IP protocol, is minimize delay because this is an interactive connection between a user (human) and a server. The user types commands and expects to receive responses without significant delay. 2- Data Connection Data Connection The data connection uses the well-known port 20 at the server site. However, the creation of a data connection is different from what we have seen so far. The following shows how FTP creates a data connection: 1. The client, not the server, issues a passive open using an ephemeral port. This must be done by the client because it is the client that issues the commands for transferring files. 2. The client sends this port number to the server using the PORT command. 3. The server receives the port number and issues an active open using the well-known port 20 and the received ephemeral port number