IPV4 ADDRESSING
• IPv4Addressing
• Forwardingofnetwork-layerpackets
Copyright By PowCoder代写 加微信 powcoder
IPv4 Addressing
• IPaddressistheidentifierusedintheIPlayerofthe TCP/IP protocol suite to identify the connection of each device to the Internet
• IPv4addressisa32-bitaddressthatuniquelyand universally defines the connection of a host or a router to the Internet.
• TheIPaddressistheaddressoftheconnection,notthe host or the router, because if the device is moved to another network, the IP address may be changed
• IPv4addressesareuniqueinthesensethateach address defines one, and only one, connection to the Internet.
IPv4 Addressing
• IfadevicehastwoconnectionstotheInternet,viatwo networks, it has two IPv4 addresses.
• IPv4addressesareuniversalinthesensethatthe addressing system must be accepted by any host that wants to be connected to the Internet.
• The address space of IPv4 is 232 or 4,294,967,296
IPv4 Address Notation
IPv4 Address Hierarchy
• IPv4addressishierarchical
• IPv4addressisdividedonlyintotwoparts:
– prefix, defines the network;
– suffix, defines the node (connection of a device to the Internet)
IPv4 Address Hierarchy
Classful Addressing
• IPv4 address was designed with a fixed-length prefix
• Toaccommodatebothsmallandlargenetworks,three fixed-length prefixes were designed instead of one
– ClassA:n=8,
– ClassB:n=16,and – ClassC:n=24
• Thewholeaddressspacewasdividedintofiveclasses (class A, B, C, D, and E)
• This scheme is referred to as classful addressing
Classful Addressing
Classful Addressing
Address Depletion
• Classfuladdressinghasbecomeobsoletebecauseof
address depletion
• theInternetwasfacedwiththeproblemofthe addresses being rapidly used up, resulting in no more addresses available for organizations and individuals that needed to be connected to the Internet
– classAcanbeassignedtoonly128organizations, each organization needs to have a single network with 16,777,216 nodes – too large for most organizations, and too few organizations
Address Depletion
• ClassBaddressesweredesignedformidsize organizations, but many of the addresses in this class also remained unused
• ClassCaddresseshaveacompletelydifferentflawin design. The number of addresses that can be used in each network (256) was so small that most companies were not comfortable using a block in this address class
• ClassEaddresseswerealmostneverused,wastingthe whole class
Subnetting
• Insubnetting,aclassAorclassBblockisdividedinto several subnets. Each subnet has a larger prefix length than the original network
• Forexample,ifanetworkinclassAisdividedintofour subnets, each subnet has a prefix of nsub = 10
• subnettingallowstheaddressestobedividedamong several organizations
– This idea did not work because most large organizations were not happy about dividing the block and giving some of the unused addresses to smaller organizations
Supernetting
• supernettingwasdevisedtocombineseveralclassC blocks into a larger block to be attractive to organizations that need more than the 256 addresses available in a class C block.
– This idea did not work either because it makes the routing of packets more difficult
Advantage of Classful Addressing
• classfuladdressinghadseveralproblemsandbecame obsolete
• ithadoneadvantage:Givenanaddress,wecaneasily find the class of the address and, since the prefix length for each class is fixed, we can find the prefix length immediately
Classless Addressing
• Subnettingandsupernettinginclassfuladdressingdid not really solve the address depletion problem
• WiththegrowthoftheInternet,itwasclearthata larger address space was needed as a long-term solution
– long-term solution has already been devised and is called IPv6 (discussed later)
– short-term solution still uses IPv4 addresses, but it is called classless addressing
Classless Addressing
• Anothermotivationforclasslessaddressingisriseof Internet Service Providers (ISPs)
– ISP is an organization that provides Internet access for individuals, small businesses, and midsize organizations
– ISP is granted a large range of addresses and then subdivides the addresses (in groups of 1, 2, 4, 8, 16, and so on)
– In 1996, the Internet authorities announced a new architecture called classless addressing
– the prefix length in classless addressing is variable
Prefix Length: Slash Notation
• Howtofindtheprefixlengthifanaddressisgiven?
• theprefixlengthisnotinherentintheaddress
• theprefixlength,n,isaddedtotheaddress,separated by a slash
• The notation is informally referred to as slash notation and formally as classless inter-domain routing or CIDR
Extracting Information from an Address
• Givenprefixlength,n:
– The number of addresses in the block is found as N = 232−n
– The first address: keep the n leftmost bits and set the (32 − n) rightmost bits all to 0s
– The last address: keep the n leftmost bits and set the (32 − n) rightmost bits all to 1s
Address Mask
• Anotherwaytofindthefirstandlastaddressesinthe block is to use the address mask
• Theaddressmaskisa32-bitnumberinwhichthen leftmost bits are set to 1s and the rest of the bits (32 − n) are set to 0s
• Address mask = 2(32) – 2(32-n)
Address Mask
• Address Mask = 2(32) – 2(32-n)
• Thenumberofaddressesintheblock
– N = 2(32-n)
• Thefirstaddressintheblock
– First = (Any address in the block) & (mask)
• Thelastaddressintheblock
– Last = (Any address in the block) | (~mask)
Bitwise OR
Bitwise AND
Bitwise NOT
• Address: 167.199.170.82/27
– 10100111-11000111-10101010-01010010 – A7C7AA52
• First address: 167.199.170.64/27
– 10100111 11000111 10101010 01000000 – A7C7AA40
– 167.199.170.64
• Last address: 167.199.170.95/27
– 10100111 11000111 10101010 01011111 – A7C7AA5F
– 167.199.170.95
• Numberofaddressesintheblock
–232-27 =25=32
• Address Mask = 232 – 25 = 0xFFFF-FFE0
• = 0b1111-1111-1111-1110-0000
Example – using the address mask
• Address: 167.199.170.82/27
– 10100111 11000111 10101010 01010010
• Address mask
– 11111111 11111111 11111111 11100000
• First address: Addr & Mask
– 10100111 11000111 10101010 01010010 &
11111111 11111111 11111111 11100000 =
– 10100111 11000111 10101010 01000000
• Last address: Addr | ~Mask
– 10100111 11000111 10101010 01010010 | – 00000000 00000000 00000000 00011111 = – 10100111 11000111 10101010 01011111
Network Address
• Thefirstaddress,thenetworkaddress,isparticularly important because it is used in routing a packet to its destination network
• Networkaddressistheidentifierusedtosearchthe routing table
Block Allocation
• Therearerestrictiononhowblocksofaddressescanbe allocated to ISP and its customers
1. Thenumberofrequestedaddresses,N,needstobe a power of 2.
N = 232-n , n is prefix size
n = 32 − log2N
If N is not a power of 2, we cannot have an integer value for n.
2. Therequestedblockneedstobeallocatedwhere
there is an adequate number of contiguous
addresses available in the address space
The suffix part must span the whole range from all zeros to all ones
• AnISPhasrequestedablockof1000addresses,find the adequate n value
• Solution:
– N = 232-n
– n = 32 − ceil(log2N) = 32 – ceil(9.96578)
– N=32–10=22
– Mask = 11111111 11111111 11111100 00000000 – Actual block size = 210
– Actual block size = 1024
Designing Subnets
• Thefollowingstepsneedtobecarefullyfollowedto guarantee the proper operation of the subnetworks:
– ❑Thenumberofaddressesineachsubnetwork should be a power of 2.
– ❑Theprefixlengthforeachsubnetworkshouldbe found using the following formula:
nsub = 32 − log2Nsub
– ❑Thestartingaddressineachsubnetworkshould be divisible by the number of addresses in that subnetwork.
This can be achieved if we first assign addresses to larger subnetworks
• Anorganizationisgrantedablockofaddresseswiththe beginning address 14.24.74.0/24.
• Theorganizationneedstohave3sub-blocksof
addresses to use in its three subnets: one sub-block of
10 addresses, one sub-block of 60 addresses, and one
sub-block of 120 addresses. Design the sub-blocks
• Solution:
– Ceil(log2(120)) = ceil(6.9) = 7 – Ceil(Log2(60)) = ceil(5.91) = 6
– Ceil(Log (10)) = Ceil(3.32) = 4 2
Prefix [24]
• Net[8]address:14.24.74.0/24
• Net[7]address:14.24.74.128/25 • Net[6]address:14.24.74.64/26 • Net[4]address:14.24.74.48/28
Prefix [24]
• Anothersolution
– Net[8] address: 14.24.74.0/24
– Net[7] address: 14.24.74.0/25
– Net[6] address: 14.24.74.128/26 – Net[4] address: 14.24.74.192/28
Example1 – continue
• Foursmallblocksofaddressesareassignedtofour organizations by an ISP.
• TheISPcombinesthesefourblocksintoonesingle block and advertises the larger block to the rest of the world.
• Anypacketdestinedforthislargerblockshouldbesent to this ISP.
Special Addresses • This-hostAddress
– The only address in the block 0.0.0.0/32 is called the this-host address. It is used whenever a host needs to send an IP datagram but it does not know its own address to use as the source address.
• Limited-broadcastAddress
– The only address in the block 255.255.255.255/32 is called the limited-broadcast address. It is used whenever a router or a host needs to send a datagram to all devices in a network.
– The routers in the network, however, block the packet having this address as the destination; the packet cannot travel outside the network
Special Addresses
• LoopbackAddress
– The block 127.0.0.0/8 is called the loopback address.
– A packet with one of the addresses in this block as the destination address never leaves the host; it will remain in the host. Any address in the block is used to test a piece of software in the machine.
– For example, we can write a client and a server program in which one of the addresses in the block is used as the server address. We can test the programs using the same host to see if they work before running them on different computers
Special Addresses • PrivateAddresses
– Four blocks are assigned as private addresses:
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, and 169.254.0.0/16. We will see the applications of these addresses when we discuss NAT later in the chapter
• MulticastAddresses
– The block 224.0.0.0/4 is reserved for multicast addresses. We discuss these addresses later in the chapter
Network Address Resolution (NAT)
• Inmostsituationsonlyaportionofcomputersina small network need access to the Internet simultaneously
• Thismeansthatthenumberofallocatedaddressesdoes not have to match the number of computers in the network, it can be much less!
• Atechnologythatcanprovidethemappingbetweenthe private and universal addresses, and at the same time support virtual private networks Network Address Translation (NAT).
Network Address Resolution (NAT)
Network Address Resolution (NAT)
• theprivatenetworkusesprivateaddresses.
• Therouterthatconnectsthenetworktotheglobal address uses one private address and one global address.
• Theprivatenetworkisinvisibletotherestofthe Internet; the rest of the Internet sees only the NAT router with the address 200.24.5.8
NAT Address Translation
• AlloutgoingpacketsgothroughtheNATrouter,which replaces the source address in the packet with the global NAT address.
• AllincomingpacketspassthroughtheNATrouter, which replaces the destination address in the packet (the NAT router global address) with the appropriate private address.
NAT Translation Table
• Translatingthesourceaddressesforanoutgoingpacket is straightforward
– Many private addresses are mapped to one (or few) global address
• ButhowdoestheNATrouterknowthedestination address for a packet coming from the Internet?
– One (or few) global address is mapped to many private addresses!!!!
• TheproblemissolvediftheNATrouterhasa translation table.
Translation Table – Using One IP Address
Translation Table – Using One IP Address
• Whentheroutertranslatesthesourceaddressofthe outgoing packet, it also makes note of the destination address— where the packet is going.
• Whentheresponsecomesbackfromthedestination, the router uses the source address of the packet (as the external address) to find the private address of the packet
• NATisusedmostlybyISPsthatassignasingleaddress to a customer. The customer, may be a member of a private network that has many private addresses. In this case, communication with the Internet is always initiated from the customer (private) site
Translation Table – Using Pool IP Address
NAT router can use a pool of global addresses
Inthiscase,multipleprivate-networkhostscan communicate with the same external host at the same time because each pair of addresses defines a separate connection
Therearesomedrawbacks.
1. No more than limited connections can be made to the same destination. Limited by pool size
2. No private-network host can access two external server programs (e.g., HTTP and TELNET) at the same time.
3. Two private-network hosts cannot access the same external server program (e.g., HTTP or TELNET) at the same time.
Using Both IP Addresses and Port
• Ifmorethanonehostisaccessinghesameserver,how can NAT distinguish them
– Using their port number – must use different port number
Forwarding of IP Packets
• Forwardingmeanstoplacethepacketinitsroutetoits destination
• SincetheInternettodayismadeofacombinationof links (networks), forwarding means to deliver the packet to the next hop
• AlthoughtheIPprotocolwasoriginallydesignedasa connectionless protocol, today the tendency is to change it to a connection-oriented protocol
Forwarding of IP Packets
• WhenIPisusedasaconnectionlessprotocol, forwarding is based on the destination address of the IP datagram
• whentheIPisusedasaconnection-orientedprotocol, forwarding is based on the label attached to an IP datagram
Forwarding Based on destination Address
• Forwardingbasedonthedestinationaddressisthe traditional approach
• Whenarouterhasreceivedapackettobeforwarded,it looks at this table to find the next hop to deliver the packet to
• Forwardingtablerequiresonerowofinformationfor each block of contiguous addresses involved
• Thetableneedstobesearchedbasedonthenetwork address (first address in the block)
• weneedtoincludethemask(/n)inthetable
Forwarding Based on DST Address
• Aclasslessforwardingtableneedstoincludefourpieces of information:
1. themask,
2. thenetworkaddress,
3. theinterfacenumber,and
4. theIPaddressofthenextrouter(neededtofind the link-layer address of the next hop
Forwarding Based on DST Address
Forwarding Based on DST Address
• Thejoboftheforwardingmoduleistosearchthetable, row by row.
– In each row, the n leftmost bits of the destination address (prefix) are kept and the rest of the bits (suffix) are set to 0s.
– If the resulting address (which we call the network address), matches with the address in the first column, the information in the next two columns is extracted;
– otherwise the search continues.
– Normally, the last row has a default value in the first column, which indicates all destination addresses that did not match the previous rows
Example – continue
Example – continue
• ShowtheforwardingprocessifapacketarrivesatR1 with the destination address 180.70.65.140.
• Solution:trym2
– IP: 10110100 01000110 01000001 10001100
– Mask1: /26
– 11111111 11111111 11111111 11000000
– Net Address
– 10110100 01000110 01000001 10000000
– 10110100 01000110 01000001 11000000 – Not matching, m2 is not good
Example – continue
• ShowtheforwardingprocessifapacketarrivesatR1 with the destination address 180.70.65.140.
• Solution:trym0
– Matching, m0 is right!
IP: 10110100 01000110 01000001 10001100 Mask2: 25
11111111 11111111 11111111 10000000 Net Address
10110100 01000110 01000001 10000000
10110100 01000110 01000001 10000000
Address Aggregation
• Asthenumberofsubnetsincrease,thenumberof entries in the routing table increase
• Ifaddressesarecontiguousontheothersideofthe same router, we can aggregate the block
• Examplewillclarify
– Router R2 uses the aggregate address of the 4 organizations connected to R1
– This way it saves space in the forwarding table and speed up search
Address Aggregation
Longest Mask Matching
• Whentheaggregateaddresshasawholethatrequires a separate entry in the routing table, this can be done by placing the entry before the aggregate one
– This guarantees that the special case is considered before the general one
– The forwarding table is ordered in terms of the prefix size
– This is called longest mask matching
Hierarchical Routing
• TheInternetisdividedintobackboneandnationalISPs.
• NationalISPsaredividedintoregionalISPs,and
• regionalISPsaredividedintolocalISPs.
• Iftheforwardingtablehasasenseofhierarchylikethe Internet architecture, the forwarding table can decrease in size.
Hierarchical Routing
• AlocalISPcanbeassignedasingle,butlarge,blockof addresses with a certain prefix length.
• ThelocalISPcandividethisblockintosmallerblocksof different sizes, and assign these to individual users and organizations, both large and small.
• AllroutersoutsideofthelocalISPcanuseasingleentry to reach any node served by the local ISP
• InternallythelocalISPwillhaveadetailedroutingtable to reach all nodes served by it
Hierarchical Routing
If one of the customers of the local ISP is a large organization, it also can create another level of hierarchy by subnetting and dividing its subblock into smaller subblocks (or sub-subblocks).
Inclasslessrouting,thelevelsofhierarchyare unlimited as long as we follow the rules of classless addressing
Hierarchical Routing – Example
Forwarding Based on Label
• Connectionlessnetwork(datagramapproach),arouter forwards a packet based on the destination address in the header of the packet.
• Connection-orientednetwork(virtual-circuitapproach), a switch forwards a packet based on the label attached to the packet.
– Routing is normally based on searching the contents of a table
– Switching can be done by accessing a table using an index
– Routing involves searching; switching involves accessing.
Forwarding Based on Label
References
• DataCommunicationsandNetworking5thedition– 2013, Behrouz A. Forouzan; Chapter 18-4:5
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com