IP Address of computer network

Source: Internet
Author: User

Classification of IP addresses

The whole internet is a single, abstract network. An IP address is a unique 32-bit identifier that is assigned to every interface on the Internet for every host (or router).

The so-called classified IP address, that is, the IP address is divided into a number of fixed classes, each type of address is composed of two fixed-length fields, one of which is the network number Net-id, which marks the host (or router) connected to the network, a network number must be unique throughout the Internet. The other field is the host number Host-id, which flags the host (or router), and a host number must be unique within the network range indicated by the network number in front of it. Thus, an IP address is unique across the Internet.

Because a router should be connected to at least two networks (so that it can forward IP datagrams from one network to another), a router should have at least two different IP addresses.

Several LANs connected with forwarders or bridges are still a network, so these LANs have the same network number.

routers are routed only based on the network number of the IP address of the destination station .

The two-level IP address can be recorded as:

IP Address:: = {< network number;, < host number;}


Class A, Class B, and Class C addresses are unicast addresses (one -to-one communication) and are most commonly used.

The network number field is preceded by a 1-4-bit category bit, with Class A, Class B, and Class C addresses that are 0, 10, and 110, respectively.

To improve readability, we often represent every 8 bits of a 32-bit IP address in its equivalent decimal number.


The network number field of Class A addresses is one byte and only 7 bits are available (the first bit is fixed to 0), but the network number that can be assigned is 126 (27-2), minus 2 because: first, the address of all 0 in the IP address is a reserved address, which means "this network"; The network number 127 (01111111) retains the inter-process communication as the local software loopback test for this host.

The host number of Class A addresses is 3 bytes, so the maximum number of hosts in each Class A network is 224-2. Reason for minus 2: First, the 0 Host number field indicates that the IP address is the single network address to which this host is connected, and the second, all 1 host Number field represents all hosts on that network.

The network number field for Class B addresses has 2 bytes, but the first two bits are fixed to 10, leaving only 14 bits to be allocated, because two bits are 10 and no network numbers are all 0 or 1, but in fact, Class B network address 128.0.0.0 is not assigned. So the maximum number of networks is 214-1. The maximum number of hosts is 216-2.

Class C addresses have a 3-byte network Number field, the first three bits are fixed bit 110, and 21 bits can be assigned. But in fact 192.0.0.0 is not assigned, so the class C address can be assigned the total number of networks is 221-1, the maximum number of hosts is 28-2.



IP address and hardware address

The hardware address is the address used by the data link layer and the physical layer , and the IP address is the address used by the network layer and the above layers , and is a logical address.


When data is sent, the data is transferred from the upper level to the stratum, and then to the communication link. IP datagrams that use IP addresses are encapsulated as Mac frames once they are delivered to the data link layer. The source and destination addresses used by Mac frames at the time of transmission are hardware addresses, both of which are written at the header of the Mac frame.

A device connected to a communication link accepts a Mac frame based on the hardware address in the Mac frame header. In the data link layer, the IP address hidden in the data of the Mac frame is not visible. The network layer can only find the source IP address and the destination IP address in the header of the IP datagram when the MAC layer data is handed over to the network layer after stripping the first and the end of the Mac frame.


Dividing subnets

A unit that has many physical networks, which divides the physical network that belongs to several subnets (subnet). Dividing subnets is purely a matter within a unit. The unit is still represented as a network on the outside.

The way to divide subnets is to borrow several bits from the host number as the subnet number Subnet-id, and the host number Host-id correspondingly reduce the number of bits. So the level two IP address inside the unit becomes level three IP address: network number, subnet number and host good.

IP Address:: = {< network number, < subnet number;, < host number;}

Any IP datagram that is sent from other networks to a host in this unit is still based on the network number Net-id of the IP datagram, first to find the router connected to the Unit network. The router then finds the destination subnet by the destination network number Net-id and subnet number Subnet-id after it receives the IP datagram. Finally, the IP datagram is delivered directly to the destination host.

Here is an example of how and how to divide a subnet.

Indicates that a unit has a class B IP address, and the network address is 145.13.0.0 (the network number is 145.13).


Now the network is divided into three subnets, where the subnet number is assumed to occupy 8 bits, so the host number is only 8 bits left. The sub-nets are divided into: 145.13.3.0, 145.13.7.0, 145.13.21.0.


After dividing the subnet, the whole network still behaves as a network, its network address is still 145.13.0.0, but the router R1 after receiving the foreign datagram, then forwards it to the corresponding subnet according to the destination address of the datagram.

Assuming that the destination address for a datagram is 145.13.3.10 has reached router R1, how does the router forward it to the subnet 145.13.3.0? This requires the use of a subnet mask (SubnetMask) to implement.

The router will handle the netmask and the destination IP address of the received datagram address 145.13.3.10 for the bitwise "and" operation, to obtain the network address of the subnet to be found.


Subnet mask and IP address after the "and" operation, the host number "filtered" out, only the network number and subnet number.


In fact, the standards of the Internet stipulate that all networks must use subnet masks. The default subnet mask is used even if a network is not divided into subnets. The location of 1 in the default subnet mask is exactly the same as the network number field in the IP address, so the network address of the IP address can be obtained after both "and" operations. The default subnet mask for Class A, Class B, and Class C addresses is fixed:


Example, the known IP address is 141.14.72.24, and the subnet mask is 255.255.192.0. Try to find the network address.

It should be noted that after the network is crossed, the routing table must contain the following three items: destination network address, subnet mask, and next hop address .

The algorithm for router forwarding grouping in the case of subnetting:

(1) Extract the destination IP address from the header of the received packet D.

(2) First use the subnet mask of each network and D to phase "and" to see if the corresponding network address matches. If matched, the packet is delivered directly. Otherwise it is indirect delivery, execution (3).

(3) If there is a specific host route with destination d in the routing table, the packet is routed to the specified next-hop router, otherwise, it is executed (4).

(4) A subnet mask for each row in the routing table and a D phase-by "and", if the result matches the destination network address of the line, the packet is routed to the next-hop router indicated by the row, otherwise, execution (5).

(5) If there is a default route in the routing table, the packet is routed to the default router indicated in the routing table; otherwise, it is executed (6).

(6) Error reporting forwarding packet.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

IP Address of computer network

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.