|
Your PC receives a unique Internet Postal address (IP
number) from your ISP (Internet service provider). This
number either stays the same (is STATIC) or changes
every time you logon (dynamic assignment). Your ISP has
a block of such numbers, which are allocated by their
upstream provider. At the top of the hierarchy for IP
number allocations are the three regional registries:
APNIC for Asia and the Pacific (www.apnic.net), RIPE
for Europe (www.ripe.net), and ARIN (www.arin.net), the
American Registry for Internet Numbers, for the
Americas and part of Africa. These agencies work in
conjunction with the Internet Assigned Numbers
Authority (www.iana.org), currently funded by the U.S.
government's National Science Foundation.
To make it possible to assign IP numbers dynamically,
in 1993 the Internet Engineering Task Force came up
with the idea of the Dynamic Host Configuration
Protocol, more commonly known as DHCP. DHCP was
designed specifically to allow greater allocation
flexibility than earlier protocols such as BOOTP (the
old Bootstrap Protocol). DHCP is in fact based on
BOOTP, but it offers many extended features, including
the ability to lease IP numbers for limited periods of
time, thereby allowing the DHCP server to recover and
reuse those numbers.
Providing IP addresses to dial-in accounts is probably
the most common use of DHCP, but it is not the only
one. For example, you can also use DHCP to let
computers on your LAN share an Internet connection.
Microsoft Windows 98 Second Edition offers this
configuration through a feature known as Internet
Connection Sharing (ICS). When installed, ICS acts as a
DHCP server to the computers on the LAN, dynamically
assigning them IP addresses from a pool of IP numbers
in the 192.168.x.x range, which has been reserved for
use in private networks. The computer on the LAN that
serves these numbers in turn obtains an IP address
through DHCP (from its ISP) and in effect shares this
IP number with the rest of the LAN. It processes each
client request to the Internet as if the request were
coming from the IP number, using the private IP numbers
to keep track of which LAN client made the request and
should receive the response. But enough of this for
now. Read at the end of this article for more info
on how DHCP works.
The Internet Assigned Numbers Authority (IANA) has
reserved the following Class ranges of IPv4 addresses
(dot quads - 4 bytes - 32 bits) for use in PRIVATE
Networks:
Class A: 10.0.0.1 - 10.255.255.254
Class ?: 90.0.0.0 - 90.255.255.254
Class B: 172.16.0.1 - 172.31.255.254
Class C: 192.168.0.1 - 192.168.255.254
Because these addresses are reserved as private, no
hosts on the Internet will ever use addresses in any of
these ranges. Similarly, the main routers on the
Internet backbone will not pass packets with such
addresses. There will be many other private networks
using the same ranges, but they can never clash with
one another.
An important concept to understand about Internet
addresses is that every Internet address has a "network
part" and a "host part". You cannot tell which part is
the network part and which part is the host part
without using something called a "subnet mask". The
result of ANDing the IP with the mask is the Network
Address.
Where the subnet mask bit fields are a binary "one",
the bits are network bits. Where the subnet mask is a
binary "zero", the bits are host bits. The network part
is the leftmost part and the host part is the rightmost
part of the address. The binary value for decimal 255
is 1111-1111.
Example:
Addr=211.178.101.117
Mask=255.255.255.0
Results: 211.178.101 is Network
and 117 is Host on that Network
Examples of private network addresses are:
10.0.0.1, 10.0.0.2, 10.0.0.3
using a subnet mask of 255.0.0.0
172.16.0.1 thru 172.31.255.254
using a subnet mask of 255.255.0.0
192.168.0.1, 192.168.0.2, 192.168.0.3
using a subnet mask 255.255.255.0
There are five classes of Public Domains, A, B, C, D and E.
The Network Class is denoted in the first
or leftmost Octet of the IP (or dot quad).
001 thru 126 denotes A class
128 thru 191 denotes B class
192 thru 223 denotes C class - most small local ISP's
224 thru 239 denotes D class - used for broadcasting
240 thru 255 denotes E class - unused or experimental
Class A "address ranges" also use only the first octet to
identify the network, and this lies in the range 1 to
126 (ie, 1.0.0.0 to 126.0.0.0); the matching subnet
mask is 255.0.0.0 There are 126 (16,777,216) addresses
in a class A network. All 126 of the class A ranges
have been allocated.
Note that the 127.0.0.0 range is reserved for loopback
(the internal logical IP network via which any machine
running IP may address itself).
Class B address ranges use the first two octets for the
network number, and the first octet must be in the
range 128 to 191; the subnet mask is 255.255.0.0. There
are 16,000 (65,536) addresses in a class B network; a
subnet mask of 255.255.0.0 is used. Most of the class B
ranges have been allocated.
Class C address ranges use the first three octets for
the network number, and the first octet must be between
223 and 192. There are 2,000,000 (256) addresses in a
class C range; the subnet mask of 255.255.255.0 is
used.
Class D is between 224.0.0.0 and 239.0.0.0 and is used
for IP multicast, a form of broadcasting.
Class E (Experimental) reserves values from 240.0.0.0
to 255.0.0.0, which currently are not used.
Certain values are reserved and may not be used. "0"
(zero) refers to an entire network; for example,
192.168.24.0 means the range of addresses from
192.168.24.1 to 192.168.24.254, and 192.0.0.0 refers to
the 192.0.0.1 to 192.255.255.255 range. A machine
therefore may not be given an address ending in 0
(zero). Similarly, 255 is the “broadcast address”: a
packet sent to 192.169.24.255 will be picked up by all
machines in the 192.168.24.0 network. Thus, 255 may not
be used in the address.
IPv6 or 128 bit addresses are being implemented.
Standardized TCP/IP Port assignments:
By international agreements, the standard ports cover
the range of numbers from 0 through 1023. Various
Clients Communicate on the following default Ports.
TELNET talks on port 23
E-MAIL talks on port 25 (smtp) and 110 (pop3)
HTTP talks on port 80
NNTP talks on port 119
FTP talks on port 21
All port numbers are stored in 16 bit Integers.
Registered ports are numbered from 1024 through 49151.
The remaining ports, referred to as dynamic ports or
private ports, are numbered from 49152 through 65535.
Here is some additional help if you are creating a new
client - server application and picking operating
ports:
Ports 1-1023 are off-limits to people inventing new
protocols. They are reserved by the IANA for new
"standard" protocols. Important protocols like POP3 and
HTTP have low numbers (110 and 80, respectively), but
your new K-RAD game server shouldn't. Note that id
Software is going to Hell for using port 666 with their
DOOM network server. They cleaned up their act with
Quake, though.
Ports 1024 through 49151 are Registered Ports, which
are a good range to choose your ports from. Just beware
that the entire world is choosing from ports in this
range, so it may make sense for you to register your
port, or at least check the current list of assigned
ports. Just be aware that no one is obligated to check
that list before they make up their app's port number.
Ports 49152 through 65535 are Dynamic Ports, meaning
that operating systems use ports in this range when
choosing random ports. (The FTP protocol, for example,
uses random ports in the data transfer phase.) This is
a poor range to choose ports from, because there's a
fairly decent chance that your program and the OS will
fight over a given port eventually.
Many OSes pick local ports for client programs from the
1024-5000 range. You would do well to pick server ports
higher than 5000, but this is not as rigid a rule as
the previous ones.
Within the "safe" 5000-49151 range, there are many
numbers the IANA shows as unregistered. Of these, you
should avoid port numbers with patterns to them, or a
widely-recognized meaning. People tend to pick these
since they're easy to remember, but this increases the
chances of a collision. Ports 6969, 5150 and 22222 are
bad choices, for example.
You should also give some thought to making your
program's port configurable, in case your program is
run on a machine where another server is already using
that port.
Fully Qualified Domain Name
Extension Conventions:
arpa --- Advanced Projects Research Agency
com ---- Commercial/Busineses
edu ---- Education/Universities
gov ---- Government
int ---- International
mil ---- Military
net ---- Networks Organizations and ISP's
org ---- Non Profit Organizations
Example: - london-college.edu.gb
Example: - keesler.af.mil
The 7 proposed new extension are:
arts ---- cultural and entertainment entities
firm ---- businesses or firms
info ---- entities providing information services
nom ----- individual or personal designation
rec ----- recreational or entertainment entities
store --- businesses offering goods for purchase
web ----- entities related to the World Wide Web
NOTE: The two letter country code designator list below
may not be complete!
ae ---- United Arab Emirates
ai ---- Anguilla
ar ---- Argentine Republic
at ---- Austria
au ---- Australia
be ---- Belgium
bg ---- Bulgaria
bh ---- Finland
bm ---- Bermuda
bo ---- Bolivia
br ---- Brazil
ca ---- Canada
ch ---- Switzerland
cl ---- Chile
cn ---- People's Republic of China
co ---- Colombia
cr ---- Costa Rica
cy ---- Cyprus
cz ---- Czech Republic
de ---- Federal Republic of Germany
dk ---- Denmark
do ---- Dominican Republic
ec ---- Ecuador
ee ---- Estonia
eg ---- Arab Republic of Egypt
es ---- Spain
fi ---- Finland
fj ---- Fiji
fo ---- Faroe Islands
fr ---- France
gb ---- Great Britain
ge ---- Georgia
gl ---- Greenland
gr ---- Greece
gu ---- Guam
hk ---- Hong Kong
hr ---- Croatia / Hrvatska
hu ---- Hungary
id ---- Indonesia
ie ---- Ireland
il ---- Israel
in ---- India
is ---- Iceland
it ---- Italian Republic
jm ---- Jamaica
jo ---- Kingdom of Jordan
jp ---- Japan
kr ---- Korea
kw ---- Kuwait
ky ---- Cayman Islands
kz ---- Kazakhstan
lc ---- Saint Lucia
li ---- Principality of Liechtenstein
lt ---- Lithuania
lu ---- Grand Duchy of Luxembourg
lv ---- Latvia
mo ---- Macau (Ao-me'n)
mt ---- Malta
mx ---- United Mexican States
my ---- Malaysia
ni ---- Nicaragua
nl ---- Netherlands
no ---- Norway
nz ---- New Zealand
pa ---- Panama
pe ---- Peru
ph ---- Philippines
pl ---- Poland
pt ---- Portuguese Republic
ro ---- Romainia
ru ---- Russian Federation
se ---- Sweden
sg ---- Singapore
si ---- Slovenia
sk ---- Slovakia
su ---- Union of Soviet Socialist Republics
th ---- Thailand
tr ---- Turkey
tt ---- Trinidad & Tobago
tw ---- Taiwan
ua ---- Ukraine
ug ---- Uganda
uk ---- United Kingdom of Great Britain
us ---- United States of America
uy ---- Uruguay
ve ---- Venezuela
za ---- South Africa
zm ---- Zambia
WHAT IS DHCP and HOW does it WORK?
DHCP is a client/server protocol (as are TCP/IP, HTTP,
FTP, and other Internet protocols). A DHCP client makes
requests of a DHCP server, which responds to the client
in preconfigured ways. A computer acts as a DHCP client
if its IP address is set to 0.0.0.0, or in Windows'
case if its TCP/IP settings are configured for
"Server Assigned IP address". When the client connects
to the network, a four-phase DHCP communication takes
place. From this point on, we'll look only at a
situation in which a computer dials in to an ISP, but
all other DHCP allocations operate by the same
principles.
The first phase is initialization. Because the client
does not have an IP address but requires one in order
to perform Internet actions (such as connection to a
Web site), it must locate a DHCP server that will issue
one. In our dial-in case, the client connects to the
modem, then broadcasts a DHCPDISCOVER message over the
line and onto the network to locate a server. If the
ISP has more than one DHCP server, all available units
respond to the request by sending a DHCPOFFER packet
that contains an IP address and an offer of lease
length. The lease length, established by the server's
administrator, is the length of time the client can
have the IP address.
The client responds with a DHCPREQUEST broadcast
indicating which server's DHCPOFFER it will accept. The
broadcast is necessary so that all other servers know
they won't be needed and can stop waiting for a
response. The accepted server finishes the
initialization phase by issuing an acknowledgment in
the form of a DHCPACK message, assigning the IP address
and the duration of the lease. If the offered IP
address has become unavailable in the meantime (because
of timing), the server sends a DHCPNAK
(nonacknowledgment) message instead, forcing the client
to start over with a DHCPDISCOVER broadcast. In fact,
the client might initiate this new broadcast on its
own: After receiving the DHCPACK packet, it issues an
Address Resolution Protocol (ARP) broadcast to the
network to determine if the offered IP address is in
use (again, because of the timing). If the address is
in use, the client will send a DHCPDECLINE message to
the offering server and immediately send a new
DHCPDISCOVER message.
Next come the renewal and rebinding phases. As
mentioned, a lease is the amount of time the server
will let the client use the IP address for. Leases can
be set for a very brief period of time, unlimited time,
or anything in between. The reason the lease time isn't
simply called "expiry time" is that leases can be
renewed as the connection is in progress.
The DHCP client (not the server) operates two timers,
T1 and T2. By default, T1 is set at 50 percent of the
lease time and T2 at 87.5 percent. When the lease has
reached the T1 point, the client enters the renewal
phase, issuing a DHCPREQUEST packet to the currently
granting server asking for a new lease. If the server
responds with a DHCPACK packet, the lease is renewed
and T1 and T2 change accordingly (the original T2 is
never reached). If the server does not respond, the
client will continue using the current IP address until
it reaches T2. At this point, the client enters the
rebinding phase and broadcasts a DHCPREQUEST packet to
all the servers. Any server that responds with a
DHCPACK renews the lease and then becomes the current
granting server. If no server responds, the lease
expires and the client no longer has an IP number.
Basically, it's just been kicked off the Internet.
The final phase is called (perhaps optimistically)
"graceful shutdown" and occurs when a client no longer
needs the assigned IP address. The client issues a
DHCPRELEASE message, telling the server that it can
have its IP number back. As you might expect,
gracefulness is not always the way things happen; if
somebody picks up the phone line and cuts you off, your
ISP's server has to wait until your computer's next T2
point to reclaim the address.
DHCP is not a complex protocol, and setting up a DHCP
client is easy. But there's no mistaking the importance
of this protocol. Without it, IP address allocation and
configuration would be much more difficult for both
user and administrator, and IP numbers, already in
short supply, would run out much more quickly.
|