thank you for coming back to part two we’re going to take what you learned in part one and build on it with some more advanced concepts we’re still going to stick with ipv4 only throughout this article.
At the end of part 1 we talked about classless inter-domain routing or cider that’s where we use a subnet mask to break a network into smaller better sized sub networks this helps us to conserve IP addresses we can build on this by introducing to you a concept called variable length subnet mask or vlsm this helps us to conserve even more IP addresses let’s take our 1 7 to 1600 / 16 network as an example again we previously spoke about breaking it up into 256 / 24 networks we did this because we had several smaller offices rather than one large one now we have 256 IPS in each Network but we also have links between our offices these are also a kind of network they may be very small though with only a router at each end no printers workstations or anything like that if these networks are all slash 24s we’re wasting over 200 IP addresses per link what we can do instead is choose one of our slash 24 networks and break it up even further maybe we could break it into slash 30s a slash 30 network uses 30 bits for the network and 2 bits for the host that’s 4 IP addresses in each network this allows for our two routers with two IPS to spare I’ll talk about why we’re keeping to spare a little later on now our original network 1 7 – 1600 slash 16 has been broken into subnets of different sizes some are slash twenty fours and others are slash 30 and that’s all vlsm is it’s creating subnets of different sizes.
All the IP addresses that we have spoken about so far are addresses that are assigned to devices as you know these are also called host addresses often our devices only want to send traffic to one other device at a time this is called unicast traffic you can think of this as being in a room full of people and you single one of them out and you have a conversation with only one person and ignore everyone else but that’s just common sense right is in traffic always between two devices no not always sometimes the device will want to send a message to every other device in the local network this may happen if it want a particular resource but it doesn’t know where it is it may broadcast a message asking who owns this resource or where can I find this as I’ve just hinted this is called broadcast traffic imagine you’re back in that room full of people and someone gets up to the microphone and makes an announcement they’re sending a message to everyone at once to broadcast to every device we have a special IP address I’m sure you won’t be surprised to find that it’s called the broadcast IP so which IP is the broadcast IP it is the very last IP in the local network always the last IP address is the IP where all host bits are turned on taking the 172 16 2.0 / 24 network as an example the last IP is 170 216 to 255 so as this is special you can never configure a device with a broadcast IP and what we’re talking about addresses that you can’t allocate to devices there’s another one and that’s called the network address the network address is kind of the opposite to the broadcast address it is when all the host bits are set to 0 so 172 16.2 dot 0/24 is a network address remember just a few minutes ago when we said we can use a slash 30 Network between our offices I said that we would need two addresses to spare that’s because of the network and the broadcast addresses a skill you will want to develop is working out what these addresses are in any network as well as how many dresses you can actually use let’s take an example you have a device with the IP 1 7 2 16 0 10 / 24 from the / 24 we can see that the first three octet are the network and the last octet are the host bits if we set all host bits to 0 we have 1 7 to 1600 that’s the network address if all the host bits are set to 1 we have 1 7 to 16 0 255 that’s the broadcast address 8 host bits mean there is a maximum of 256 addresses we subtract our two special addresses and find that we have 254 useable IPS on this network now that’s not too hard to work out on a / 24 network but when vlsm enters the picture it can get a little more complicated imagine that a device has an IP of 10.40 2.37 dot 12/20 – this is a much more complicated example while you can sit down and work out all the different ones and zeros there’s another method that many people find easier and it’s called the magic number method we start with our IP address and we work out the subnet mask a slash 22 has 22 ones so we get to a subnet mask of 255 255 – 5 – 0 now I’ll find the octet in the subnet mask that we need to work with it’s going to be the one that’s got a mixture of ones and zeros so the third octet in our case subtract this value from 256 for us 256 – 252 is 4 now we need to know the value of the third octet in our IP that’s 37 in our case we count by four until we find the numbers that are next to the value of the third octet in our IP that means we want the numbers immediately smaller and larger than 37 if we count by four that’s 36 and 40 36 is the start of the network that gives us the network address 40 is the start of the next network so we can go back one IP and that gives us the broadcast we know there are 10 host bits that gives us 1,024 IP addresses subtract our two special addresses and we have 1022 usable IPS on this network now that is a lot to take in go over it a few times and practice in fact try a few right now see if you can work out the network address the broadcast address and the number of usable IPs for these networks here we know that the router helps to get traffic from one network to another we also discussed how a device knows when to ask the router for help but how do devices find the router how do they know where to send their traffic when they need help when we configure an IP address on a say a Windows machine we will also configure a default gateway this is the local routers IP address so when a host has no way of sending traffic to this destination on its own it will forward it to the default gateway some device is called the default gateway the Gateway of last resort I kind of like this term because it really shows us what this IP address is for if a host runs out of options to handle their data itself as a last resort it sends it to the local router let’s go back to broadcast traffic for a moment I said earlier that the last IP address in the subnet is the broadcast IP it’s not the only one there’s another special IP used for broadcasts its 255 255 255 255 it’s different in that it doesn’t care what the local subnet is it basically says I don’t care what network you’re on send this traffic everywhere there are times when this is useful one case is when a host is starting up and it doesn’t have an IP address yet we’ll get into this a bit more later but one option is to use a special server to give the host an IP address but the host doesn’t know where the server is yet so it sends out a broadcast to 255 255 255 255 asking for an IP so while it’s useful there are also some downsides to broadcasting around like this routers are made to forward traffic between networks so what would happen if they received a broadcast well the larger network could get flooded with broadcast messages also if a broadcast message gets forwarded from one router to another router it may get stuck in a loop the simple solution to this is routers never forward broadcast messages all IP broadcast messages stay within the local network that makes us wonder then what if we do need to announce something to other parts of our network an example of this might be a server that’s sending a video stream several devices in the network wanted to Union and watch this video stream one option is perhaps we could send video traffic to each device individually that’s the unicast traffic we discussed before unfortunately that’s inefficient because we would need to duplicate this traffic for every single recipient broadcasting is no good for two reasons first not all devices want to receive the stream I mean what would a printer do with a video stream second broadcast don’t get passed the router so other subnets would not be able to receive the traffic the way we make this work is with a technology called multicast multicast uses special IP addresses we mentioned this back in the last video we spoke about Class D these addresses range from 2 to 4 0 0 0 to 239 255 255 255 we won’t get into much detail here but basically multicast is a way for devices to opt-in to receiving certain traffic the video server sends traffic to a multicast IP and other hosts look for traffic sent to that IP routers also forward multicast so the traffic can reach the networks it needs to get to so imagine you back in that room full of people if all of you broke out into small groups and you spoke to your small group while ignoring everyone else then your multi casting this is a lot of information to take in so see if you got it all we just spoke about three different special address types can you remember what they are and how they work.
Public and Private
IP addresses need to be unique if they are to work properly it’s like your home address if someone somewhere else in the country has exactly same address as you your mail might end up their place or their mail may end up at yours so how do we make sure that the IP addresses in your network are unique what’s to stop someone else in another company using the same addresses that you have IP addresses are managed by an organization called the internet assigned numbers Authority they give large blocks of addresses to sub organizations around the world called regional internet registries each RIR has a different name the one that we use here in Australia is called the asia-pacific network information center or AP Nick the our IRS then assign blocks of RP space either directly to you if you’re a large enough customer or they’ll also assign blocks to internet providers then ISPs the internet providers will give some of their space to the smaller customers while this process is a necessity there are some problems we’ll face if you want to create a new network you may need to get more IP space and that can really slow you down also we use up IP space very quickly as we have already seen we run into problems when we run low on IP addresses so to address these issues in the mid-1990s a standard called RFC 1918 was released if you’re not familiar with RFC’s their standards that describe how certain internet technologies work I’ll include a link to one of them if you’re interested but be warned they’re very detailed and sometimes quite complex so don’t feel obligated to hub have a read anyway this particular RFC says that some IP spaces are now reserved for private use you can use these IPS in any way that you see fit within your local network all other IP s these are the ones that are assigned to you or to the ISP are called public IPs remember these IPS the ones you see on your screen here you will see them a lot in your daily life but there’s something interesting about these addresses they are not allowed on the internet why well this prevents us from overlapping with any other company that is using the same addresses it also conserves IP addresses as we don’t need to use so many public IP addresses anymore but if they’re not allowed on the internet how do you get access to the Internet even with private addressing you still use some public addressing at the very least your internet provider will give you one public address let’s say you have a device in your network with the IP 170 to 1601 when it sends a message to the Internet the internet router will alter this message to use a public IP address this is a process called NAT or network address translation it’s a topic all of its own so I won’t go into any more detail on this right now we’ll cover that in another video some other time let me propose the simple question which RFC defines private addresses which private address ranges does it define?
We’ll now take a moment to talk about how devices get addresses there are two main ways and one less common way first you can login to a device and configure an address this is called a static address as it doesn’t change unless you manually reconfigure it when you assign an IP address this way you need to choose the address and you need to make sure it’s unique if two devices end up with the same address will have an IP conflict which causes us all sorts of problems you will commonly use this method for devices like routers and some servers devices whose addresses should never change the second method is to set addresses dynamically with a DHCP server a dhcp server has a pool of IP addresses available to it when a device starts up it broadcasts a message around the local network to find the DHCP server the server then gives it an IP address from its pool the server makes sure that it doesn’t give the same IP address to more than one device also there’s no guarantee that the device will get the same IP address each time that’s part of what makes this process dynamic this is good news for workstations laptops phones and tablets these are devices that may be mobile and will need to get a new address whenever they move to a new network there’s also a lot of these devices so it’s an easier method than logging into every single device and configuring them manually now the third method it’s a little unusual it’s called automatic private IP addressing and as far as I can tell only Windows uses it the basic idea is you don’t statically set an IP address on this machine the workstation starts and sends a broadcast message to find a DHCP server however it doesn’t find one this is when ap IP a let me did I get that correct apipa yep that’s right now that is when apipa kicks in it picks a random IP from the 169.254 dot 0 0 / 16 space and assigns that to the workstation this kinda has its uses perhaps on a small network if the DHCP server fails then devices can still reach each other they won’t know what the default gateway should be so they won’t be able to reach other networks on the internet but at least they can reach each other personally I would not recommend relying on this method.
When we looked at the OSI model we learned how extra headers are added to the data before it is sent this adds information needed for delivery is like writing an address on an envelope IP is no exception to this it adds the header that you see here not all the details that you will see will make a lot of sense right now we’ll cover a few of the fields but we won’t get into a lot of detail for now the two important parts that you need to know are the source and destination fields and they’re pretty self-explanatory the version field is also easy it’s either for ipv4 or ipv6 now this is where it gets interesting sometimes a packet is too large for a particular device so the device will break the packet into smaller packets and send each of them individually this is called fragmentation so this field here the fragment offset tracks the order of these fragments so they can be reassembled in the right order at the destination but sometimes we decide we want to prevent fragmentation altogether and we can do that by using the flags field he’s another interesting one remember earlier I said that broadcast could go round and round and round in the circles if routers didn’t stop them well the same could happen to other kinds of traffic so to deal with is we have this time-to-live field the device sending the packet sets a value in this field every time the packet passes through a router the TTL value is lowered by one if it gets all the way to zero the packet is dropped this is how we prevent a packet from looping forever if there is some sort of error in the network next up we’re going to look at the tcp/ip model this is somewhat like the OSI model but it has a bit of a different approach let me know what you thought of this article in the comments and subscribe if you don’t want to miss anything new