Section 15.2. An Overview of Networks


[Page 708 (continued)]

15.2. An Overview of Networks

Networking is a broad and complex topic. In a typical computer science curriculum, it is covered in one or more upper-level courses. Nevertheless, in this chapter you can learn enough about networking to be able to use network resources and to design simple Java networking applications.

15.2.1. Network Size and Topology

Computer networks come in a variety of sizes and shapes. A local area network (LAN) is usually a privately owned network located within a single office or a single organization. Your campus network would be an example of a LAN. A wide area network (WAN) spans a wide geographical distance like a country or a continent. It may use a combination of public, private, and leased communication devices. Some of the large commercial networks, such as MCI and Sprint, are examples of WANs.

The computers that make up a network can be arranged in a variety of topologies, or shapes, some of the most common of which are shown in Figures 15.1 and 15.2. As you would expect, different topologies use different techniques for transmitting information from computer to computer.

Figure 15.1. Star, bus, and ring topologies.


Figure 15.2. Tree and fully connected mesh topologies.
(This item is displayed on page 709 in the print version)


Network topology


In a star network (Fig. 15.1), a central computer functions as a hub to which every other computer in the network is connected. Each computer can communicate with the others but only through the hub. The bus topology doesn't have a hub computer. Instead, each node looks at each message sent on the bus to find those that are addressed to it. In sending a message, a node waits until the bus is free and then transmits the message.


[Page 709]

A ring network (Fig. 15.1) also has no host, and the computers are connected in a loop through which they exchange information. The tree topology (Fig. 15.2) is organized into a hierarchy, with each level (trunk of the tree, major branch of the tree) controlled by a hub. The fully connected mesh network directly connects all points to all points, eliminating the "middleman." Here there is no need to go through one or more other computers in order to communicate with a particular computer in the network.

Network topologies differ quite a bit in the expense of the wiring they require, their efficiency, their susceptibility to failure, and the types of protocols they use. These differences are beyond the scope of this chapter.

15.2.2. Internets

An internet (lowercase i) is a collection of two or more distinct networks joined by devices called routers (Fig. 15.3). An internet is like a meeting of the United Nations. Each country sends a delegation whose members all speak that country's language. A national delegation is like a single computer network. Language interpreters take on the task of translating one language to another so that any two delegations, say, the United States and China, can communicate. The routers play a similar translation role within an internet. The UN conference, composed of communicating delegations from all the different countries of the world, is like a worldwide internet.


[Page 710]

Figure 15.3. An internet is a collection of networks joined together by routers.
(This item is displayed on page 709 in the print version)


An internet vs. the Internet


The United Nations is an apt analogy for the Internet (uppercase I), which is an example of a worldwide internet. Internets, in the generic sense, should not be confused with the Internet. It is quite likely that your campus LAN is itself composed of several smaller networks, each of which uses its own "language."

Self-Study Exercises

Exercise 15.1

In a network of 10 computers, which topology would require the most cables?

Exercise 15.2

Which topology would be most resistant to having one of its computers crash?

Exercise 15.3

Which topology would be least resistant to having one of its computers crash?

15.2.3. Network Protocols

A protocol is a set of rules that governs the communication of information. For example, the World Wide Web is based on the HyperText Transfer Protocol (HTTP). HTTP describes how information is to be exchanged between a Web browser, such as Internet Explorer or Netscape Navigator, and a Web server that stores an individual's or company's Web pages. Web pages are encoded in the HyperText Markup Language (HTML). Among other things, the HTTP protocol can interpret HTML pages.

Network protocols


Similarly, the Simple Mail Transfer Protocol (SMTP) is a set of rules that governs the transfer of e-mail. And the File Transfer Protocol (FTP) is the protocol that governs the transfer of files across the Internet.

Application Protocols

HTTP, SMTP, and FTP are examples of application protocols. They are relatively high-level protocols that support and govern a particular network application, such as e-mail or WWW access. Among other things, they determine how we address different computers on the network. For example, the HTTP protocol specifies Web addresses by using a Uniform Resource Locator (URL). A URL specifies three necessary bits of information: the method used to transfer information (e.g., HTTP or FTP), the address of the host computer (e.g., www.prenhall.com), and the path describing where the file is located on the host (/morelli/index.html):

METHOD:  // HOST/PATH HTTP:    // www.prenhall.com/morelli/index.html 


Similarly, an e-mail address is specified by the SMTP protocol to consist of a local mailbox address (George.W.Bush) followed by the address of the computer (mail.whitehouse.gov):

LOCAL_MAILBOX@COMPUTER George.W.Bush@mail.whitehouse.gov 



[Page 711]

Another good example of an application protocol is the Internet's Domain Name System (DNS), which is the system that governs how names, such as whitehouse.gov and java.trincoll.edu, can be translated into numeric addresses. In the DNS, each host computer on the Internet is identified with a unique host namefor example, mail, javawhich is usually made up by the network administrator whose job it is to manage an organization's network. The DNS divides the entire Internet into a hierarchy of domains and subdomains. The generic domains are names like com, edu, and mil, which refer to the type of organizationcommercial, educational, and military, respectively. In addition, there are country domains, such as fr, au, and nz, for France, Australia, and New Zealand. Finally, individuals and organizations can buy their own domain names, such as whitehouse, microsoft, and TRincoll.

Internet domain names


What makes the whole system work is that certain computers within the network are designated as DNS servers. It is their role to translate names such as java.trincoll.edu to numeric addresses whenever they are requested to do so by clients such as the SMTP or the HTTP server. The DNS servers must also communicate among themselves to make sure that their databases of names and addresses are up-to-date.

Self-Study Exercise

Exercise 15.4

What is the URL of the Web server at Prentice Hall? Identify its component partshost name, domain name, Internet domain.

15.2.4. Client/Server Applications

The HTTP, FTP, SMTP, and DNS protocols are examples of client/server protocols, and the applications they support are examples of client/server applications. In general, a client/server application is one in which the task at hand has been divided into two subtasks, one performed by the client and one performed by the server (Fig. 15.4).

Figure 15.4. Client/server application.


For example, in the HTTP case, the Web browser plays the role of a client by requesting a Web page from a Web (HTTP) server. A Web server is just a computer that runs HTTP softwarea program that implements the HTTP protocol. For e-mail, the program you use to read your e-mailEudora, Pine, or Outlookis an e-mail client. It requests certain services, such as send mail or get mail, from an e-mail (SMTP) server, which is simply a computer that runs SMTP software. In the FTP case, to transfer a program from one computer to another, you would use an FTP client, such as Fetch. Finally, in the DNS case, the DNS servers handle requests for name to address translations that come from HTTP, FTP, and SMTP servers, acting in this case like clients.

So we can say that a client/server application is one that observes the following protocol:

Server: Set up a service on a particular host computer. Client: Contact the server and request the service. Server: Accept a request from a client and provide the service. 



[Page 712]

As these examples illustrate, many Internet applications are designed as client/server applications.

Effective Design: Divide and Conquer

The client/server protocol is an example of the effective use of the divide-and-conquer strategy.


Self-Study Exercise

Exercise 15.5

Many of our everyday interactions fit into the client/server model. Suppose you are the client in the following services:

  • Buying a piece of software at a bookstore.

  • Buying a piece of software over the phone.

  • Buying a piece of software over the Internet.

Identify the server and then describe the basic protocol.

15.2.5. Lower-Level Network Protocols

Modern computer networks, such as the Internet, are organized into a number of levels of software and hardware. Each level has its own collection of protocols (Fig. 15.5).

Figure 15.5. Levels of network protocols.


The application level, which contains the HTTP, FTP, SMTP, and DNS protocols, is the highest level. Underlying the application-level protocols are various transmission protocols, such as the Transfer Control Protocol (TCP) and the User Datagram Protocol (UDP). These protocols govern the transfer of large blocks of information, or packets, between networked computers. All of the applications we have mentionedWWW, e-mail, and file transferinvolve data transmission and, therefore, rely on one or more of the transmission protocols.

Packet transfer


At the very lowest end of this hierarchy of protocols are those that govern the transmission of bits, or electronic pulses, over wires and those that govern the delivery of data from node to node. Most of these protocols are built right into the hardwarethe wires, connectors, transmission devicesthat networks use. On top of these are protocols, such as the ethernet protocol and the token ring protocol, that govern the delivery of packets of information on a local area network. These too may be built right into the network hardware.


[Page 713]

As you might expect, these lower-level protocols are vastly different from each other. An ethernet network cannot talk directly to a token ring network. How can we connect such disparate networks together? Think again of our United Nations analogy. How do we get French-speaking networks to communicate with English-speaking networks? The answer supplied by the Internet is to use the Internetworking Protocol (IP), which governs the task of translating one network protocol to a common format (Fig. 15.6).

Figure 15.6. Routers between individual networks use the IP protocol to translate one network protocol to another.


Disparate protocols


To push the UN analogy a bit further, the Internet's IP is like a universal language built into the routers that transmit data between disparate networks. On one end of a transmission, a router takes a French packet of information received from one of the delegates in its network. The router translates the French packet into an IP packet, which it then sends on through the network to its destination. When the IP packet gets close to its destination, another router takes it and translates it into an English packet before sending it on to its destination on its network.

The Internet protocol


15.2.6. The java.net Package

As we have seen, networks are glued together by a vast array of protocols. Most of these protocols are implemented in software that runs on general-purpose computers. You can install software on your personal computer to turn it into a Web server, an FTP server, or an e-mail server. Some of the lower-level protocols are implemented in software that runs on special-purpose computers, the routers. Still other protocols, such as the ethernet protocol, are implemented directly in hardware.

Fortunately, we don't have to worry about the details of even the highest-level protocols in order to write client/server applications in Java. The java.net (Fig. 15.7) package supplies a powerful and easy-to-use set of classes that supports network programming.

Figure 15.7. The java.net package.
(This item is displayed on page 714 in the print version)


The java.net.URL class provides a representation of the Internet's Uniform Resource Locator that we described earlier. We will show how to use its methods to download WWW pages. We will also look at an example that uses a URL and an input stream so that files stored on the Web can be used as input files to a Java applet or application program.

java.net.*


The Socket and ServerSocket classes provide methods that let us develop our own networking applications. They enable us to make a direct connection to an Internet host, and read and write data through InputStreams and OutputStreams. As we will see, this is no more difficult than reading and writing data to and from files. The DatagramPacket and DatagramSocket classes provide support even for lower-level networking applications, based on Internet packets.




Java, Java, Java(c) Object-Orienting Problem Solving
Java, Java, Java, Object-Oriented Problem Solving (3rd Edition)
ISBN: 0131474340
EAN: 2147483647
Year: 2005
Pages: 275

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net