Presentation is loading. Please wait.

Presentation is loading. Please wait.

Jozef Goetz, 2009 1 Application Layer PART VI Jozef Goetz, 2009 2 Position of application layer The application layer enables the user, whether human.

Similar presentations


Presentation on theme: "Jozef Goetz, 2009 1 Application Layer PART VI Jozef Goetz, 2009 2 Position of application layer The application layer enables the user, whether human."— Presentation transcript:

1

2 Jozef Goetz, 2009 1 Application Layer PART VI

3 Jozef Goetz, 2009 2 Position of application layer The application layer enables the user, whether human or software, to access the network. It provides user interfaces and support for services such as 1. electronic mail, 2. remote file access and transfer, and 3. access to the World Wide Web (requires a simple transfer protocol called HTTP)

4 Jozef Goetz, 2009 3 application layer The application layer is designed to give different services to the user or user programs. The most common service, Simple Network Management Protocol - SMTP, allows a user to send a message to another user in the Internet. This service is electronic mail and has many similarities to the traditional postal mail. Another common service is file transfer. File Transfer Protocol FTP. A user can transfer a file from its computer to the server or transfer a file from a server to its computer

5 Jozef Goetz, 2009 4 Application layer duties

6 Jozef Goetz, 2009 5 Chapters Chapter 24 Client-Server Model Chapter 25 Domain Name System Chapter 26 SMTP and FTP Chapter 27 HTTP and WWW Chapter 28 Multimedia

7 Jozef Goetz, 2009 6 Chapter 24 ed.3 Current one is ed.4 expanded by Jozef Goetz, 2009 The McGraw-Hill Companies, Inc., 2004

8 Jozef Goetz, 2009 7 Client-Server Model Before discussing some application layer protocols, we need to understand the nature of these application programs. We need to know that the Internet is based on a client-server model. There are several ways that a computer can ask for the services of another computer. By far the most common is the client-server model. Although there are several ways to allow a client and a server to communicate, the most common one is the socket interface

9 Jozef Goetz, 2009 8 24.1 Client-Server Model Relationship Concurrency Processes

10 Jozef Goetz, 2009 9 The purpose of a network, or an internetwork, is to provide services to users. A user at a local site wants to receive a service from a computer at a remote site. There is only one way for a computer to do the job; it must run a program. A computer runs a program to either request a service from another computer or provide a service to another computer. Client-server model

11 Jozef Goetz, 2009 10 So, application programs, running at two end computers and communicating with each other, are needed. In other words, in an internet, the application programs are entities that communicate with each other, not computers or users. Client-server model

12 Jozef Goetz, 2009 11 These are some of the questions that we may ask: l. Should both the applications be able to request services and provide services, or should they just do one or the other? One solution is to have an application program, called the client, running on the local machine request a service from another application program, called the server, running on the remote machine.

13 Jozef Goetz, 2009 12 2. Should an application program provide services only to one specific client application program installed somewhere in an Internet, or should it provide services for any client application program that requests this service? The most common solution is a server providing a service for any client These are some of the questions that we may ask:

14 Jozef Goetz, 2009 13 3. When should an application program be running-all the time or just when there is a need for the service? Generally, a client program, which requests a service, should run only when it is needed. The server program, which provides a service, should run all the time b/c it does not know when its services will be needed. These are some of the questions that we may ask:

15 Jozef Goetz, 2009 14 4. Should there be only one server universal application program that can provide any type of service a user wants? Or should there be one server application program for each type of service? In the Internet, services needed frequently and by many users have specific client-server application programs. For example, we have separate client-server application programs that allow users to access files or send email. For services that are more customized, we should have one generic application program that allows users to access the services available on a remote computer. These are some of the questions that we may ask:

16 Jozef Goetz, 2009 15 Client A client is a program running on the local machine requesting service from a server. 1. A client program is started by the user (or another application program) and terminates when the service is complete. 2. A client opens the communication channel using the IP address of the remote host and the well-known port address of the specific server program running on that machine. This is called an active open. 3. After a channel of communication is opened, the client sends its request and receives a response. 4. Although the request-response part may be repeated several times, the whole process is finite and eventually comes to an end. At that moment, the client closes the communication channel with an active close.

17 Jozef Goetz, 2009 16 Server A server is a program running on the remote machine and providing service to the clients. 1. When it starts, it opens the door for incoming requests from clients, but it never initiates a service until it is requested to do so. This is called a passive open. 2. A server program is an infinite program. When it starts, it runs infinitely unless a problem arises. 3. It waits for incoming requests from clients. 4. When a request arrives, it responds to the request, either iteratively or concurrently.

18 Jozef Goetz, 2009 17 Concurrency Both clients and servers can run in concurrent mode. Concurrency in Clients Clients can be run on a machine either iteratively Running clients iteratively means running them one by one; one client must start, run, and terminate before the machine can start another client. or concurrently. Most computers today, however, allow concurrent clients; that is, two or more clients can run at the same time.

19 Jozef Goetz, 2009 18 Concurrency in Servers An iterative server can process only one request at a time; it receives a request, processes it, and sends the response to the requestor before it handles another request. A concurrent server, on the other hand, can process many requests at the same time and thus can share its time between many requests. The servers use either UDP, a connectionless transport layer protocol, or TCP, a connection-oriented transport layer protocol.

20 Jozef Goetz, 2009 19 Concurrency in Servers Server operation, therefore, depends on 2 factors: the transport layer protocol and the service method. Theoretically we can have 4 types of servers: 1. connectionless iterative, 2. connectionless concurrent, 3. connection­oriented iterative, and 4. connection-oriented concurrent.

21 Jozef Goetz, 2009 20 1. Connectionless Iterative Server The servers that use UDP are normally iterative, which, means that the server processes one request at a time. The server uses one single port for this purpose, the well­known port. All the packets arriving at this port wait in line to be served

22 Jozef Goetz, 2009 21 4. Connection-Oriented Concurrent Server 1. A client can make its initial approach to this port to make the connection. 2. After the connection is made, the server assigns a temporary port to this connection to free the well-known port. p.1065 ed.4 list of ports 3. Data transfer can now take place between these two temporary ports, one at the client site and the other at the server site. 1. The well-known port is now free for another client to make a connection. The idea is to push demultiplexing to TCP instead of the server.

23 Jozef Goetz, 2009 22 4. Connection-Oriented Concurrent Server A connection is established between the server and each client, and the connection remains open until the entire stream is processed and the connection is terminated. each connection requires a port and many connections may be open at the same time. Many ports are needed, but a server can use only one well- known port. The solution is to use one well-known port and many ephemeral (short lived) ports. The server issues a passive open at the well-known port.

24 Jozef Goetz, 2009 23 4. Connection-Oriented Concurrent Server The servers that use TCP are normally concurrent. This means that the server can serve many clients at the same time. Communication is connection-oriented, which means that a request is a stream of bytes that can arrive in several segments and the response can occupy several segments.

25 Jozef Goetz, 2009 24 Processes Understanding the concept of a process is necessary to comprehend the client­server model. Most operating systems OS, including UNIX, distinguish a program from a process. Whereas a program and a process are related to each other, they are not the same thing. In UNIX, LINUX etc. a program is code. The code defines all the variables and actions to be performed on those variables. A process, on the other hand, is an instance of a program. When the OS executes a program, an instance of the program, a process, is created. The OS can create several processes from one program, which means several instances of the same program are running at the same time (concurrently). Memory is allocated for each process separately.

26 Jozef Goetz, 2009 25 Socket Interface was originally based on UNIX and defines a set of system calls (procedures) that are an extension of system calls used in UNIX to access files. There are whole books devoted to this subject. Instead, we introduce the concept and idea

27 Jozef Goetz, 2009 26 24.2 Socket Interface Sockets Connectionless Iterative Server Connection-Oriented Server

28 Jozef Goetz, 2009 27 Socket structure The communication structure that we need in socket programming is a socket. A socket acts as an endpoint. A socket is defined in the operating system as a structure. Two processes need a socket at each end to communicate with each other. These fields are listed below: Family. This field defines the protocol group: IPv4, IPv6, UNIX domain protocols, and so on. Type. This field defines the type of socket: stream socket, packet socket, or raw socket. Protocol. This field is usually set to 0 for TCP and UDP.

29 Jozef Goetz, 2009 28 Socket structure Local socket address. This field defines the local socket address, a combination of the local IP address and the port address of the local application program. Remote socket address. This field defines the remote socket address, a combination of the remote IP address and the port address of the remote application program.

30 Jozef Goetz, 2009 29 Socket types The socket interface is a set of declarations, definitions, and procedures for writing client- server programs.

31 Jozef Goetz, 2009 30 Socket types The socket interface defines 3 types of sockets (All can be used in a TCP/IP environment) : the stream socket is designed to be used with a connection-oriented protocol such as TCP. TCP uses a pair of stream sockets to connect one application program to another across the Internet. the packet/datagram socket is designed to be used with a connectionless protocol such as UDP. UDP uses a pair of datagram sockets to send a message from one application program to another across the Internet.

32 Jozef Goetz, 2009 31 Socket types the raw socket Some protocols such as ICMP or OSPF that directly use the services of IP use neither stream sockets nor datagram sockets. Raw sockets are designed for these types of applications.

33 Jozef Goetz, 2009 32 1. Connectionless Iterative Server using UDP and datagram sockets a server that uses UDP is usually connectionless iterative. This means that the server serves one request at a time. A server gets the request received in a packet from UDP, processes the request, and gives the response to UDP to send to the client. The server pays no attention to the other packets. These packets, which could all be from one client or from many clients, are stored in a queue, waiting for service. They are processed one by one in order of arrival. The server uses one single port for this purpose, the well-known port.

34 Jozef Goetz, 2009 33 The server performs the following functions: 1.Create a socket. The server asks the OS to create a socket. 2. Bind. The server asks the OS to enter information (e.g. port #) in the socket related to the server. This is called binding the server socket. 3. Repeat. The server repeats the following steps infinitely: A. Receive a request. The server asks the operating system to wait for a request destined for this socket and to receive it. B. Process. The request is processed by the server. C. Send. The response is sent to the client. Socket interface for connectionless iterative server

35 Jozef Goetz, 2009 34 Client The client performs the following functions: 1. Create a socket. The client asks the SO to create a socket. There is no need for binding here. The OS normally fills in the information in the socket. 2. Repeat. The client repeats the following steps as long as it has requests: a. Send. The client asks the OS to send a request. b. Receive. The client asks the OS to wait for the response and deliver it when it has arrived. 3. Destroy. When the client has no more requests, it asks the OS to destroy the socket.

36 Jozef Goetz, 2009 35 4. Connection-Oriented Concurrent Server using TCP and stream sockets the servers that use TCP are normally concurrent. This means that the server serves many clients at the same time. Communication is connection-oriented, which means that a request is a stream of bytes that can arrive in several segments and the response can occupy several segments. A connection is established between the server and each client; the connection remains open until the entire stream is processed, and then the connection is terminated.

37 Jozef Goetz, 2009 36 4. Connection-Oriented Concurrent Server The server must have one buffer for each connection. The segments from the clients are stored in the appropriate buffers and handled concurrently by the server. most implementations use the concept of parent and child servers. A server running infinitely and accepting connections from clients is called a parent server. The parent server uses the well-known port. After the connection is made, the parent server creates a child server and an ephemeral port and lets the child server handle the client. It frees itself so that it can wait for another connection.

38 Jozef Goetz, 2009 37 The server performs the following functions: 1. Create a socket. The server asks the OS to create a socket. 2. Bind. The server asks the OS to enter information in the socket created in the previous step. 3. Listen. The server asks the OS to be passive and listen to the client that needs to be connected to this server. Remember that TCP is a connection­oriented protocol. A connection needs to be made before data transfer. 4. Socket interface for Connection- Oriented Concurrent Server

39 Jozef Goetz, 2009 38 4. Repeat. The server repeats the following steps infinitely: a. Create a child. When a child requests a connection, the OS creates a temporary child process and assigns the duty of serving the client to the child. The parent process is free to listen for new clients. b. Create a new socket. A new socket is created to be used by the child process. c. Repeating. The child repeats the following steps as long as it has requests from the client: Read. The child reads a stream of bytes from the connection. Process. The child processes the stream of bytes. Write. The child writes the results as a stream of bytes to the connection. d. Destroy socket. After the client has been served, the child process asks the OS to destroy the temporary socket. Socket interface for Connection-Oriented Concurrent Server

40 Jozef Goetz, 2009 39 Client The client performs the following functions: 1. Create a socket. The client asks the OS operating system to create a socket. 2. Connect. The client asks the operating system to make a connection. 3. Repeat. The client repeats the following steps as long as it has data to send. a. Write. The client sends a stream of bytes to be sent to the server. b. Read. The client receives a stream of bytes from the server. 4. Destroy. After the client has finished, it asks the OS to destroy the socket. The connection is also closed. 4. Socket interface for Connection- Oriented Concurrent Server

41 Jozef Goetz, 2009 40 Client and Server Programs Client-server programs are written in languages such as C, C++, C#, Java, and Perl. This type of programming is very involved and requires an advanced knowledge of programming as well as knowledge of the particular language. see client-server programs in Appendix H ed.3 for those interested readers.


Download ppt "Jozef Goetz, 2009 1 Application Layer PART VI Jozef Goetz, 2009 2 Position of application layer The application layer enables the user, whether human."

Similar presentations


Ads by Google