How to understand IP, Mask, Gateway, LAN, VALN, Broadcast, Multicast.

The aim of this article is to fullly understand the IP, mask, gateway, lan, vlan, broadcast, multicast.

Internet Protocol(IP)

It’s easy to understand and I believe your guys are familiar with it. If our computer need to access the network, we need a unique IP address. The IP address have IPv4 and IPv6.

IP component

An IP address have two parts. One is network number. It means that it belongs to which network segment. A network segment is a portion of a computer network. Another is host number. You can identify an unique host with this host number.

IPv4 address

IP addresses are divided into five categories: category A is reserved for government agencies, category B for medium-sized companies, category C for anyone who needs it, category D for multicast, and category E for experiments, each with A different number of addresses.

Category A:

  1. The first byte as network number. The others as host number. The first bit in first byte is fixed with 0.
  2. The range of network number is from 0.0.0.0 to 127.0.0.0. The range of host number is from 0.0.0.0 to 127.255.255.255.
  3. There are private address and reserved address in category A.
    1. 10.x.x.x is private address. which means it can’t be used to access the public network. it can be used in local area network. The range of private address is from 10.0.0.0 to 10.255.255.255.
    2. 127.x.x.x is reserved address. It can be used to test loop.

Category B:

  1. The first two bytes as network number. The others as host number. The first two bits in first byte are fixed with 10.
  2. The range of network number is from 128.0.0.0 to 192.255.0.0. The range of host number is from 128.0.0.0 to 192.255.255.255.
  3. There are private address and reserved address in category B.
    1. 172.16.0.0 to 172.31.255.255 are private address.
    2. 169.254.X.X are reserved address. If you use DHCP to obtain IP address, but you don’t have a DHCP server. so you will get this IP address.
    3. 191.255.255.255 is broadcast address.

Category C:

  1. The first three bytes as network number. The last byte as host number. The first three bits in first byte are fixed 110.
  2. The range of network number is from 192.0.0.0 to 223.255.255.0. The range of host number is from 192.0.0.0 to 223.255.255.255.
  3. There are private address in category C.
    1. 192.168.x.x are private address.

Category D:

  1. There is no network number and host number concept in category D. The first four bits in first byte are fixed with 1110.
  2. The range of address is from 224.0.0.0 to 239.255.255.255.

Category E:

  1. There is no network number and host number concept in category E. The first four bits in first byte are fixed with 11110.
  2. The range of address is from 240.0.0.0 to 255.255.255.254.

Local Area Network(LAN)

How does two PC communicate if they are in the same LAN?

They use MAC address to communicate with each other. If the two PC in the same LAN by switch, they are communicate with each other by MAC address directly. If the two PC in the same LAN by router, they need to use ARP protocal to tranfer IP to MAC address.

  1. According to the mask to decide if they are in the same network segment.(I will talk about mask later).
  2. Using ARP protocal to find the corresponding MAC address of IP address.
  3. Using MAC address to communicate with each other.

Note: The PC in the same LAN can be accessed directly. The PC in different LAN can’t be accessed directly. They need to use router to access.

Virtal Local Area Network(VLAN)

For example, if we have a router which has only one port for terminal connections. Assume the IP address is 192.168.1.1/24. But a company have two departments, they all want to have a subnet. such as 192.168.1.0–127/25 and 192.168.1.128–255/25. But the router’s physical port should only be able to assign an IP address. This allows you to create two sub-interfaces — logical interface implementations — under this physical port use logical interface.

For another example. The ports in a switch have different network segment. It is also the VALN technology.

Mask

For more convenient manage our network, we set network segment(subnet). The IP address is in the same network segment. They can access each other directly. So how do we know if two ips are on the same network segment?

Here we go. There are two methods to know it.

One is Classless Inter-Domain Routing(CIDR). Let me explain it to you. For example, 198.168.5.20/16. It has 16 bits as network number.
198.168.5.20 –> 1100 0110 1010 1000 0000 0101 0001 0100
so the first 16 bits as network number. so the range of host number is from 198.168.0.0 to 198.168.255.255.

Another example. Do in the same network segment?
We can analyze them by representing  them in binary form.
196.76.194.19/20 —> 11000100 01001100 1100 | 0010 00010011
196.76.207.96/20 —> 11000100 01001100 1100 | 1111 01100000
196.76.2.19/20 —> 11000100 01001100 0000 | 0010 00010011
so if the first 20 bits are the same, they are in the same network segment. 196.76.194.19/20 and 196.76.207.96/20 are in the same network segment.

Another is the combination of IP address and Mask. If a IP address is 196.76.194.19. Its binary form is 11000100 01001100 11000010 00010011. The mask is 255.255.255.0. Its binary from is 11111111 11111111 11111111 00000000. so the network number is the result of (196.76.194.19 & 255.255.255.0).
11000100 01001100 11000010 00010011 &
11111111 11111111 11111111 00000000 =
11000100 01001100 11000010 00000000 = 196.76.194.0
The CIDR form is 196.76.194.0/24.

Gateway

So what exactly is a gateway?
A gateway is essentially an IP address from a network to another network. For example, network A and network B, the IP address range of network A is “192.168.1.1~ 192.168.1.254″, and the subnet mask is 255.255.255.0.The IP address range of network B is 192.168.2.1~192.168.2.254”, and the subnet mask is 255.255.255.0. In the absence of a router, TCP/IP communication between the two networks is not possible. Even if the two networks are connected on the same switch (or hub), the TCP/IP protocol determines that the hosts in the two networks are in different networks according to the subnet mask (255.255.255.0). In order to realize the communication between the two networks, the gateway must be used. If the host in network A finds that the destination host of the packet is not in the local network, it forwards the packet to its own gateway, which in turn forwards the packet to the gateway of network B, which in turn forwards the gateway of network B to A host of network B. The process of forwarding packets from network A to network B.

Broadcast

The webcast is routed and sent to each host on the dedicated network. The network field of the IP address defines the network, and the host field is usually all 1, such as 192.168.10.255 .

Multicast

Ethernet frames with a value of 1 in the least-significant bit of the first octet of the destination address are treated as multicast frames and are flooded to all points on the network. This mechanism constitutes multicast at the data link layer. This mechanism is used by IP multicast to achieve one-to-many transmission for IP on Ethernet networks
The basic mechanism of multicast is that when a certain person sends data to a group of people, it does not have to send data to everyone, but sends data to a specific group address for reservation, and all the people who join the group can receive the data.In this way, for the sender, the data can be sent to all receivers only once, greatly reducing the network load and the sender’s burden.

Have fun.

Reference:
https://baike.baidu.com/item/IP%E7%BB%84%E6%92%AD
https://en.wikipedia.org/wiki/Multicast
https://blog.csdn.net/calculatorw/article/details/8199318

Share this article to your social media
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments