Link to home
Start Free TrialLog in
Avatar of amcandrew
amcandrew

asked on

TCP/IP and NetMasks and Routing Tables

Perhaps someone can help me to understand TCP/IP and subnet masks better.

I have two computers (connected to a cable modem and to each other via a hub, not a router) that have been dynamically assigned (via DHCP) their IP addresses. The addressess are as follows:

Computer A:  xxxx.yyyy.181.97, subnet mask 255.255.248.0

Computer B:  xxxx.yyyy.180.177, subnet mask 255.255.248.0


Now, doing a "bitwise and" between the two addressess and their respective masks, I derive the network to which I belong to be xxxx.yyyy.176.0.

I also note that for computer A the last byte is less than 128 and for computer B the last byte is greater than 128. I know that there can be some significance to this, but have not seen an explanation.

Now, if we limited the IP addresses on the subnet xxxx.yyyy.176.0 to be of the form xxxx.yyyy.176.(1-255) with a subnet mask of 255.255.255.0, then this subnet would only be able to accommodate 255 IP addresses. It looks like the combination of the 181 and the 248 on the subnet mask allows for more IP addresses to be assigned to that subnet? Is that the point?

Now let's say that I wanted to be able to network these two computers together at home. I would want an entry in my routing table for computer A that says that if I am trying to send a packet to computer B, I should send it from computer A. What should that look like and why?:

Destination: ??
Gateway: ??
Genmask: ??
Flags: ??
MSS: 0?
Window: 0?
irtt: 0?
IFace: eth0

Thanks for the help/tutorial.
ASKER CERTIFIED SOLUTION
Avatar of newmang
newmang

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amcandrew
amcandrew

ASKER

Gavin:
Now I think I understand the subnet/host part. I did not realize that one could specify that only 5 of the eight bits in the 3rd byte would be used for the subnet, since almost all of the examples that I have seen have had subnet masks of the form 255.255.0.0.

As to the last question, the two computers that I wish to network together are connected to each other via a hub and they are each connected to the Internet (and to subnet xxxx.yyyy.176.0 via a cable modem). If I want to send a packet from A to B, I see two physical possibilities. First, the packet could go from A out the cable modem to a computer on the subnet (xxx.yyy.176.1? it is the gateway for destination 0.0.0.0) and then come back through the cable modem to computer B. Or, the packet could go directly from A to B, if A knows that it is directly connected to B via the hub.

I think that the second approach would be the best. Can I implement it directly by the following routing table entry on A?:

Destination: xxxx.yyyy.180.177  (i.e. B)
Gateway: xxxx.yyyy.181.97  (i.e. A)
Genmask: xxxx.yyyy.248.0
Flags: U
MSS: 0
Window: 0
irtt: 0
IFace: eth0

Thanks for your assistance thusfar; I will accept your next answer so that you'll get the points you deserve.

Regards,

Alec

You don't need any routing in this case. As newmang stated above, in this case both computers are in the same subnet (same network number and netmask). Therefore each can "see" the other.

In practice what is going to happen when one wants to communicate to the other is that the originating box will broadcast an arp request. All nodes that are on the same subnet will see the broadcast. The arp request is simply the originating box's request to find out what system on the local subnet has the IP it's trying to reach. Basically it's asking "who has 1.2.3.4, tell me". The other system will see the broadcast and respond with its MAC and off they go.

Give the points to newmang. He's answered your question.
But, when I try to ping B (xxxx.yyyy.180.177) from A, I get a message that all packets are lost.

The routing table on A has the following entries (generated by DHCP)

Destination       Gateway           Genmask
XXX.YYY.176.0     0.0.0.0           255.255.248.0
127.0.0.0         0.0.0.0           255.0.0.0
0.0.0.0           xxx.yyy.176.1     0.0.0.0

Note that pinging 127.0.0.0 works fine and I have internet access via my browser. I am a little suspicious of the destination and gateway addresses that are simply 0.0.0.0; maybe that is the way DHCP sets things up so that I do not have access to, cannot ping, any other machine on the cable company's network?
Your routing table is correct for the local network and the default route. The first line says that XXX.YYY.176/255.255.248.0 is a local network and that no gateway is needed. The last line has a destination of 0.0.0.0 (anywhere) and a gateway point to your ISP's router and is the default route for non-local traffic.

If these two boxes are Linux machines you may have installed a default firewall on them. This would prevent pings or anything else from working between the two systems. If that's the case you'll need to modify the firewall rulesets or disable the firewall.
It was a firewall on B. Duh!  Thanks for the help.
Alec

Glad to see it is all working and you understand the addressing.

Just to fill in the background to this.....

In the beginning when the addressing structure was defined no-one had any idea of the "internet". All IP networks were essentially private networks.

There were 3 classes of addressing defined with the difference being the division of the 32 bit address into network and host component parts. These were as follows:

Class A :
8 bits of network address, 24 bits of host address.
1st bit of the address is ALWAYS 0
Addresses range from 1.0.0.0 to 126.255.255.255
Allows for a small number of networks each with huge numbers of hosts.

Class B :
16 bits of network address, 16 bits of host address
1st 2 bits of address ALWAYS 10
Addresses range from 128.0.0.0 to 191.255.255.255
Allows for a medium number of networks each with a medium number of hosts

Class C :
24 bits of network address, 8 bits of host address.
1st 3 bits of address ALWAYS 110
Addresses range from 192.0.0.0 to 223.255.255.255
Allows for large number of networks each with a small number of hosts.

Class D : is reserved for multicasts, starts with 1110 and ranges from 224.0.0.0 to 239.255.255.255

Note that 127.x.x.x addresses are reserved for internal loopback addresses, this explains why you could ping 127.0.0.0 - it never went outside the box.

With the emergence of the internet this addressing structure became very wasteful as many addresses in each network were wasted. What then emerged was the ability to sub-net the address whereby a class B address such as you are using can be subdivided by allowing some of the host part of the address to be used as network address bits.

One entity would be allocated a Class B address (255.255.0.0), they would then subdivide this address into a number of sub-nets by subnetting (in your case 255.255.248.0) and then allocate those networks out to other entities.

This is a very simplified explanation of what's going on here - there is much much more such as super-netting, classless inter-domain routing (CIDR) etc but it should give you a start. There are many books available on the subject if you really want to get down and dirty with this - I've been doing this for 30 years now and I still find out new stuff every day.

Cheers - Gavin
Thanks for the additional background. I think I'll look for a book ("TCP/IP for Dummies"?).


Regards,

Alec