Java Reference
In-Depth Information
TCP, however, carries a fair amount of overhead. Therefore, if the order of the data isn't
particularly important and if the loss of individual packets won't completely corrupt the
data stream, packets are sometimes sent without the guarantees that TCP provides using
the UDP protocol. UDP is an unreliable protocol that does not guarantee that packets
will arrive at their destination or that they will arrive in the same order they were sent.
Although this would be a problem for uses such as file transfer, it is perfectly acceptable
for applications where the loss of some data would go unnoticed by the end user. For
example, losing a few bits from a video or audio signal won't cause much degradation;
it would be a bigger problem if you had to wait for a protocol like TCP to request a
retransmission of missing data. Furthermore, error-correcting codes can be built into
UDP data streams at the application level to account for missing data.
A number of other protocols can run on top of IP. The most commonly requested is
ICMP, the Internet Control Message Protocol, which uses raw IP datagrams to relay
error messages between hosts. The best-known use of this protocol is in the ping pro‐
gram. Java does not support ICMP, nor does it allow the sending of raw IP datagrams
(as opposed to TCP segments or UDP datagrams). The only protocols Java supports are
TCP and UDP, and application layer protocols built on top of these. All other transport
layer, internet layer, and lower layer protocols such as ICMP, IGMP, ARP, RARP, RSVP,
and others can only be implemented in Java programs by linking to native code.
IP Addresses and Domain Names
As a Java programmer, you don't need to worry about the inner workings of IP, but you
do need to know about addressing. Every computer on an IPv4 network is identified by
a four-byte number. This is normally written in a dotted quad format like 199.1.32.90,
where each of the four numbers is one unsigned byte ranging in value from 0 to 255.
Every computer attached to an IPv4 network has a unique four-byte address. When
data is transmitted across the network, the packet's header includes the address of the
machine for which the packet is intended (the destination address) and the address of
the machine that sent the packet (the source address). Routers along the way choose the
best route on which to send the packet by inspecting the destination address. The source
address is included so the recipient will know who to reply to.
There are a little more than four billion possible IP addresses, not even one for every
person on the planet, much less for every computer. To make matters worse, the ad‐
dresses aren't allocated very efficiently. In April 2011, Asia and Australia ran out. No
more IPv4 addresses were available to be allocated to these regions; and they have since
had to make do by recycling and reallocating from their existing supply. In September
2012, Europe ran out too. North America, Latin America, and Africa still have a few IP
address blocks left to parcel out, but they're not going to last much longer.
A slow transition is under way to IPv6, which will use 16-byte addresses. This provides
enough IP addresses to identify every person, every computer, and indeed every device
Search WWH ::




Custom Search