networking chp#3 ip addressing

Upload: waqas-ghaffari

Post on 18-Oct-2015

99 views

Category:

Documents


0 download

DESCRIPTION

This a complete chapter for well understanding the concept of ip addressing. The following topics are covered.Dynamic vs static IPPrivate vs Public IPClassful addressingClassless AddressingDefault routeLoopbackNatingCIDRMask , BlocksSubnetting Broadcast Address

TRANSCRIPT

PowerPoint Presentation

CHAPTER 3 IP ADDRESSING

Izaz A KhanMcGraw-HillThe McGraw-Hill Companies, Inc., 2000IP AddressWas invented by Robert E. Kahn (an American Engineer) in 1974.The IP Address is a unique number assigned to your computer connection by your home or office or employer's Internet Service Provider (ISP). This unique number serves as the ID of your connection when it's accessing the Internet. It functions like your street addressif someone wants to send you mail or you order a pizza, your address is needed for the postman or delivery person to find your home. The same process applies to your computer, your IP address is used to route information from the Internet to your computer.Standards OF IP AddressesTwo StandardsIPv4: Each address is 32 bits. (Mostly used)IPv6: Each address is 128 bits.Dynamic vs static IPDynamic IP addresses can change each time you connect to the Internet, while static IP addresses are reserved for you statically and don't change over time.Residential Internet connections, whether broadband or dialup usually use dynamic IP addresses, while commercial leased lines and servers have static IPs, so they can always be reached at the same address.Private vs Public IPPublic IP AddressA public (or external) IP address is the one that your ISP (Internet Service Provider)provides to identify your home network to the outside world. It is an IP address that is unique throughout the entire Internet.

Private IP AddressJust as your network's public IP address is issued by your ISP, your router issues private (or internal) IP addresses to each network device inside your network.Thisprovides unique identification fordevices that are within your home network, such as your computer, your mobile, and so on. IPv4 ADDRESSESAn IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device (for example, a computer or a router) to the Internet.6The IPv4 addresses are unique and universal.

NoteIP addresses are unique in the sense that each address defines one, and only one, connection to the Internet.IP addresses are universal in the sense that the addressing system must be accepted by any host that wants to be connected to the Internet.7RULE:If a protocol uses N bits to define an address, the address space is 2N because each bit can have two different values (0 and 1)and N bits can have 2N values.Address SpaceA protocol such as IPv4 that define addresses has an address space.An address space is the total number of addresses used by the protocol.The address space of IPv4 is 232 or 4,294,967,296.

Note9NOTATIONSThere are two notations to show an IPv4 address.Binary Notation.Dotted-Decimal Notation. (Mostly used)1-Binary NotationIn binary notation, the IPv4 address is displayed as 32 bits. The 32 bits are divided into 4 octets (means 8 bits each). Each octet is often referred to as a byte.So, it is common to hear an IPv4 address referred to as a 32-bit address or a 4-byte address. 01110101 10010101 00011101 11101010Binary Notation2- dotted-decimal notationTo make the IPv4 address more compact and easier to read, IP addresses are usually written in decimal form with a decimal point (dot) separating the bytes.For each octet, the decimal equivalent of the 8 bits binary number is written and the decimal numbers are separated by dots.

Dotted-decimal notationExample 1Change the following IP address from binary notation to dotted-decimal notation.10000001 00001011 00001011 11101111Solution129.11.11.239Example 2Change the following IP address from dotted-decimal notation to binary notation.111.56.45.78Solution01101111 00111000 00101101 01001110Example 3Find the error, if any, in the following IP address:111.56.045.78SolutionThere are no leading zeroes in dotted-decimal notation (045).Example 4Find the error, if any, in the following IP address:75.45.301.14SolutionIn dotted-decimal notation, each number is less than or equal to 255; 301 is outside this range.(As we know, there are 8 bits in each octet. Even if all the bits are 1 that is 11111111 still its decimal equivalent will be 255 that is why we say that In dotted-decimal notation, each number is less than or equal to 255).

Types of AddressingTwo types of addressing.Classful AddressingClassless Addressing 1- Classful AddressingIn classful addressing, the address space is divided into five classes: A, B, C, D, and E.

Finding the class in binary notation

Finding the address classExample 6Find the class of the address:00000001 00001011 00001011 11101111SolutionThe first bit is 0. This is a class A address.Example 7Find the class of the address:11000001 10000011 00011011 11111111SolutionThe first 2 bits are 1; the third bit is 0. This is a class C address.

Finding the class in decimal notationSee the verification of the above ranges in the next slide.Verification of rangesWe know that for class A in binary, the first bit from left of the address will always be 0, so 0 will stay 0 and the remaining 7 bits can change. Means the range will be from 00000000 (minimum) to 01111111 (maximum) which is from 0 to 127 in decimal. Similarly for class B, In binary the first 2 bits from the left will be 1 0 always, so these two bits will not change and remaining 6 bits can change. Means the range will be from 10000000 (minimum) to 10111111 (maximum) which is from 128 to 191 in decimal. By similar approach we can verify the ranges for the remaining 3 classes.NoteWe see that the range of Class A is 0 to 127, but the available range is 1 to 126 (0 to 127 is the total range).It means we cannot assign an ip address starting from 0 i.e (0.87.5.6) and starting from 127 i.e (127.1.5.60).This is because 0 is reserved for Default Route and 127 is reserved for Loopback.Explanation in the next slides.Default routeA default route allows traffic to be forwarded, even without a specific route to a destination.This route generally points to another router, which treats the packet the same way. If a route matches the packet is forwarded accordingly otherwise the packet is forwarded to the default route of the router.The process continues until packet is delivered.The default route in IPv4 is designated as the zero address 0.0.0.0.LOoPbACKLoopback is used to check whether TCP/IP protocol is installed or not.The loopback address is 127.0.0.0. The command ping 127.0.0.0 is useful in situations when there is no LAN card in the computer. Means we cannot check from the properties of LAN card whether TCP/IP is installed or not.By typing the above command if we get a reply (means if the ping works) then it will be understood that TCP/IP protocol is installed. Example 8Find the class of the address:227.12.14.87SolutionThe first byte is 227 (between 224 and 239); the class is D.Example 9Find the class of the address:193.14.56.22SolutionThe first byte is 193 (between 192 and 223);the class is C.CLASS D and EThe range of Class D is 224 239. It is used for multicasting and it is not for our use.The range of Class E is 240 - 255. It is used for future experiment and it is not for our use. Netid and HostidNetid = network id, Hostid = host id.Netid identifies the network and Hostid identifies the host.In classful addressing, an ip address in class A,B or C is divided into netid and hostid. These parts are of various lengths depending on the class of the address. The figure in the next slide shows some netid and hostid bytes. The netid is in color, the hostid is in white. Note that the concept does not apply to class D and E.In class A: 1 byte = netid, 3 bytes = hostid.In class B: 2 bytes = netid, 2 bytes = hostid.In class C: 3 bytes = netid, 1 byte = hostid.

Finding the classes in binary and dotted-decimal notation

34Classes and BlocksClassNumber of BlocksBlock SizeA12816,777,216B16,38465,536C2,097,152256Classes and BlocksNumber of Blocks = number of networks.Block Size = Number of hosts / Addresses per network.Classes and BlocksClassLeadingbitsSize of network. Network bit fieldSize of rest bit fieldNumber of networksAddresses per networkStart addressEnd addressA0824128 (27)16777216 (224)0.0.0.0127.255.255.255B10161616384 (214)65536 (216)128.0.0.0191.255.255.255C1102482097152 (221) 256 (28)192.0.0.0223.255.255.255How? See proofs in the next slides.FOR Class AIn class A, the number of networks are 128=27. This is because we know that in class A only the first byte represent the network (netid). And we also know that the first bit in class A address is 0 (see slide 21). The formula to find the number of networks for a class is given by = 2number of bits in the netid after the first zero from leftIn this case the first bit is zero from the left which means the number of networks will be = 27 , as we are left with 7 bits in the netid.NoteIn the previous slide we see that the number of networks in Class A are 128. And the range will be from 0 to 127. But if we take out the Default route(0) and Loopback(127) then we are left with 128-2= 126.So the total number of networks in Class A are 128 but the available number of networks are 126. In Class B and C the total number of networks are available, means no reservations.FOR class BSimilarly in class B, for netid we have 2 bytes and the address starts from 1 0 so the number of bits remaining in the netid after the first 0 from the left is 14 that is why the number of networks in class B is = 214 = 16384FOR class CFor class C, for netid we have 3 bytes and the address starts from 1 1 0 so the number of bits remaining in the netid after the first 0 from the left is 21 that is why the number of networks in class B is = 221 = 2097152Addresses per networkFor class A: We have 3 bytes for hostid so, 224 = 16777218For class B: We have 2 bytes for hostid so, 216 = 65536For class C: We have 1 byte for hostid so, 28 = 256

maskAlthough the length of the netid and hostid is predetermined in classful addressing, we can also use a mask (also called default mask), a 32-bit number made of 1s followed by 0s. The mask can help us to find the netid and the hostid. For example, the mask for a class A address has eight 1s, which means the first 8 bits of any address in class A define the netid; the next 24 bits define the hostid.See the table in the next slide.Default masks for classful addressing

CIDR = ? Next slide44CIDRThe last column of the table in the last slide shows the mask in the form /n where n can be 8,16 or 24 in classful addressing. This notation is also called slash notation or Classless Interdomain Routing (CIDR) notation. It is used mostly in classless addressing which will be discussed later. However it can also be used in classful addressing.For example, /8 means we have 8 bits for netid so the address is class A and /16 means we have 16 bits for netid so the address is class B. Classful addressing, which is almost obsolete (not generally in use), is replaced with classless addressing.

Note462- Classless AddressingTo overcome address depletion (the act of decreasing something) classless addressing was designed and implemented.In this scheme, there are no classes, but the addresses are still granted in blocks.Address blocksIn classless addressing, when an entity, small or large, needs to be connected to the Internet, it is granted a block (range) of addresses. The size of the block (the number of addresses) varies based on the nature and size of the entity.For example, a household may be given only two addresses; a large organization may be given thousands of addresses.RestrictionsTo simplify the handling of addresses, the internet authorities impose three restrictions on classless address blocks.The addresses in a block must be contiguous, one after another.The number of addresses in a block must be a power of 2 (1,2,4,8,16,32,64,128,).The first address must be evenly divisible by the number of addresses.

The figure in the next slide shows a block of addresses, in both binary and dotted-decimal notation, granted to a small business that needs 16 addresses.

We can see that the restrictions are applied to this block. The addresses are contiguous. The number of addresses is a power of 2 (16 = 24), and the first address is divisible by 16. The first address, when converted to a decimal number, is 3,440,387,360, which when divided by 16 results in 215,024,210. Example 1050 A block of 16 addresses granted to a small organization

51How to convert an IPv4 address to decimal?In Example 10 we say, The first address, when converted to a decimal number, is 3,440,387,360.How?The first address is 205.16.37.32 and it can be converted into decimal number by the following method = 205*2563 + 16*2562 + 37*2561 + 32*2560 = 3,440,387,360.MaskA better way to define a block of addresses is to select any address in the block and the mask.As we discussed before, a mask is a 32-bit number in which the n left most bits are 1s and the 32 n rightmost bits are 0s.However, in classless addressing the mask for a block can take any value from 0 to 32. It is very convenient to give just the value of n preceded by a slash (CIDR notation).In IPv4 addressing, a block of addresses can be defined asx.y.z.t /nin which x.y.z.t defines one of the addresses and the /n defines the mask.

Note54The first address in the block can be found by setting the rightmost 32 n bits to 0s.

Note55A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the first address in the block?

SolutionThe binary representation of the given address is11001101 00010000 00100101 00100111If we set 3228 rightmost bits to 0, we get 11001101 00010000 00100101 00100000 or 205.16.37.32. This is actually the block shown in Example 10.Example 1156The last address in the block can be found by setting the rightmost 32 n bits to 1s.

Note57Find the last address for the block in Example 11.

SolutionThe binary representation of the given address is11001101 00010000 00100101 00100111If we set 32 28 rightmost bits to 1, we get 11001101 00010000 00100101 00101111 or 205.16.37.47This is actually the block shown in Example 10.Example 1258The number of addresses in the block can be found by using the formula 232n.

Note59Find the number of addresses in Example 11, where one of the address was given as 205.16.37.39/28Example 13SolutionThe value of n is 28, which means that numberof addresses is 2 3228 or 16.60Another way to find the first address, the last address, and the number of addresses is to represent the mask as a 32-bit binary number.. In Example 13 the /28 can be represented as 11111111 11111111 11111111 11110000 (twenty-eight 1s and four 0s).

Finda. The first addressb. The last addressc. The number of addresses.Example 1461SolutionThe first address can be found by ANDing the given addresses (205.16.37.39) with the mask. ANDing here is done bit by bit. The result of ANDing 2 bits is 1 if both bits are 1s; the result is 0 otherwise.Example 14 (continued)

62 The last address can be found by ORing the givenaddresses (205.16.37.39 with the complement of the mask. Oring here is done bit by bit. The result of ORing 2 bits is 0 if both bits are 0s; the result is 1 otherwise. The complement of a number is found by changing each 1to 0 and each 0 to 1.Example 14 (continued)

63The number of addresses can be found by complementing the mask, converting it as a decimal number, and adding 1 to it.Example 14 (continued)

64A network configuration for the block 205.16.37.32/28

65Network and Broadcast AddressesWhen an organization is given a block of addresses, the organization is free to allocate the addresses to the devices that need to be connected to the Internet.The first and last address of the block however is treated specially. The first address is called the Network address and the last address is called Broadcast address.The first address in a block is normally not assigned to any device; it is used as the network address that represents the organization to the rest of the world.

Note67 Network AddressesThe network address is the first address.The network address defines the network to the rest of the Internet. Given the network address, we can find the class of the address, the block, and the range of the addresses in the blockBroadcast AddressesA special type of networking address that is reserved for sending messages to all machines on a given network segment.For example, if a server wants to send a message to all clients it will broadcast the message.The last address in a block will be always reserved for broadcasting, means through that address a message can be broadcasted to all the devices in the network.HierarchyHierarchy means any system of persons or things ranked one above another.IP addresses have levels of hierarchy.For example, a telephone network in North America has three levels of hierarchy. The leftmost three digits define the are code, the next three digits define the exchange, the last four digits define the connection of the local loop to the central office.The local loop (also referred to as a subscriber line) is the physical link or circuit that connects the customer premises to the Telecommunications service provider's network.

Hierarchy in a Telephone Network in North America

71Tw0 levels hierarchy: NO SUBNETTINGAn IP address can define only two levels of hierarchy when not subnetted.The n left most bits of the address x.y.z.t/n define the network (organization network).The 32-n right most bits define the particular host (computer or router) to the network.The part of the address that defines the network is called the prefix and the part of the address that defines the host is called the suffix.Each address in the block can be considered as a two-level hierarchical structure: the leftmost n bits (prefix) define the network;the rightmost 32 n bits define the host (suffix).

Note73Three levels of hierarchy: SUBNETTINGDue to Subnetting a large network is divided into smaller networks (subnets).Subnets are created to serve as a physical separations say between floors, buildings, cities, and even departments.An organization that is granted a large block of addresses may want to create subnets and divide the addresses between the different subnets. The rest of the world still sees the organization as one entity; however, internally there are several subnets.SUBNettingAll messages are sent to the router address that connects the organization to the rest of the Internet; the router routes the message to the appropriate subnets.The organization, however, needs to create small sub blocks of addresses, each assigned to specific subnets.The organization has its own mask; each subnet must also have its own. SUBNettingAs an example, suppose an organization is given the block 17.12.40.0/26, which contain 64 addresses (232-n). The organization has three offices and needs to divide the addresses into three sub blocks of 32,16 and 16 addresses. We can find the new masks by using the following arguments.Suppose the mask for the first subnet is n1, then 232-n1 must be 32 (because we need 32 addresses in the first sub block), which means that n1=27. SUBNetting2. Suppose the mask for the second subnet is n2, then 232-n2 must be 16, which means that n2=28.

3. Suppose the mask for the third subnet is n3, then 232-n3 must be 16, which means that n3=28.This means that we have the masks 27,28,28 for subnets and 26 for the organization.The figure in the next slide shows the whole scenario.

Configuration and addresses in a subnetted network

78NOTEThe diagram in the last page is taken from the book Data Communications and Networking by Behrouz 4th edition. In the diagram, in every subnet the last address is assigned to devices which is not correct.Because generally the last address in a network or sub network is used for broadcasting. Finding the Subnet AddressIn subnet 1, the address 17.12.14.29/27 can give us the subnet address if we use the mask /27 becauseHost: 00010001 00001100 00001110 00011101Mask: /27Subnet: 00010001 00001100 00001110 00000000Subnet: 17.12.14.0 As we know that the Network Address (sub network address) or Subnet Address is the first address of the network (sub network). That is why we find it by the above method which is also the method for finding the first address.Finding the Subnet AddressIn subnet 2, the address 17.12.14.45/28 can give us the subnet address if we use the mask /28 becauseHost: 00010001 00001100 00001110 00101101Mask: /28Subnet: 00010001 00001100 00001110 00100000Subnet: 17.12.14.32 Finding the Subnet AddressIn subnet 3, the address 17.12.14.50/28 can give us the subnet address if we use the mask /28 becauseHost: 00010001 00001100 00001110 00110010Mask: /28Subnet: 00010001 00001100 00001110 00110000Subnet: 17.12.14.48 Finding the Broadcast AddressAs we know that Broadcast Address is the Last Address in a network (subnet).So for every subnet the broadcast address (last address) can be determined by the formula of finding the last address.The (Broadcast) last address in the block can be found by setting the rightmost 32 n bits to 1s (See slide 57 and 58).The same formula will be applied to all the subnets for finding the Broadcast Address.Network Address translation (NAT)NAT enables a user to have a large set of addresses internally and one address externally. The traffic inside can use the large set; the traffic outside the small set.To separate the addresses used inside the home or business and the ones used for the Internet, the Internet authorities have reserved three sets of addresses as private addresses shown in the next slide.Addresses for private networks

85Addresses for private networksAny organization can use an address out of the set of addresses for private networks without permission from the Internet authorities.Everyone knows that these reserved addresses are for private networks.They are unique inside the organization, but they are not unique globally.No router will forward a packet that has one of these addresses as the destination address.Implementation of NATThe site must have only one single connection to the global Internet through the router (using NAT).The figure in the slide shows a simple implementation of NAT.In the figure, the private network uses private address. The router that connects the network to the global address uses one private address and one global address. The private network is not visible to the rest of the internet; the rest of the Internet sees only the NAT router with the address 200.24.5.8. A NAT implementation

88Address translationAll the outgoing packets go through the NAT router, which replaces the source address in the packet with the global NAT address. All incoming packets also pass through the NAT router, which replaces the destination address in the packet (the NAT router global address) with the appropriate private address. The figure in the next slide shows an example of address translation.Addresses in a NAT

Where 200.24.5.8 is the NAT router global address.90QuestionThe reader may have noticed that translating the source addresses for outgoing packets is straightforward. But how does the NAT router know the destination address for a packet coming from the Internet? There may be tens or hundreds of private IP addresses, each belonging to one specific host.The problem is solved if the NAT router has a Translation Table.Translation tableA translation table has only two columns: the private address and the external address (destination address of the packet).When the router translates the source address of the outgoing packet, it also makes note of the destination address (where the packet is going).When the response comes back from the destination, the router uses the source address of the packet (as the external address) to find the private address of the packet.The figure in the next slide shows the idea. NAT address translation

Where 200.24.5.8 is the NAT router global address.93 IPv6 ADDRESSESDespite all short-term solutions, address depletion is still a long-term problem for the Internet. This and other problems in the IP protocol itself have been the motivation for IPv6. 94An IPv6 address is 128 bits long.

Note95The address space of IPv6 is 2128.

Note96IPv6Consists of 8 Quarteds separated by colons. 1:2:3:4:5:6:7:8Hexadecimals values are used in each quardet. IPv6 vs IPV4IPv6QuartedHexadecimalColon format16 bits/quarted16 = 4 hexadecimal values

IPv4OctetDecimalDot format8 bits/octet

IPv6 address in binary and hexadecimal colon notation

1 hexadecimal digit = 4 bits => 4*32 = 128 bits 99 Abbreviated IPv6 addresses

Note that :: can be used only once is an address and preference will be given to the left. 100Expand the address 0:15::1:12:1213 to its original.Example 15SolutionWe first need to align the left side of the double colon to the left of the original pattern and the right side of the double colon to the right of the original pattern to find how many 0s we need to replace the double colon.

This means that the original address is.

101