IP Addressing


On IP networks, computers and devices identify one another using numerical IP addresses. As mentioned earlier in this chapter, two versions of IP are in use today: IPv4 and IPv6. The next two sections describe IP address formats in more detail.

IPv4 Protocol

The IPv4 protocol was developed in the mid 1970s as a part of the Advanced Research Project Agency (ARPA) of the United States Department of Defense. Ipv4 has become the de facto standard protocol on the Internet. With IPv4, computers are assigned an address that s represented as a 32-bit quantity, formally known as an IPv4 address . All current versions of the Windows operating system support the IPv4 protocol.

IPv4 addresses are typically represented in a dotted decimal format, for example, xxx.xxx.xxx.xxx, where each xxx section is an octet (8 bits) of the address and is converted to a decimal number that s separated by a period (dot). An IPv4 address might look like 172.31.28.120. IPv4 addresses are divided into classes that describe the portion of the address assigned to the network and the portion assigned to actual end points (or computers). Table 7-1 lists the different classes.

Table 7-1: IPv4 Address Classes

Class

Network Portion

First Number

Number of End Points

A

8 bits

0 to 127

16,777,216

B

16 bits

128 to 191

65,536

C

24 bits

192 to 223

256

D

n/a

224 to 239

n/a

E

n/a

240 to 255

n/a

All IP addresses that identify individual computer interfaces (also known as unicast addresses ) can be broken into two parts : the network portion and the host ID. The network portion is the first part of the address, which can be a variable number of bits, and it identifies the specific network a host resides on. The host portion of the address is comprised of the remaining bits in the address and uniquely identifies that computer s interface on the given network. When specifying an IP address, the number of bits indicating the network portion can be appended to the dotted decimal address after a slash mark (/). For example, the address 172.31.28.120/16 indicates that the first 16 bits make up the network portion of the address. This address, followed by the slash, is known as the Classless Interdomain Routing (CIDR) notation, which is equivalent to the netmask . The address 172.31.28.120/16 has an equivalent subnet mask of 255.255.0.0.

The last two entries in Table 7-1 are special classes of IPv4 addresses. Class D addresses are reserved for IPv4 multicasting, and class E addresses are experimental. Also, the following blocks of addresses have been reserved for private use and can t be used by a system on the Internet:

  • 10.0.0.0 to 10.255.255.255 (10.0.0.0/8)

  • 172.16.0.0 to 172.31.255.255 (172.16.0.0/12)

  • 192.168.0.0 to 192.168.255.255 (192.168.0.0/16)

Finally, the loopback address (127.0.0.1) is a special address that refers to the local computer.

To list the IPv4 addresses assigned to a Windows computer, the ipconfig.exe utility on Windows NT, Windows 2000, Windows XP, and Windows Server 2003 will output a list of the IP addresses for all network interfaces on the local computer. For Windows 9x (including Windows Me), the utility for retrieving IPv4 address information is winipcfg.exe.

We ve briefly discussed the breakdown of the IPv4 address space, and within these different address classes are three types of IPv4 addresses: unicast, multicast, and broadcast. There are also two other special address types ”loopback and wildcard. Table 7-2 lists the different types of IPv4 addresses. The next sections will briefly discuss these different types of IPv4 addresses. For a much more detailed discussion of IPv4 networking and addressing, consult The Protocols (TCP/IP Illustrated, Volume 1) by W. Richard Stevens (Addison- Wesley, 1994).

Table 7-2: IPv4 Address Types

Type

Address or Range

Description

Broadcast

255.255.255.255

When data is sent to this address, all computers on the local network will receive it.

Loopback

127.0.0.1

This address represents only the local computer.

Multicast

224.0.0.1 to 239.255.255.255

These are multicast addresses used to send from one source to many recipients.

Unicast

0.0.0.1 to 223.255.255.255

These are unique addresses assigned to a computer s interfaces.

Wildcard

0.0.0.0

Also known as the any address, this address represents all interfaces on the computer.

Although IPv4 addresses are not too large in form, they still can be quite cumbersome to remember when trying to identify computers. Therefore, IP networks can have a DNS service that provides a mapping between a user -friendly name and an IP address. Later in the chapter, we ll show how to use the DNS service to resolve names to addresses.

Unicast Addresses

Unicast addresses are assigned to an individual computer s interface, and only one interface can be assigned that address. If another computer on the network is configured with that address, data will not be delivered correctly. Typically, computers are configured either with a manually assigned IPv4 address or they obtain one from a configuration protocol such as DHCP. If, for some reason, a computer configured to retrieve a DHCP-assigned address can t, the network stack will assign an autoconfigure address in the range of 169.254.0.0/16. An autoconfigure address is valid only on the local network link; it is not routable or valid on the Internet.

The IPv4 unicast address space sets aside several regions that are designed for use on isolated networks, that is, networks not connected directly to the Internet (often intranets ). The following addresses are reserved for intranet uses:

  • 10.0.0.0 to 10.255.255.255 (10.0.0.0/8)

  • 172.16.0.0 to 172.31.255.255 (172.16.0.0/12)

  • 192.168.0.0 to 192.168.255.255 (192.168.0.0/16)

Other than the fact that these addresses can never appear on the Internet, they follow the same rules as regular unicast addresses, such as only one instance of a given intranet address can be present on the local network. These addresses are routable on the private network.

These private addresses are also used by Network Address Translators (NATs), which are commonly found on routers and Digital Subscriber Line (DSL) modems. These addresses are useful when an Internet service provider (ISP) allows a customer only one global IPv4 address, but the customer has several computers on a home network to connect to the Internet. A NAT assigns each computer on the home network one of the private intranet addresses, and the NAT router is assigned the global IPv4 Internet address. The NAT translates communication to and from the home network computers. NATs are useful in this respect, but they can introduce problems, as we will discuss later.

Wildcard Address

The wildcard address is a special address used when an application wants to receive network traffic on any interface on the computer, which is typically the case for server applications. However, if an application wants to operate on a single interface, it uses the unicast IPv4 address assigned to the interface that it s interested in.

Loopback Address

The loopback address is typically used for interprocess communication. If multiple sockets on the sample computer need to communicate with each other, the loopback address is used to establish a connection within the local machine.

Broadcast Address

The broadcast address is used as a destination address when sending data. When data is sent to the broadcast address, every computer on the local network must process that packet to determine if anyone is waiting for broadcast data. It s considered bad practice to design applications that use broadcast data because every machine on the network must process that message when most machines probably do not care about that data.

Multicast Addresses

Multicast addresses are used by applications that need to send data from a single source to many recipients. Unlike broadcast data, multicasting provides a way for applications to register whether they are interested in data sent to a particular multicast address. Multicasting will be discussed in greater detail in the next chapter.

IPv6 Protocol

The IPv6 protocol is a relatively new protocol aimed to replace the IPv4 protocol; it addresses several key limitations of IPv4. First and foremost, the world is running out of IPv4 addresses, which is leading to a proliferation of NAT techniques where multiple computers can share (or hide behind) a single IP address. The problem with NATs is that they break the end-to-end connectivity experience. As mentioned earlier in this chapter, computers behind a NAT are assigned private addresses. Consider the case where you and your buddy want to start an instant messenger “type application. If both computers are behind a NAT, when you connect to your buddy, all you have is your buddy s private IP address, which is not valid to address over the Internet. To circumvent this problem, a central server (that has a valid non-private IPv4 address) needs to be present to route the traffic accordingly . The good thing about IPv6 is that it was designed with a much larger 128-bit address space, which means that there are plenty of addresses for everyone.

Because IPv6 addresses are much bigger than IPv4 addresses, they are represented in hexadecimal form, such as fe80::240:96ff:fe36:d757, where each hex digit represents 4 bits of the address and each 16-bit chunk of the address is separated by a colon. You ll notice our example address has a double colon , which represents zero compression. If there is a series of 16-bit chunks that are all zero, they can be replaced by the double colon. This compression can occur only once in the address.

The IPv6 address space is hierarchical, which means that high-order bits define the address types shown in Table 7-3. For example, a multicast address always starts with a series of consecutive one bits (or 0xFF when viewed in hex). A hierarchical address space simplifies the protocol routing on networks.

IPv6 addresses and host names can also be registered with DNS so that applications can resolve a host name and receive IPv6 addresses in return. Again, we ll talk more about using DNS to resolve names to IP addresses later in the chapter.

Note that the IPv6 protocol is only available on Windows XP and later. Also, the IPv6 sockets are not accessible from the .NET Framework unless explicitly enabled. To enable the IPv6 protocol, edit the machine.config file under %SYSTEMROOT%\Microsoft.Net\Framework\ version \config, where version is the .NET Framework version number in which IPv6 is to be enabled. Versions 1.1.4322 and later support IPv6 sockets. The configuration file is XML based. Search for the ipv6 entry, which looks like this:

 <!--<ipv6enabled="false"/>--> 

Set the property to true , and remove the XML comment tags, <!-- and -->, so that the line looks like this:

 <ipv6enabled="true"/> 

Hopefully, future versions of the .NET Framework will ship with this flag automatically enabled.

The next sections will give a short introduction of the different types of IPv6 addresses. For a comprehensive discussion of the IPv6 protocol, consult Understanding IPv6 by Joseph Davies (Microsoft Press, 2002).

Table 7-3: IPv6 Address Types

Type

Prefix/ Address

Description

Broadcast

n/a

The IPv6 protocol does not support the notion of broadcast data.

Global

001

Address that is globally reachable on the Internet.

Link-local

1111 1110 10

Local address that is not routable but can be used to communicate to other computers on the same network link.

Loopback

::1

Address representing the local computer.

Multicast

1111 1111

Multicast addresses used to send from one source to many recipients.

Site-local

1111 1110 11

Represents addresses that are reachable only in a LAN environment.

Wildcard

::

Also known as the any address; represents all interfaces on the computer.

Unicast Addresses

IPv6 addresses are assigned to interfaces just as the IPv4 protocol addresses are, with a few exceptions. First, a computer with IPv6 installed will have multiple IPv6 unicast addresses assigned to it. By default, all interfaces will be assigned a link-local address regardless of whether a global address is obtained. This address is analogous to the autoconfigure assigned address in IPv4. A link-local address is always prefixed with the hex sequence FE80 . So, fe80::240:96ff:fe36:d757%4 is an example of a local link address.

One thing to note is the %4 at the end of the address. The percent sign indicates a scope ID, while the number 4 indicates that this link-local address is on interface number 4. Link-local addresses such as IPv4 autoconfigure addresses are not routable, meaning that they are valid only on that local network link. So, an application connecting to another computer using link-local addresses must specify the local link on which the remote link-local address can be reached. In Figure 7-1, there are two computers on the same link: computer A with the address fe80::1%1 and computer B with fe80::2%2. If computer A needs to connect to B, A substitutes its local interface from which B is reachable as the scope-id in the destination address, which would be fe80::2%1.

click to expand
Figure 7-1: Connecting using link-local addresses

An interface will always have a link-local address, and it might also have a site-local address, a global address, or both. A site-local address is analogous to the private address ranges in IPv4 except that all IPv6 site-local addresses begin with the prefix FEC0 . Site-local addresses are typically used for corporate intranets where traffic should not be routable to the global Internet. There are IPv6 global addresses that are fully routable and valid everywhere.

Site-local and global addresses can either be manually configured or assigned via router advertisements ”that is, the network infrastructure can assign the network portion of the address and the local computer will create the host portion from the Media Access Control (MAC) address of the interface. The same CIDR notation is used with IPv6 addresses. For example, a router might advertise a site-local prefix of fec0::/48, meaning that the first 48 bits of the address are the network portion of the 128-bit IPv6 address.

Wildcard Address

The IPv6 wildcard address is a double include, which indicates all zeroes and has the same meaning as in IPv4. An application binds to the wildcard address to listen across all interfaces on the local system.

Loopback Address

The IPv6 loopback address is ::1, which indicates all zeroes except that last bit, which is one. The loopback address indicates the local computer.

Broadcast Address

The IPv6 protocol does not support the notion of a broadcast packet ”that is, there s no support for sending a packet that will be received by every computer on the local network. Applications that require this ability should use multicasting because only computers interested in receiving the data would join the same group .

Multicast Addresses

All multicast addresses in IPv6 begin with the prefix 1111 1111 (FF). IPv6 multicasting is very similar to IPv4 multicasting and will be covered in more detail in the next chapter.




Network Programming for the Microsoft. NET Framework
Network Programming for the MicrosoftВ® .NET Framework (Pro-Developer)
ISBN: 073561959X
EAN: 2147483647
Year: 2003
Pages: 121

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