Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This may seem like a basic question but I need to understand IP addresses.

I don't understand why IP addresses are split into network (wires) and nodes (hosts | device).

For example Class A has 8 bits of network and 24 bits of host, where does this fit into the actual IP address.

I am quite stuck on this as I look at examples around the net and they state mainly that the IP is split into network and hosts then each class has different values. But I'm not sure exactly what this means.

would be great if someone could spend a little time to explain.

share|improve this question

migrated from stackoverflow.com Apr 2 '11 at 2:40

This question came from our site for professional and enthusiast programmers.

4 Answers 4

Perhaps this article from Cisco will help.

share|improve this answer

There are two main reasons a host needs to know which portion of its address is the network number and which portion is the host number.

The first reason is so it knows what data link layer (e.g. Ethernet MAC layer) destination address to put on an outgoing packet. If the destination IP address's network section matches the source IP address's network section, then the destination host is directly reachable on the local data link (e.g. it's on the same Ethernet LAN), so the sender can find the destination machine's link-layer address (perhaps via ARP) and put that host's link-layer address in the destination field of the link layer header of the packet. If the network sections of the source and destination IP addresses doesn't match, then the sending host has to send the packet to a router. In that case, the sending host puts the router's link-layer address in the link-layer header.

The second reason is so the host can determine the local network's broadcast address. It does this by filling in all the bits in the host section with ones. So in the case of 192.168.1.0/24, the broadcast address is 192.168.1.255.

The idea of network "classes" (a.k.a. "classful networking") only really mattered from the invention of IPv4 in 1981 until the invention of subnetting and Classless Inter-Domain Routing (CIDR) in 1993. From 1981 to 1993, if the first bit of your IP address was a zero, you knew you were on a Class A network, so the first 8 bits of your address was your network number, and the other 24 were your host number. But this meant sites with Class A networks would have 16.8 million hosts on a single flat network, which was impractical. Even though it's been almost two decades since "Class A", "Class B", and "Class C" really mattered, the names still get kicked around to refer to /8's (16.8 million host networks), /16's (65 thousand host networks), and /24's (~256 host networks), respectively.

share|improve this answer

The reason for the split is that it's rare that you have a direct connection to the computer you want to send something to. The data you send usually goes to a router, which then forwards it to other routers, and so forth until a final router in the chain delivers it to your system.

For this to work, there must be a way of knowing which IP addresses can be reached just by dumping data out of the network card, and which IP addresses can only be reached "behind" a router. The network part of the IP address, determined by the network mask, makes this distinction.

So, if my IP is 10.1.1.42, and my netmask is 24 bits from the left (255.255.255.0), then that means I can reach any IP address from 10.1.1.1 to 10.1.1.254 just by sending data out of my network card. I'll use my IP as the source address, the end machine as the destination address, and just throw the traffic on the wire. It should get there if say, the other machine is connected via a switch or hub, without any further help.

Let's say I want to talk to 10.1.2.50. Well, I can't reach that just by spitting the bits out of my NIC. It has to go through a router. The simplest situation is where there is a default gateway given by DHCP. Let's say the default gateway given to us through DHCP is 10.1.1.254. I'll then send my traffic that I want to go to 10.1.2.50 to 10.1.1.254, putting my IP (10.1.1.42) as a source address and 10.1.2.50 as a destination address. The default gateway is not the ultimate destination, but I'm really expecting 10.1.1.254 to forward the traffic to 10.1.2.50 on my behalf. Hopefully the machine at 10.1.1.254 has a connection to the 10.1.2.0/24 network, and will be able to do that.

I hope this is helpful.

share|improve this answer

Example: 10.0.0.1 /8
where /8 - means network mask. This means that first 8 bits of 32(the adress consists of 32 bits divided by dots and this bits are represented as decimal numbers) identify the network and others - the host

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.