2.1 Networks
A
network
is a collection of computers and other devices that can send data to
and receive data from each other, more or less in real time. A
network is often connected by wires, and the bits of data are turned
into electromagnetic waves that move through the wires. However,
wireless networks transmit data through infrared light and
microwaves, and many long-distance transmissions are now carried over
fiber optic cables that send visible light through glass filaments.
There's nothing sacred about any particular physical
medium for the transmission of data. Theoretically, data could be
transmitted by coal-powered computers that send smoke signals to each
other. The response time (and environmental impact) of such a network
would be rather poor.Each machine on a network is called a
node.
Most nodes are computers, but printers, routers, bridges, gateways,
dumb terminals, and Coca-Cola™ machines can also be
nodes. You might use Java to interface with a Coke machine but
otherwise, you'll mostly talk to other computers.
Nodes that are fully functional computers are also called
hosts.
We will use the word node to refer to any device
on the network, and the word host to refer to a
node that is a general-purpose computer.Every network node has an
address,
a series of bytes that uniquely identify it. You can think of this
group of bytes as a number, but in general the number of bytes in an
address or the ordering of those bytes (big endian or little endian)
is not guaranteed to match any primitive numeric data type in Java.
The more bytes there are in each address, the more addresses there
are available and the more devices that can be connected to the
network simultaneously.Addresses are assigned differently on different kinds of networks.
AppleTalk addresses are chosen randomly at startup by each host. The
host then checks to see if any other machine on the network is using
that address. If another machine is using the address, the host
randomly chooses another, checks to see if that address is already in
use, and so on until it gets one that isn't being
used. Ethernet addresses are attached to the physical Ethernet
hardware. Manufacturers of Ethernet hardware use pre-assigned
manufacturer codes to make sure there are no conflicts between the
addresses in their hardware and the addresses of other
manufacturer's hardware. Each manufacturer is
responsible for making sure it doesn't ship two
Ethernet cards with the same address. Internet addresses are normally
assigned to a computer by the organization that is responsible for
it. However, the addresses that an organization is allowed to choose
for its computers are assigned by the organization's
Internet Service Provider (ISP). ISPs get their IP addresses
from one of four regional Internet Registries (the registry for North
America is ARIN, the American Registry for
Internet Numbers, at http://www.arin.net/), which are in turn
assigned IP addresses by the Internet Corporation for Assigned Names
and Numbers (ICANN, at http://www.icann.org/).On some kinds of networks, nodes also have names that help human
beings identify them. At a set moment in time, a particular name
normally refers to exactly one address. However, names are not locked
to addresses. Names can change while addresses stay the same or
addresses can change while the names stay the same. It is not
uncommon for one address to have several names and it is possible,
though somewhat less common, for one name to refer to several
different addresses.All modern computer networks are
packet-switched
networks: data traveling on the network is broken into chunks called
packets
and each packet is handled separately. Each packet contains
information about who sent it and where it's going.
The most important advantage of breaking data into individually
addressed packets is that packets from many ongoing exchanges can
travel on one wire, which makes it much cheaper to build a network:
many computers can share the same wire without interfering. (In
contrast, when you make a local telephone call within the same
exchange, you have essentially reserved a wire from your phone to the
phone of the person you're calling. When all the
wires are in use, as sometimes happens during a major emergency or
holiday, not everyone who picks up a phone will get a dial tone. If
you stay on the line, you'll eventually get a dial
tone when a line becomes free. In some countries with worse phone
service than the United States, it's not uncommon to
have to wait half an hour or more for a dial tone.) Another advantage
of packets is that checksums can be used to detect whether a packet
was damaged in transit.We're still missing one important piece: some notion
of what computers need to say to pass data back and forth. A
protocol
is a precise set of rules defining how computers communicate: the
format of addresses, how data is split into packets, and so on. There
are many different protocols defining different aspects of network
communication. For example, the Hypertext Transfer Protocol (HTTP)
defines how web browsers and servers communicate; at the other end of
the spectrum, the IEEE 802.3 standard defines a protocol for how bits
are encoded as electrical signals on a particular type of wire (among
other protocols). Open, published protocol standards allow software
and equipment from different vendors to communicate with each other:
your web browser doesn't care whether any given
server is a Unix workstation, a Windows box, or a Macintosh, because
the server and the browser speak the same HTTP protocol regardless of
platform.
• Table of Contents• Index• Reviews• Reader Reviews• Errata• AcademicJava Network Programming, 3rd EditionBy
Elliotte Rusty Harold Publisher: O'ReillyPub Date: October 2004ISBN: 0-596-00721-3Pages: 706
Thoroughly revised to cover all the 100+ significant updates
to Java Developers Kit (JDK) 1.5, Java Network
Programming is a complete introduction to
developing network programs (both applets and applications)
using Java, covering everything from networking fundamentals
to remote method invocation (RMI). It includes chapters on
TCP and UDP sockets, multicasting protocol and content
handlers, servlets, and the new I/O API. This is the
essential resource for any serious Java developer.