2

In Subnet Addressing of TCP/IP Illustrated, Vol. 1: The Protocols, there is description: This makes sense because class A and class B addresses have too many bits allocated for the host ID: 16384 - 2 and 65536 - 2, respectively., I think this is the reason of Subnet Addressing, but I don't know where to find the protocol, which describe the any two hosts can communicate each other only if they have the same network id and subnet id? This is relative to Ethernet? but I did not find the description about it. I know there must be something I missed!

For example, enter image description here

Here, the gateway has 1.4, aix has 1.92, solaris has 1.32, and above thick line, there is 1.0 I don't know whether I can summary my question, Why in LAN, if the first host want ping the second host, the first one is 140.252.1.4, then the second one must be 140.252.1.x?

For making my question clear, I make a test that I connected my mac and Fedora linux directly by cable, then:

Under mac:

 ~ » sudo ifconfig en0 192.168.90.104                          

Under Fedora Linux:

[abelard@bogon ~] ifconfig eno1 192.168.90.197

and execute the flollowing command under mac:

~ » ping 192.168.90.197                                          abelard@localhost
PING 192.168.90.197 (192.168.90.197): 56 data bytes
64 bytes from 192.168.90.197: icmp_seq=0 ttl=64 time=0.803 ms
64 bytes from 192.168.90.197: icmp_seq=1 ttl=64 time=0.602 ms
64 bytes from 192.168.90.197: icmp_seq=2 ttl=64 time=0.606 ms

But when I changed mac's ip into 192.168.91.104:

     ~ » sudo ifconfig en0 192.168.91.104                          

then

~ » ping 192.168.90.197                                       abelard@localhost
PING 192.168.90.197 (192.168.90.197): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

why?

1

An IPv4 address is really just a 32-bit binary number. The entire 32 bits are significant for a host address.

Conceptually an address is divided into two parts: the network part and the host part. The dividing line can be moved by the network mask that determines which bits of an address are for the network part. More recently, the network mask is being replaced with the mask length (address and mask length are a network prefix), and you can easily convert a mask length to a mask by setting the length number of most significant bits to one.

In your example the mask length appears to be 24, but assuming you use 16, that would make the mask 255.255.0.0, meaning the usable network host addresses are from .0.1 to .255.254. If the mask length was 17, then the last usable host number is .127.254, while for 18, it would be .63.254, etc.

You must convert the dotted-decimal notation, that is simply for human readability, into binary to perform your calculations. When you do that, everything becomes obvious. Convert back to dotted-decimal when you are done with your calculations. Remember, IPv4 addresses are really 32-bit binary numbers, and trying to do this in dotted-decimal will lead to confusion and errors.

See this answer for how do do all your IPv4 calculations.


Assuming you have a router that knows how to get to all the other networks, you can actually ping any host address, even hosts not on your network. Traffic is delivered directly from host-to-host by layer-2, e.g. ethernet, on a LAN, but it needs layer-3, e.g. IPv4, to get from one LAN to another LAN.

A host will mask both its address and a destination address to see if both are on the same LAN. If they are, it lets layer-2 deliver directly to the destination. If not, it has layer-2 send to it configured gateway. It is then up to the gateway to get the packets forwarded toward the destination.

| improve this answer | |
  • Thank you Ron Maupin, "Traffic is delivered directly from host-to-host by layer-2, e.g. ethernet, on a LAN" and "A host will mask..." you writen is the answer I wanted, But where to find more official details about it? – abelard2008 Mar 22 '17 at 23:53
  • That actually has nothing to do with IPv4, or any other layer-3 protocol. Ethernet, and some other layer-2 protocols, use MAC addresses. The layer-2 protocols can carry any number of different layer-3 protocols, and they do not really know or care what those are. Neither do the layer-3 protocols care which layer-2 protocols are carrying them. – Ron Maupin Mar 22 '17 at 23:56
  • Thank you, but I am little confused, if this is not relative to layer-3, about the figure of my above post, why the book emphasized the subnet address above and under thick line must be 1 or said ips 124.252.1.x? – abelard2008 Mar 23 '17 at 0:05
  • Your book is about layer-3 (IPv4) and layer-4 (TCP/UDP). These layers don't care about layer-1/2, and IP has been successfully run over some pretty bizarre layer-1/2 combinations, but it doesn't know or care. – Ron Maupin Mar 23 '17 at 0:24
  • 1
    That is about the network. You need to know the network mask or mask length to determine if the devices are on the same layer-3 network. If they are not, the sending host sends to it configured gateway (router). Routers route between networks, and if your two hosts are on two separate networks, you need a router between them. Study the excellent answer in the link of my answer to learn how to determine if your hosts are on the same or different networks. With IP addressing, you must have both an address and a mask (or mask length). With those, you can determine everything else. – Ron Maupin Mar 23 '17 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.