07 Tcpip
07 Tcpip
Digit 1 0 0 1 1
Exponent * 24 * 23 * 22 * 21 * 20
Product 16 0 0 2 1
SUM 16 16 16 18 19 .
Bits and Number Value Quotient Remainder
Bases 719
359
359
179
1
1
o Decimal-to-Binary: 7 1 9 179 89 1
89 44 1
Divide the number by two
44 22 0
Place the remainder on the 22 11 0
end 11 5 1
Repeat with the quotient, 5 2 1
placing the remainder before 2 1 0
the previous digit. 1 0 1
Do this until you get a
quotient of zero. 1 0 1 1 0 0 1 1 1 1
Bits and Number Bases
• Hexadecimal: Hex Binary Hex Binary
o Values are 0 through 15 0 0000 4 0100
o Digits are 0 - 9, with 10 - 15 1 0001 5 0101
represented by A through F 2 0010 6 0110
o A hex digit is equivalent to a 3 0011 ...
quartet (4 bits)
0 OR 1 1 Turned ON
1 OR 0 1 Unchanged
0 OR 0 0 Unchanged
o Ifyou use a bit mask with OR , it will turn some bits on while
keeping the others as they were.
Bits and Number Bases
• AND operation:
o Any bit and 0 is turned/left OFF
o In contrast, any bit and 1 is simply left unchanged
Bit Mask Result
1 AND 1 1 Unchanged
0 AND 1 0 Unchanged
1 AND 0 0 Turned OFF
Turned OFF
0 AND 0 0 (if zero, would have been)
o If
you use a bit mask with AND , it will turn some bits off
while keeping the others as they were.
Bits and Number Bases
• Let's look at an example:
o Our original bit string:
1 0 1 1 0 0 1 1 1 1
o Bit string's decimal value: 7 1 9
1 0 1 1 0 0 1 1 1 1 719
OR
1 1 1 1 1 0 0 0 0 0 (992)
First 5
bits are
turned ON 1 1 1 1 1 0 1 1 1 1 (1007)
Mask applied with AND
1 0 1 1 0 0 1 1 1 1 719
Last 5
AND bits are
1 1 1 1 1 0 0 0 0 0 turned
(992)
OFF
1 0 1 1 0 0 0 0 0 0 (704)
IPv4 Addressing
• IP addressing allows hosts and other devices to have
routable addresses, both in LANs and within wider
networks -- most notably the Internet.
o MAC addresses provide for forwarding within a LAN, but IP
addresses let us extend beyond that.
o Thepredominant version of IP today is IPv4, though we will
cover IPv6 later on.
• IPv4 addresses are divided into five classes, indicated by
letters A-E
IPv4 Addressing
Class A: 0.0.0.0 - 127.255.255.255
Class B: 128.0.0.0 - 191.255.255.255
Class C: 192.0.0.0 - 223.255.255.255
Class D: 224.0.0.0 - 239.255.255.255
Class E: 240.0.0.0 - 254.255.255.255
• We will primarily be using the first three classes, though
Class D is relevant to Chapter 9, "Routing Protocols".
• These classes are useful for demonstrative purposes,
though the classification system is now outdated...
IPv4 Addressing
• An IPv4 address is expressed in 32 bits:
o In theory, this allows for 232, or 4294967296, possible IPs
o Each octet (8-bit chunk) will have a value in the range 0-255
you will see IP addresses expressed in decimal
o Normally,
form, where the octets' values are separated by periods.
o Example: www.google.com
Decimal: 146.115.22.166
Binary: 10010010011100110001011010100110
IPv4 Addressing
• Generally, the bits of an IP address are divided into two
parts that, in combination, give the full network location
of a particular host.
o The network bits comprise the first part of the longer bit
string, and they convey the location of the network where the
host resides.
o Followingare the host bits, which indicate the location of
the host within the network.
each octet in an IPv4 address contains either
o Traditionally,
network bits or host bits, according to address class...
IPv4 Addressing
+---------+---------------+---------------+---------------+
| Address | Network | Host | # Hosts |
| Class | Octets (Bits) | Octets (Bits) | per Network |
+---------+---------------+---------------+---------------+
| A | 1 (8) | 3 (24) | 1.68e7 (224) |
| B | 2 (16) | 2 (16) | 6.55e4 (216) |
| C | 3 (24) | 1 (8) | 2.56e2 (28) |
+---------+---------------+---------------+---------------+
See also Figure 6-13
• Depending on the number of host bits (vs network bits),
different classes of networks will have a different possible
number of hosts per network -- specifically, two raised to the
power of number of host bits.
IPv4 Addressing
• Within each class, some IPs are designated as private:
Class A: 10.0.0.0 - 10.255.255.255
Class B: 172.16.0.0 - 172.31.255.255
Class C: 192.168.0.0 - 192.168.255.255
o These are for internal networks, or intranets, such as...
The IT Lab's inner network
A home network
o Private IP addresses are not routable over the Internet!
IPv4 Addressing
• On a wider level, the Internet Assigned Number
Authority (IANA) is responsible for the allocation of
IP addresses.
o However,
it delegates this task to regional Internet
registries (RIRs), who allocate addresses according to
geographical location.
o In
North America, the American Registry for Internet
Numbers (ARIN) assigns IP addresses.
o Largeentities like ISPs and universities are allocated blocks of
IP addresses to further assign as they choose.
Subnetting
• A network can be partitioned into smaller entities called
subnets.
o These create a hierarchical network structure.
o Subnetsare separated at layer 3, in the sense that you use IP
and routing to move between them
• Example: You have a network at address 192.145.17.0
+----------+----------+----------+----------+
| 192 | 145 | 17 | 0 |
+----------+----------+----------+----------+
| 11000000 | 10010001 | 00010001 | 00000000 |
+----------+----------+----------+----------+
Subnetting
• This network, however, might be divided into 4 subnets:
192.145.17.0 (IP range: 192.145.17.0 - 192.145.17.63)
192.145.17.64 (IP range: 192.145.17.64 - 192.145.17.127)
192.145.17.128 (IP range: 192.145.17.128 - 192.145.17.191)
192.145.17.192 (IP range: 192.145.17.192 - 192.145.17.255)
Source: https://upload.wikimedia.org/wikipedia/commons/2/26/CIDR_Address.svg
Classless Interdomain Routing
• When grouping subnets into a CIDR block, they must
resolve to the same IP when the subnet mask is applied
to them. For example...
172.20.0.0/14
172.21.0.0/14
172.22.0.0/14
172.23.0.0/14
• ...would not be a problem because the /14 mask
resolves them to the same value of 172.20.0.0
Classless Interdomain Routing
• However, these would not work as a CIDR block....
172.22.0.0/14
172.23.0.0/14
172.24.0.0/14
172.25.0.0/14
• ...would be problematic because the mask resolves
some to 172.20.0.0 and others to 172.24.0.0
IPv6
• IPv4 addressing, using 32 bits, allows for roughly 4.3
billion unique IP addresses.
• As the Internet grows and more devices are connected
to it, this number is becoming insufficient.
• This is where IPv6 (also known as IPng) comes in.
• IPv6 addressing uses 128 bits -- which allows for 2128
possible addresses
IPv6
• Whereas IPv4 addresses are usually written in dotted
decimal form (e.g., 192.168.0.1), IPv6 addresses are
expressed in hexadecimal digits -- separated by colons.
o Example: 9b32:e6da:d14f:6698:a9e5:7fae:1ba2:ed81
o Theexample would be considered a full IPv6 address
because none of the hex digits are zero.
• When some of the digits are zeroes, there may be ways
to "compress" the zeroes to shorten the address.
IPv6
• Zero compression: Replace consecutive zeroes with
two colons
o From: 9b32:0000:0000:0000:a9e5:7fae:1ba2:ed81
o To: 9b32::a9e5:7fae:1ba2:ed81
• Leading zero compression: For individual quartets,
omit leading zeroes
o From: 9b32:000a:d14f:0698:00e5:7fae:0002:ed81
o To: 9b32:a:d14f:698:e5:7fae:2:ed81
IPv6
• Both compression types:
o From: 9b32:0000:0000:0000:00e5:7fae:0002:ed81
o To: 9b32::e5:7fae:2:ed81
• To recover the original IPv6 address from its compressed
form...
o Start with the rightmost digit (of the latter)
::ac1b:d55e
IPv6
• IPv6 addresses belong to three categories:
o Unicast: Associated with a single network interface
controller on a networked device.
o Multicast:Indicates a group of devices, and data sent to
such an address will be sent to the entire group.
o Anycast: Comes from a list of addresses.
• Although IPv6 allows for a much better range of
addresses, IPv4 is near-universal and will be in play for a
long time to come.
IPv6
• There are a number of technologies out there to
facilitate the transition to IPv6.
• One such technology is the 6to4 prefix, which allows
IPv6 devices to use IPv4 networks.
o Thisinvolves the use of special 6to4 devices that do the
routing required.
oA 32-bit IPv4 address will be included within the larger 128-
bit IPv6 address
IPv6
• Until IPv6 becomes more common, there are other solutions
out there for the issue of limited IPv4 addresses.
o For example, a private IP address -- not being routable over the
Internet -- can be used by many different hosts -- so long as it is
unique within a private network.
In the IT Lab: 10.0.0.0/24 addresses
On home networks: 192.168.0.0
o When hosts on private networks need Internet connectivity, they may
use Network Address Translation (NAT) -- where the router
replaces the inner, private source IP with its own outer, public one.