Introduction to Computer Network
1.1 Introduction To Computer Network
Computer networks have revolutionized out use of computers. They are used in our everyday life, from automated teller machines, to airline reservation systems, to electronic mail services, to electronic bulletin boards. Computer systems used to be stand-alone entities. Each computer was self-contained and had all the peripherals and software required to do a particular job. If a particular feature was needed, such as printer, the printer was attached to the system. If large amount of disk storage were needed, disks were added to the system. What helped change this is the realization that computers and their users need to share information and resources.
Information sharing can be electronic mail or file transfer. Resource sharing can involve accessing a peripheral on another system. In past days this type of sharing took place by exchanging magnetic tapes or a deck of punched cards. Today computers can be connected together using various electronic techniques called networks. A network can be as simple as two computers connected together using a modem or as complex as the TCP/IP Internet, which connects millions of computers together. Some typical network applications are
o Exchange electronic mail with users on other computers
o Exchange files between systems
o Share peripheral devices
o Execute a program on another computer
o Remote login
So in order to develop these types of applications we should know how to write network applications. In this course we will deal with the system functions which are used to develop network applications. Network programming is a subject which deals with writing network applications. Before actually starting to write the network applications we just go through the review of the computer networks and some other network protocols
1.1.1 Layering
Given a particular task that we want to solve, such as providing a way to exchange files between two computers that are connected with a network, we divide the task into pieces and solve each piece. In the end we connect the pieces back together to form the final solution. We could write a single monolithic system to solve the problem, but experience has shown that solving the problem in pieces leads to a better, and more extensible, solution.
It is possible that part of the solution developed for a file transfer program can also be used for a remote printing program. Also, if we're writing the file transfer program assuming the computers are connected with an Ethernet, it could turn out that part of this program is usable for computers connected with a leased telephone line.
In the context of networking, this is called layering. We divide the communication problem into pieces (layers) and let each layer concentrate on providing a particular function. Well-defined interfaces are provided between layers.
Figure 1. Layers, protocols, and interfaces
The layering concept reduces the design complexity of the protocol hierarchies. Each layer or level is built upon the one below it. The number of layers, the name of each layer, the contents of each layer, and the function of each layer differ from network to network. However, in all networks, the purpose of each layer is to offer certain services to the higher layers, shielding those layers from the details of how the offered services are actually implemented.
Layer n on one machine carries on a conversation with layer n on another machine. The rules and conventions used in this conversation are collectively known as the layer n protocol. Basically, a protocol is an agreement between the communication parties on how communication is to proceed.
A five-layer network is illustrated in Figure 1. The entities comprising the corresponding layers on different machines are called peers. Peers communicate using the protocols.
In reality, no data are directly transferred from layer n on one machine to layer n on another machine. Instead, each layer passes data and control information to the layer immediately below it, until the lowest layer is reached. Below layer 1 is the physical medium through which actual communication occurs. In the figure the virtual communication is shown by dotted lines and physical communication by solid lines.
Between each pair of adjacent layers there is an interface. The interface defines which primitive operations and services the lower layer offers to the upper one. When network designers decide how many layers to include in a network and what each one should do, one of the most important considerations is defining clean interfaces between the layers. Doing so, in turn, requires that each layer perform a specific collection of well-understood functions. In addition to minimizing the amount of information that must be passed between layers, clean-cut interfaces also make it simpler to replace the implementation of one layer with a completely different implementation, because all that is required of the new implementation is that it offers exactly the same set of services to its upstairs neighbor as the old implementation did.
A set of layers and protocols is called a network architecture. The specification of an architecture must contain enough information to allow an implementer to write the program or build the hardware for each layer so that will correctly obey the appropriate protocol. Neither the details of the implementation nor the specification of the interfaces are part of the architecture because these are hidden away inside the machines and not visible from the outside. It is not even necessary that the interfaces on all machines in a network be the same, provided that each machine can correctly use all the protocols. A list of the protocols used by certain system, one protocol per layer, is called a protocol stack.
1.1.2 OSI Model
The starting point for describing the layers in a network is the International Standards Organization (ISO) open systems interconnection model (OSI) for computer communications. This is a 7-layer model shown in Figure 1
Figure 2. OSI 7-layer model
The OSI model provides a detailed standard for describing a network. Most computer networks today are described using the OSI model. Later each of the networks protocol stacks is shown against the OSI model.
The transport layer is important because it is the lowest of the seven" layers that provides reliable data transfer between two systems. The layers above the transport layer can assume they have an error-free communications path. Details such as sequence control, error detection, retransmission and flow control are handled by the transport layer and the layers below it.
1.1.3 Processes
A fundamental entity in a computer network is a process. A process is a program that is being executed by the computer's operating system. When we say that two computers are communicating with each other, we mean that two processes, one running on each computer, are in communication with each other.
The only way a new process can be created by the UNIX system is by issuing the fork system call. Some operating systems use the term task instead of process. A multitasking operating system can execute more than one task (process) at a time. Also, it is possible for a single program to be executing as many different processes at the same time.
1.1.4 A Simplified Model
Network programming deals with the top three layers of the OSI model—the session, presentation, and application layers—along with the interface between these three layers and the transport layer beneath them. These three layers are combined into and it is called the process layer. In case of TCP/IP model session and presentation layers are not present and we will mainly deal with the interface with the application and the transport layer. OSI and TCP/IP models are discussed later in this note. Additionally the bottom two layers are combined into a single layer and it is called the data-link layer. A simplified, 4-layer version of the OSI model is illustrated in Figure 3.
In Figure 3 two systems that are connected with a network are shown. The actual connection between the two systems is between the two data-link layers, the solid horizontal line. Although it appears to the two processes that they are communicating with each other (the dashed horizontal line between the two process layers), the actual data flows from the process layer, down to the transport layer, down to the network layer, down to the data-link layer, across the physical network to the other data-link layer, up through the network layer, then the transport layer to the other process.
Layering leads to the definitions of protocols at each layer. Even though physical communication takes place at the lowest layer (the physical layer in the OSI model), protocols exist at every layer. The protocols that are used at a given layer, the four horizontal lines in Figure 3, are also called peer-to-peer protocols to reiterate that they are used between two entities at the same layer. The various protocols at the data-link, network, and transport layers, are discussed here.
Since the data always flows between a given layer and the layer immediately above it or immediately below it, the interfaces between the layers are also important for network programming. The network programming course and the socket API (system call) provide detailed descriptions of two interfaces between the transport layer and the layer above it. The Berkeley socket is the main topics of our discussion. Later we will also deal with the WinSock (Windows Socket) and programming with SPX/IPX.
Figure 3. Simplified 4-layer model
Another feature of the model shown in Figure 3 is that often the layers including the transport layer (layers 1 through 4 of the OS1 model) are included in the host operating system. This is the case for 4.3BSD and System V.
1.1.5 Client-Server Model
The standard model for network applications is the client-server model. A server is a process that is waiting to be contacted by a client process so that the server can do something for the client. A typical (but not mandatory) scenario is as follows:
§ The server process is started on some computer system. It initializes itself, and then goes to sleep waiting for a client process to contact it requesting some service.
§ A client process is started, either on the same system or on another system that is connected to the server's system with a network. Client processes are often initiated by an interactive user entering a command to a time-sharing system. The client process sends a request across the network to the server requesting service of some form. Some examples of the type of service that a server can provide are
o return the time-of-day to the client
o print a file on a printer for the client
o read or write a file on the server's system for the client
o allow the client to login to the server's system
o execute a command for the client on the server's system
- When the server process has finished providing its service to the client, the server goes back to sleep, waiting for the next client request to arrive
We can further divide the server processes into two types.
1. When a client's request can be handled by the server in a known, short amount of time, the server process handles the request itself. We call these iterative servers. A time-of-day service is typically handled in an iterative fashion by the server.
2. When the amount of time to service a request depends on the request itself (so that the server doesn't know ahead of time how much effort it takes to handle each request), the server typically handles it in a concurrent fashion. These are called concurrent servers. A concurrent server invokes another process to handle each client request, so that the original server process can go back to sleep, waiting for the next client request. Naturally, this type of server requires an operating system that allows multiple processes to run at the same time. (More on this in the next chapter.) Most client requests that deal with a file of information (print a file, read or write a file, for example) are handled in a concurrent fashion by the server, as the amount of processing required to handle each request depends on the size of the file.