Java Reference
In-Depth Information
in the North Sea. You'll make still different choices if your clients are on a 3G data plan
where they're charged by the byte for relatively low bandwidth. And if you're writing a
general consumer application that could be used by any of these clients, you'll try to hit
a sweet spot somewhere in the middle, or perhaps even detect and dynamically adapt
to individual client capabilities. However, whichever physical links you encounter, the
APIs you use to communicate across those networks are the same. What makes that
possible is the internet layer.
The Internet Layer
The next layer of the network, and the first that you need to concern yourself with, is
the internet layer . In the OSI model, the internet layer goes by the more generic name
network layer . A network layer protocol defines how bits and bytes of data are organized
into the larger groups called packets, and the addressing scheme by which different
machines find one another. The Internet Protocol (IP) is the most widely used network
layer protocol in the world and the only network layer protocol Java understands.
In fact, it's two protocols: IPv4, which uses 32-bit addresses, and IPv6, which uses 128-
bit addresses and adds a few other technical features to assist with routing. At the time
of this writing, IPv4 still accounts for more than 90% of Internet traffic, but IPv6 is
catching on fast and may well surpass IPv4 before the next edition of this topic. Although
these are two very different network protocols that do not interoperate on the same
network without special gateways and/or tunneling protocols, Java hides almost all of
the differences from you.
In both IPv4 and IPv6, data is sent across the internet layer in packets called data‐
grams . Each IPv4 datagram contains a header between 20 and 60 bytes long and a pay‐
load that contains up to 65,515 bytes of data. (In practice, most IPv4 datagrams are much
smaller, ranging from a few dozen bytes to a little more than eight kilobytes.) An IPv6
datagram contains a larger header and up to four gigabytes of data.
Figure 1-3 shows how the different quantities are arranged in an IPv4 datagram. All bits
and bytes are big endian; most significant to least significant runs left to right.
Search WWH ::




Custom Search