Advanced Computer Networks Chapter 3

download Advanced Computer Networks Chapter 3

of 76

Transcript of Advanced Computer Networks Chapter 3

  • 8/13/2019 Advanced Computer Networks Chapter 3

    1/76

    Dr. Tareq Alhmiedat

    Department of Information Technologys,

    Faculty of Computers and Information Technology,

    Tabuk University,

    [email protected]

    1

  • 8/13/2019 Advanced Computer Networks Chapter 3

    2/76

    To introduce the concept of an address spacein general and the address space of IPv4 inparticular

    To discuss the classful architecture

    To discuss the idea of hierarchical addressing

    2

  • 8/13/2019 Advanced Computer Networks Chapter 3

    3/76

    The identifier used in the IP layer of theTCP/IP protocol package to identify eachdevice connected to the Internet address or IPaddress

    An IPv4 address is a 32-bit address thatuniquely and universally defines theconnection of a host or a router to the

    Internet

    3

  • 8/13/2019 Advanced Computer Networks Chapter 3

    4/76

    A protocol like IPv4 that defines addresseshas an address space

    An address space is the total number ofaddresses used by the protocol

    4

  • 8/13/2019 Advanced Computer Networks Chapter 3

    5/76

    Binary notation10001111 10011001 10101000 11100011

    Dotted-Decimal Notation128 . 11 . 3 . 31

    5

  • 8/13/2019 Advanced Computer Networks Chapter 3

    6/76

    We often need to deal with a range ofaddresses instead of one single address

    We sometimes need to find the number ofaddresses in a range if the first and lastaddress is given

    Example: Find the number of addresses in arange if the first address is 146.102.32.0andthe last address is 146.102.32.255

    6

  • 8/13/2019 Advanced Computer Networks Chapter 3

    7/76

    IP addresses used the concept of classes This architecture is called classful addressing In the mid-1990, a new architecture called

    classless addressingwas introduced We start with classful addressing

    7

  • 8/13/2019 Advanced Computer Networks Chapter 3

    8/76

    In classful addressing, the IP address space isdivided into five classes: A, B, C, D, and E

    Each class occupies some part of the wholeaddress space

    8

  • 8/13/2019 Advanced Computer Networks Chapter 3

    9/76

    Class A: 231, forms 50% Class B: 230, forms 25%

    Class C: 229, forms 12.5%

    Class D: 228

    , forms 6.25% Class E: 228, forms 6.25%

    9

  • 8/13/2019 Advanced Computer Networks Chapter 3

    10/76

    Class A:

    10

    Byte 4yte 3yte 2yte 10-127

    Octet 4ctet 3ctet 2ctet 10..

    Binary notation

    Dotted-decimal notation

  • 8/13/2019 Advanced Computer Networks Chapter 3

    11/76

    Class B:

    11

    Byte 4yte 3yte 2yte 1128-191

    Octet 4ctet 3ctet 2ctet 110..

    Binary notation

    Dotted-decimal notation

  • 8/13/2019 Advanced Computer Networks Chapter 3

    12/76

    Class C:

    12

    Byte 4yte 3yte 2yte 1192-223

    Octet 4ctet 3ctet 2ctet 1110..

    Binary notation

    Dotted-decimal notation

  • 8/13/2019 Advanced Computer Networks Chapter 3

    13/76

    Class D:

    13

    Byte 4yte 3yte 2yte 1224-239

    Octet 4ctet 3ctet 2ctet 11110..

    Binary notation

    Dotted-decimal notation

  • 8/13/2019 Advanced Computer Networks Chapter 3

    14/76

    Class E:

    14

    Byte 4yte 3yte 2yte 1240-255

    Octet 4ctet 3ctet 2ctet 11111..

    Binary notation

    Dotted-decimal notation

  • 8/13/2019 Advanced Computer Networks Chapter 3

    15/76

    Example: Find the class of each address:

    a. 00000001 00001011 00001011 11101111

    b. 11000001 10000011 00011011 11111111

    c. 11110011 10011011 11111011 00001111

    d. 10100111 11011011 11111011 01101111

    15

  • 8/13/2019 Advanced Computer Networks Chapter 3

    16/76

    In classful addressing, an IP address inclasses A, B, and C is divided into netidandhostid

    These parts are of varying lengths, dependingon the class of the address

    16

  • 8/13/2019 Advanced Computer Networks Chapter 3

    17/76

    17

    Byte 1 Byte 2 Byte 3 Byte 4

    Class A Netid Hostid

    Class B Netid Hostid

    Class C Netid Hostid

    Class D Multicast address

    Class E Reserved for future use

  • 8/13/2019 Advanced Computer Networks Chapter 3

    18/76

    A block is a range of addresses. Given anyaddress in the block, we normally like toknow three pieces of information about theblock:

    1. The number of addresses

    2. The first address

    3. The last address

    18

  • 8/13/2019 Advanced Computer Networks Chapter 3

    19/76

    In order to extract these pieces ofinformation, we need to do the following:

    1. The number of addresses in block N, can befound using N = 232-n

    2. To find the first address, we keep the nleftmost bit and set the (32-n) rightmostbits all to 0s

    3. To find the last address, we keep n leftmostbits and set the (32-n) rightmost bits all to1s

    19

  • 8/13/2019 Advanced Computer Networks Chapter 3

    20/76

    20

    netid hostid

    n bits (32-n) bits

    netid 0000netid 1111

    First address Last address

    Class A: n = 8

    Class B: n =16

    Class C: n=24

  • 8/13/2019 Advanced Computer Networks Chapter 3

    21/76

    Example 1: An address in a block is given as73.22.17.25. Find the number of addressesinthe block, the first address, and the lastaddress.

    Example 2: an address in a block is given as180.8.17.9. Find the number of addressesinthe block, the first address, and the lastaddress.

    21

  • 8/13/2019 Advanced Computer Networks Chapter 3

    22/76

    The network address is particularly importantbecause it is used in routing a packet to itsdestination network

    The network address is actually the identifierof the network

    Each network is identified by its networkaddress

    22

  • 8/13/2019 Advanced Computer Networks Chapter 3

    23/76

    The routers in the Internet usually use analgorithm to extract the network address fromthe destination address of a packet, to do this,we need a network mask

    A network maskor a default maskin classfuladdressing is a 32-bit number with nleftmostbits all set to 1s and (32-n) rightmost bits allset to 0s

    Since nis different for each class in classfuladdress, we have three default masks inclassful addressing

    23

  • 8/13/2019 Advanced Computer Networks Chapter 3

    24/76

    24

    11111111 00000000 00000000 00000000

    8 bits 24 bitsMask for class A

    11111111 11111111 00000000 00000000

    16 bits 16 bits

    11111111 11111111 11111111 00000000

    24 bits 8 bitsMask for class B

    Mask for class C

  • 8/13/2019 Advanced Computer Networks Chapter 3

    25/76

    To extract the network address from thedestination address of a packet, a router usesthe AND operation

    When the destination address is ANDed withthe default mask, the result is the networkaddress

    The default mask can be used to find the

    number of addresses in the block and the lastaddress in the block

    25

  • 8/13/2019 Advanced Computer Networks Chapter 3

    26/76

    26

    10010101101 10010101101

    AND

    100101010000

    Destination

    address DefaultMask

    Network

    address

  • 8/13/2019 Advanced Computer Networks Chapter 3

    27/76

    Example: A router receives a packet with thedestination address 201.24.67.32. Show howthe router find the network address of thepacket.

    27

  • 8/13/2019 Advanced Computer Networks Chapter 3

    28/76

    The IP addresses were originally designed withtwo levels of addressing

    To reach a host on the Internet, we must firstreach the network and then the host

    There is a great demand to have more than twoaddresses

    The idea of splitting a block to smaller blocks isreferred to as subnetting

    In subnetting, a network is divided into severalsmaller subnetworks (subnets) with eachsubnetwork having its own subnetwork address

    28

  • 8/13/2019 Advanced Computer Networks Chapter 3

    29/76

    Consider the following example shown belowwhich shows a network using class Baddresses before subnetting

    29

    Switch Network: 141.14.0.0/16

    141.14.0.1 141.14.0.2 141.14.0.27

    141.14.255.253 141.14.255.254

    Internet router

  • 8/13/2019 Advanced Computer Networks Chapter 3

    30/76

    30

    Internet router

    Site router

    141.14.0.0/18 141.14.64.0/18

    141.14.128.0/18 141.14.192.0/18

    Subnet 1 Subnet 2

    Subnet 3 Subnet 4

    141.14.0.0/16

    141.14.0.1 141.14.31.29 141.14.63.254 141.14.64.1 141.14.90.27 141.14.127.254

    141.14.128.1 141.14.142.37 141.14.191.254 141.14.192.1 141.14.223.47 141.14.255.254

  • 8/13/2019 Advanced Computer Networks Chapter 3

    31/76

    The network mask discussed before is usedwhen a network is not subnetted

    When we divide the network into severalsubnetworks, we need to create a subnetwork

    mask (or subnet mask) for each subnetwork

    A subnetwork has subnetid and hostid

    Subnetting increases the length of the netid

    and decreases the length of hostid We can divide the network into snumber of

    subnetworks

    31

  • 8/13/2019 Advanced Computer Networks Chapter 3

    32/76

    We can calculate the subnetid for eachsubnetwork as

    in which nis the length of netid, nsubis thelength of each subnetid, and sis the numberof subnets which must be a power of 2

    32

  • 8/13/2019 Advanced Computer Networks Chapter 3

    33/76

    33

    netid hostid

    subnetid hostid

    n bits 32 - n bits

    ChangeNetwork mask

    subnetwork mask

  • 8/13/2019 Advanced Computer Networks Chapter 3

    34/76

    Example: consider a network is divided intofour subnetworks in class B. Show the formatof the subnetwork mask.

    34

  • 8/13/2019 Advanced Computer Networks Chapter 3

    35/76

    When a network is subnetted, the firstaddress in the subnet is the identifier of thesubnet and is used by the router to route thepackets destined for that subnetwork

    Given any address in the subnet, the routercan find the subnet mask using the sameprocedure discussed in the network mask

    35

  • 8/13/2019 Advanced Computer Networks Chapter 3

    36/76

    Example: Assume a network is divided intofour subnets. Since the address in subnet 2 is141.14.120.77. Find the subnet address.

    36

  • 8/13/2019 Advanced Computer Networks Chapter 3

    37/76

    In supernetting, an organization can combineseveral class C blocks to create a larger rangeof addresses

    In other words, several networks are

    combined to create a supernetwork

    An organization can apply for several class Cblocks instead of just one

    37

  • 8/13/2019 Advanced Computer Networks Chapter 3

    38/76

    A supernet mask is the reverse of a subnetmask

    A subnet mask for class C has more 1s thanthe default mask for this class

    A supernet mask for class C has less 1s thanthe default mask for this class

    In supernetting, the number of class C

    addresses that can be combined to make asupernet needs to be a power of 2

    38

  • 8/13/2019 Advanced Computer Networks Chapter 3

    39/76

    Comparison of subnet, default mask, andsupernet mask

    39

    11111111 11111111 11111111 111 00000

    11111111 11111111 11111111 00000000

    Divide 1 class block into 8 subblocksSubnet mask

    Default maskSupernet mask

    11111111 11111111 11111 000 00000000

    Combine 8 class blocks into 1 superblock

    nsub= 24 + 3 = 27

    n= 24

    nsuper= 24 3 = 21

  • 8/13/2019 Advanced Computer Networks Chapter 3

    40/76

    Supernetting provides two main problems:1. The number of blocks to combine needs to

    be a power of 2, which means anorganization that needed seven blocks

    should be granted at least eight blocks(address wasting)

    2. Supernetting and Subnetting reallycomplicated the routing of packets in theInternet

    40

  • 8/13/2019 Advanced Computer Networks Chapter 3

    41/76

    Subnetting and supernetting in classfuladdressing did not really solve the addressdepletion problem and made the distribution ofaddresses and the routing process more difficult

    With the growth of the Internet, it was clear thata larger address space was needed as a long-term solution

    The larger address space requires that the

    length of the IP addresses to be increased That means, the format of the IP packets needs

    to be changed

    41

  • 8/13/2019 Advanced Computer Networks Chapter 3

    42/76

    The class privilege was removed from thedistribution to compensate for the addressdepletion

    In 1996, the Internet authorities announced a

    new architecture called classless addressing In classless addressing, variable-length

    blocks are used that belong to no classes

    We can have a block of 1 address, 2addresses, 4 addresses,128 addresses, andso on

    42

  • 8/13/2019 Advanced Computer Networks Chapter 3

    43/76

    In classfull addressing the whole addressspace was divided into five classes

    Classes D & E were reserved for specialpurpose

    In classless addressing, the whole addressspace is divided into variable length blocks

    Theoretically, we can have a block of 20, 21,

    22

    , 232

    addresses The only restriction is that the number of

    addresses in a block needs to be a power of 2

    43

  • 8/13/2019 Advanced Computer Networks Chapter 3

    44/76

    In classless addressing the block is actuallydivided into two parts: the prefixand suffix

    The prefix plays the same role as the netid

    The suffix plays the same role as the hostid

    All addresses in the block have the sameprefix, while each address has a differentsuffix

    44

  • 8/13/2019 Advanced Computer Networks Chapter 3

    45/76

    In classful addressing, the length of the netidn depends on the class of the address, it canbe only 8, 16, 24

    In classless addressing, the length of the

    prefix n depends on the size of the block, itcan be 0, 1, 2, 3, .. 32

    45

    Prefix Suffix

    Network Host

    n bits (32-n) bits

  • 8/13/2019 Advanced Computer Networks Chapter 3

    46/76

    Example: What is the prefix length and suffixlength if the whole Internet is considered as onesingle block with 4,294,967,296 addresses?

    46

  • 8/13/2019 Advanced Computer Networks Chapter 3

    47/76

    In classful addressing, the netid length isinherent in the address. Given an address, weknow the class of the address

    In classless addressing, the prefix length can

    not be found if we are given only an addressin the block. The given address can belong toa block with any prefix length

    47

    byte .byte .byte .byte /n

    Prefix

    length

  • 8/13/2019 Advanced Computer Networks Chapter 3

    48/76

    The slash notation is formally referred to asclassless interdomain routing or CIDR

    In classless addressing, we need to know theone of the addresses in the block and the

    prefix length to define the block

    48

  • 8/13/2019 Advanced Computer Networks Chapter 3

    49/76

    The idea of network mask in classlessaddressing is the same as the one in classfuladdressing

    A network mask is a 32-bit number with the

    n leftmost bits all set to 1s and the rest of thebits all set to 0s

    49

  • 8/13/2019 Advanced Computer Networks Chapter 3

    50/76

    Example: Give the network mask for thefollowing addresses:

    a. 12.23.24.78/8

    b. 130.11.232.156/16

    c. 167.199.170.82/27

    50

  • 8/13/2019 Advanced Computer Networks Chapter 3

    51/76

    An address in slash notation (CIDR) containsall information we need about the block: thefirst address(network address), the number ofaddresses, and the last address

    1. The number of addresses in the block canbe found as:

    N = 232-nwhere nis the prefix, and Nis the number ofaddresses in the block

    51

  • 8/13/2019 Advanced Computer Networks Chapter 3

    52/76

    2. The first address (Network address) in theblock can be found by ANDing the addresswith the network mask:

    First Address = any address) AND network mask)

    52

  • 8/13/2019 Advanced Computer Networks Chapter 3

    53/76

    3. The last address in the block can be foundby either adding the first address with thenumber of addresses, or directly, by Oringthe address with the complement (NOTing) of

    the network mask

    Last address = any address) OR [NOT network mask)]

    53

  • 8/13/2019 Advanced Computer Networks Chapter 3

    54/76

    Example 1: One of the addresses in a block is167.199.170.82/27. Find the number ofaddresses in the network, the first address,and the last address

    Example 2: One of the addresses is17.63.110.114/24. Find the number ofaddresses, the first address, and the lastaddress in the block

    54

  • 8/13/2019 Advanced Computer Networks Chapter 3

    55/76

    The responsibility of block allocation is givento a global authority called the InternetCorporation for Assigned Names andAddresses (ICANN)

    However, ICANN does not normally allocateaddresses to individual Internet users. Itassigns a large block of addresses to an ISP

    55

  • 8/13/2019 Advanced Computer Networks Chapter 3

    56/76

    For the proper operation of the CIDR, threerestrictions need to be applied to the allocatedblock.

    1. The number of requested addresses, N, needsto be a power of 2

    2. The value of the prefix length can be foundfrom the number of addresses in the block

    3. The requested block needs to be allocatedwhere there are a contiguous number of

    unallocated addresses in the address space.The beginning address must be divisible by thenumber of addresses

    56

  • 8/13/2019 Advanced Computer Networks Chapter 3

    57/76

    Example: Which of the following can be thebeginning address of a block that contains 16addresses?

    A. 205.16.37.36

    B. 190.16.42.44

    C. 17.17.33.80

    D. 123.45.24.52

    57

  • 8/13/2019 Advanced Computer Networks Chapter 3

    58/76

    Example: Which of the following can be thebeginning address of a block that contains256 addresses?

    A. 205.16.37.36

    B. 190.16.42.0

    C. 17.17.33.0

    D. 123.45.24.52

    58

  • 8/13/2019 Advanced Computer Networks Chapter 3

    59/76

    Example: An ISP has requested a block of1000 addresses.

    59

  • 8/13/2019 Advanced Computer Networks Chapter 3

    60/76

    All issues discussed for classless addressingcan be applied to classful addressing

    The classful addressing is a special case ofthe classless addressing in which the blocks

    in class A, B, and C have the prefix lengthnA=8, nB=16, nC=24

    A block in classful addressing can be easilychanged to a block in class addressing

    60

  • 8/13/2019 Advanced Computer Networks Chapter 3

    61/76

    Three levels of hierarchy can be created usingsubnetting

    An organization that is granted a range ofaddresses may divide the range into several

    subranges and assign each subrange to asubnetwork (or subnet)

    A subnetwork can be divided into severalsub-subnetworks. A sub-subnetwork can bedivided into several sub-sub-subnetworks.And so on

    61

  • 8/13/2019 Advanced Computer Networks Chapter 3

    62/76

    The subnetwork in a network should becarefully designed to enable the routing ofpackets

    We assume the total number of addresses

    granted to the organization is N, the prefixlength is n, the assigned number ofaddresses to each subnetwork is Nsub, theprefix length for each subnetwork is nsub,

    and the total number of subnetworks is s

    62

  • 8/13/2019 Advanced Computer Networks Chapter 3

    63/76

    The following steps need to be carefully followedto guarantee the proper operation of thesubnetworks:

    1. The number of addresses in each subnetwork

    should be a power of 22. The prefix length for each subnetwork should

    be found using the following formula:

    nsub= n + log2(N/Nsub)

    3. The starting address in each subnetwork shouldbe divisible by the number of addresses in thatsubnetwork.

    63

  • 8/13/2019 Advanced Computer Networks Chapter 3

    64/76

    Example: An organization is granted theblock 130.34.12.64/26. The organizationneeds four subnetworks, each with an equalnumber of hosts. Design the subnetworks

    and find the information about each network.

    64

  • 8/13/2019 Advanced Computer Networks Chapter 3

    65/76

    Example: An organization is granted a blockof addresses with the beginning address14.24.74.0/24. the organization needs tohave 3 subblocks of addresses to use in its

    three subnets as shown below:One subblock of 120 addresses

    One subblock of 60 addresses

    One subblock of 10 addresses

    65

  • 8/13/2019 Advanced Computer Networks Chapter 3

    66/76

    One of the advantages of CIDR architecture isaddress aggregation

    ICANN assigns a large block of addresses toan ISP

    Each ISP in turn divides its assigned blockinto smaller subblocks and grants thesubblocks to its customers

    Many blocks of addresses are aggregated inone block and granted to one ISP.

    66

  • 8/13/2019 Advanced Computer Networks Chapter 3

    67/76

    In classful addressing some addresses werereserved for special purposes

    All Zeros address 0.0.0.0/32, which contains only one single

    address, is reserved for communication whena host needs to send an IPv4 packet but itdoes not know its own address

    67

  • 8/13/2019 Advanced Computer Networks Chapter 3

    68/76

    All Ones Address: Limited Broadcast Address The block 255.255.255.255/32, which

    contains one single address, is reserved forlimited broadcast address in the current

    network A host that wants to send a message to every

    other host can use this address as adestination address in the IPv4 packet

    However, a router will block a packet havingthis type of address to confine thebroadcasting to the local network

    68

  • 8/13/2019 Advanced Computer Networks Chapter 3

    69/76

    Loopback Addresses The block 127.0.0.0/8 is used for the loopback

    address, which is an address used to test thesoftware on a machine

    When this address is used, a packet never leavesthe machine, it simply returns to the protocolsoftware

    It can be used to test the IPv4 software

    For example: an application such as ping can

    send a packet with a loopback address as thedestination address to see if the IPv4 is capableof receiving and processing a packet.

    69

  • 8/13/2019 Advanced Computer Networks Chapter 3

    70/76

    Private Addresses A number of blocks are assigned for private

    use

    They are not recognized globally

    70

  • 8/13/2019 Advanced Computer Networks Chapter 3

    71/76

    Some addresses in a block are used forspecial addresses

    These addresses are not assigned to any host

    However, if a block (or subblock) is so small,

    we cannot afford to use part of the addressesas special addresses

    71

  • 8/13/2019 Advanced Computer Networks Chapter 3

    72/76

    A. Network Address The first address (with the suffix set all to 0s)

    in a block defines the network address

    It actually defines the network itself and not

    any host in the network

    72

  • 8/13/2019 Advanced Computer Networks Chapter 3

    73/76

    B. Direct Broadcast Address The last address in a block or subblock (with

    the suffix set all to 1s) can be used as a directbroadcast address

    This address is usually used by a router tosend a packet to all hosts in a specificnetwork

    All hosts will accept a packet having this type

    of destination address Note that this address can be used only as a

    destination address in an IPv4 packet

    73

  • 8/13/2019 Advanced Computer Networks Chapter 3

    74/76

    In most situations, only a portion of computers ina small network need access to the Internetsimultaneously. This means that the number ofallocated addresses does not have to match thenumber of computers in the network

    For example, assume a small business with 20computers in which the maximum number ofcomputers that access the Internet simultaneouslyis only 5. Most of the computers are either doing

    some task that does not need Internet access. Thissmall business can use the TCP/IP protocol forboth internal and universal communication.

    74

  • 8/13/2019 Advanced Computer Networks Chapter 3

    75/76

    A technology that can provide that mappingbetween the private and universal addresses,and at the same time, support virtual privatenetworks is network address translation(NAT)

    The technology allows a site to use a set ofprivate addresses for internal communicationand a set of global Internet addresses (at

    least one) for communication with the rest ofthe world

    75

  • 8/13/2019 Advanced Computer Networks Chapter 3

    76/76

    All of the outgoing packets go through theNAT router, which replaces the sourcesaddress in the packet with the global NATaddress

    All incoming packets also pass through theNAT router, which replaces the destinationaddressin the packet with the appropriateprivate address