From the course: Networking Foundations: IP Addressing

Expressing IP addresses

From the course: Networking Foundations: IP Addressing

Start my 1-month free trial

Expressing IP addresses

- [Instructor] So we know that the IP address is critical for being able to send and receive data on the network. We know this address dictates our network assignment and also describes our host ID. We represent both IPv4 and IPv6 addresses in a format that we humans are comfortable with. For example, let's consider the dotted decimal notation of an IPv4 address. The computer sees this 32 bit address in its binary form though. We know that the computers love binary where we have a zero or a one bit setting. Now there's eight bits in each section of the IP address. So because each of these sections are going to consist of eight bits, these sections are named octets. Sadly, when the designers of IPv4 were planning the address space, they never dreamed of the popularity that IP in the internet would bring. So sure enough, we're essentially out of IPv4 address space that can be assigned to companies. This really helped speed up the development of the next generation IP technology called IPv6. In IPv6, the 128 bit IPv6 address is presented in hexadecimal as we can see here. Now, there are two shortcuts you can use with IPv6 addresses in order to shorten them. First, you can substitute consecutive fields that consist of only zeros with a colon colon. Please note though, you can only do this once within the address. Now you can also trim leading zeros from any field and you can do this as many times as you like. So if we were to apply both of these techniques to our IPv6 address, we would get the shortened IPv6 address. Notice we've trimmed all the leading zeros from fields and once within the address, we represented those two fields of all zeros with our colon colon trick. Now let me show you just how easy it is to convert from decimal to binary and vice versa. This is actually an important skill when you're learning to work with IP addresses and we'll see reasons why this is true later on in the course. So what I do in order to be able to convert from binary to decimal or vice versa is I use a handy little conversion chart. And in fact, I like to make this chart on my scratch paper before I start a certification exam so that I can use the chart to answer these types of questions. So here's how this works. On the first row of the chart, I write down two raised to the seven and then six and then five and then four and then three and two and one and zero. So we have two raised to the zero all the way up to two raised to the seventh. So that's the first row of my conversion chart and then underneath that row, I'm going to put the values. Now, two raise to the zero power, it turns out anything raised to the zero power simply gets a value of one and then we have two raised to the first which is the value itself of two and then two raised to the second is four. In fact, you can quickly fill out this row by just doubling the value as you move from right to left. So one, two, four, eight, 16, 32, 64 and 128. So there is the conversion chart in all of its glory and this makes it very, very simple to do these conversions. Let's take an example of, oh let's say inside of one of our octets, we have the number 10 in decimal, what is that in binary? Well, when you take a look at the bits inside of an octet and this table right here represents those eight bits inside of an octet, so when we look at that, we just say, "Okay, can I subtract the decimal value here of 128 from the number we are trying to convert?" And the answer is no we can't and so that bit position gets a zero. Can we subtract 64 and not have a negative number or a zero? And the answer is no we can't, so that has a zero. And then the next column would get a zero and then the next column would get a zero and then look at this, we have our first one bit position. We can subtract eight from 10 and it gives us a remainder of two. And so then we work on that remainder, can we subtract four from two? The answer is no we cannot. Can we subtract two from two? The answer is, yes we can and in fact that gives us that zero we're looking for, so that would leave a zero in the last position. So it turns out that 10 converted to binary is 00001010. And as a matter of fact, let's face it, if we're presenting this to someone and we are not talking about the eight bits, well of course you could just trim off those leading zeros and you could tell them that the binary 1010 is of course equal to 10. So that's how easy it is to make that conversion from the, in this case, decimal to the binary. We now want to see an example where we're going to be doing the conversion in the other direction. All right, so notice we are going to be able to take advantage of our same conversion chart, thank goodness, when we do this and it's really, really simple. Let's say we have 10111101. So we are presented with this octet in binary, what does it equal in decimal? Well, all you got to do is look at these one bit positions and just add up those values. So we would have 128 plus 32 plus 16 plus eight plus four, the zero is in that two position, so we don't add that and then we add one. So that's it, so we just have a big addition challenge here. So 189, I do believe this number works out to be in decimal. That conversion chart, as you've seen is going to make it very easy for us to by hand convert from decimal into binary or binary into decimal.

Contents