Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

IP addressing

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

One: the structure of IP message

IP message header information is used to instruct network devices to route and fragment messages. Data forwarding within the same network segment can be realized through the link layer, while data forwarding across network segments requires the routing function of network devices. Fragmentation means that when a packet exceeds a certain length, it needs to be divided into different segments so that it can be transmitted in the network.

The header length of the IP message is 20-60 bytes. According to the source and destination IP addresses, it can be determined whether the destination is in the same network segment as the sender. If the two are not on the same network segment, a routing mechanism is required for forwarding across network segments.

Two: IP addressing

IP address is divided into network number and host number

The IPV4 address is a 32-bit binary number, usually expressed in dotted decimal. IP addresses are used to identify devices in the network, and devices with IP addresses can communicate on the same or across network segments. The IP address consists of two parts, the first part is the network number, which identifies the network segment to which the IP address belongs, and the second part is the host number, which is used to uniquely identify a device on the network.

It is important to note that there are two special addresses on each network segment that cannot be assigned to network devices. The first is the network address of the address, the host bits of the IP are all 0, indicating a network segment, the second address is the broadcast address in the network segment, and the message whose destination address is the broadcast address will be received by all the network devices of the network segment. The host bits of the broadcast address are all 1. IP other than the network address and broadcast address can be used as the IP address of the network device.

Binary and hexadecimal are commonly used coding methods

Three: IP classification

IPv4 addresses are divided into five categories A, B, C, D and E, and the network number of each type of address contains a different number of bytes. Class A, B, C addresses can be assigned IP addresses, and the number of networks and hosts supported by each type of address is different. For example, class An addresses can support 126 networks, each network supports 2 ^ 24 host addresses, and the network and broadcast addresses in each network segment cannot be assigned to hosts. Class C addresses support more than 2 million networks, each supporting 256 host addresses, of which 254 can be assigned to hosts.

Class D addresses are multicast addresses. After the host receives a message with a class D address as the destination address, and the host is a member of the group group, it will receive and process the message. Various IP addresses can be distinguished by the bits in the first byte. For example, the highest bit of the first byte of the class An address is fixed at 0, the highest two bits of the first byte of the class B address is 10, the high three bits of the first byte of the class C address is fixed at 110, the high four bits of the first byte of the class D address is fixed at 1110, and the highest four bits of the first byte of the class E address is fixed at 1111.

Some IP addresses in IPv4 are reserved for special purposes. In order to save IPv4 addresses, a specific range of addresses are reserved as private network IP in category B and C address fields. Assigning private network addresses to hosts saves public network addresses and alleviates the shortage of IP addresses. Private network addresses are commonly used in enterprise networks, and private network IP in different enterprise networks can overlap. By default, hosts in the network cannot use the private network IP to communicate with the public network. When you need to communicate with the public network, the private network IP must be converted into the public network IP.

There are also some special IP addresses, such as the loopback address in the 127.0.0.0 network segment, which is used to diagnose whether the network is working properly. The first address 0.0.0.0 in IPv4 represents any network, and the last address in IPV4, 255.255.255.255, is the broadcast address in the network.

Four: subnet mask

The subnet mask is used to distinguish between the network part and the host part. The subnet mask is represented in the same way as the IP address. One represents the network bit, and 0 represents the host bit.

Default subnet mask

The default subnet mask for a Class An address is 8 bits, where the first byte represents the network bit and the other three bytes represent the host bit. The default subnet mask for Class B addresses is 16 bits, so Class B addresses support more networks, but there are fewer host bits, and the default subnet mask for Class C addresses is 24 bits.

Variable length subnet mask (VLSM)

The drawback of classful IP addressing: the use of classful IP addresses in the design of the network will result in address waste.

VLSM: the above problems can be solved by using VLSM, and the network can be divided into multiple subnets by changing the subnet mask. VLSM alleviates the problem of address waste caused by the use of default subnet masks while providing a more efficient addressing scheme for enterprise networks.

Example:

160.200.0.0Compact 16 divides it into 16 subnets

a. Subnetted netmask

2 ^ n = 16 nude 4

255.255.240.0

b. Number of hosts per subnet?

2 ^ (32-20) = 4094

c. The network ID of the smallest and largest subnet?

160.200.0.0/20

160.200.240.0/20

d. The IP range of the largest subnet.

160.200.240.1/20

160.200.255.254/20

e. Divide the largest subnet into 32 subnets. Or the above four requirements

160.200.240.0/20

E.1 subnetted netmask

2 ^ n = 32 nails 5

255.255.11111111.1 0000000

255.255.255.128

E.2 number of hosts per subnet?

2 ^ 7-236

E.3 Network ID of the smallest and largest subnet?

160.200.240.0/25

160.200.255.128/25

E.4 the IP range of the largest subnet.

160.200.255.129/25 160.200.255.254/25

Formula:

1. Calculate the number of networks: 2 ^ variable network ID

two。 Calculate the maximum number of hosts in the network: 2 ^ host ID bits-2

3. Number of subnets = 2 ^ number of bits borrowed from host ID by network ID

Classless inter-domain routing (CIDR)

Advantages: CIDR breaks through the classification boundary of traditional IP addresses, aggregates several routing routes in the routing table into one route, reduces the size of the routing table, and improves the extensibility of the routing table. (it can be understood that the host bit borrows from the network bit, the number of the network decreases, and the host bit increases. It's the reverse of VLSM. )

Five: gateway

In the process of packet forwarding, the forwarding path and the interface to the destination network segment are first needed, and then the message is encapsulated in the Ethernet frame and forwarded through the specified physical interface. If the destination host is not on the same network segment as the source host, the message needs to be forwarded to the gateway first, and then forwarded to the destination network segment through the gateway

A gateway is a device that receives and processes messages sent by the host of the local network segment and forwards them to the destination network segment. To achieve this function, the gateway must know the IP address of the destination network segment. The interface address on the gateway device that connects the local network segment is the gateway address of that network segment.

Six: IP packet slicing

If the length of the message exceeds the maximum length supported by the data link layer, the message needs to be separated into several smaller fragments before it can be transmitted on the link. The process of dividing a message into multiple fragments is called fragmentation. The receiver reorganizes the fragment message according to the identifiers, flags and slice offset fields in the fragment message.

Identity: occupies 16 bits, it is a counter, usually, every time a message is sent, the change value will be increased by 1

Is also used for packet sharding, and the value is the same in several shards of the same packet

Logo (flag): occupies 3 places, currently only the last two places are meaningful

DF: Don't Fragment, the middle bit, sharding is allowed only when DF=0

MF: More Fragment, the highest bit, MF=1 indicates that there are still fragments behind it. MF=0

Represents the last shard

Slice offset: occupies 12 bits, which means that the longer packet is in the original packet after the slicing.

The relative position. The slice offset is in 8 bytes.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report