IP Addressing - The Problem Have to assign addresses so that the Internet can find a destination with the minimum of processing, memory, bandwidth etc Therefore address must be assigned so that we can quickly identify the rough location of a machine ie, address must be based on the home network
IP Addressing - The Problem IPv4 addresses begin with the address of the network where machine is located Allows routers to figure out quickly where the machine is located Once a packet has reached this network, it is the responsibility of the network to find the correct machine (and send the packet there)
IP Addressing - The Problem We do not want to waste addresses Therefore we do not want to allocate to any network, a lot of addresses which will never be used However, we do want to leave room for growth of the networks So must leave some unused addresses for every network
IP Addressing - The Problem Networks are of different sizes Smallest may be just a few computers Largest may have hundreds of thousands How do we differentiate between networks of different sizes?
IPv4 The solution adopted by IPv4 was to have several “classes” of networks Class A networks - up to 224 = 16,000,000 addresses Class B networks - up to 216 = 65,000 addresses Class C networks - up to 28 = 256 addresses
IPv4 IPv4 Address Formats 0 Network (7 bits) Host (24 bits) Class A 10 Network (14 bits) Host (16 bits) Class B 110 Network (21 bits) Host (8 bits) Class C IPv4 Address Formats
IPv4 This gives very coarse granularity However, does allow: many small networks = 221 = 2,000,000 moderate number of medium sized networks = 214 = 16,000 very few large networks = 27 = 128 (less than one per member country of the UN)
IPv4 When the Internet was small, the coarseness was not a problem Now we are running out of addresses This system locks up addresses that are needed in other parts of the network We need to get out of this somehow
Subnetting The Internet community has solved this problem in three steps 1 Class-Based IPv4 Subnetting 2 Classless Inter-Domain Routing (CIDR) 3 Distributed subnetting - IPv6
Class-Based IPv4 Subnetting Remember the structure of the address: class identifier.network id.host id Problem is that the boundary between fields for network and host ids can only move in steps of eight bits Would like to let it move in smaller steps
Class-Based IPv4 Subnetting We cannot move the boundary back towards the beginning of the address We can move it forwards, using class-based IPv4 subnetting We use the first few bits of the host id as the identifier of a new network which we call a “subnetwork”
Class-Based IPv4 Subnetting We need a number of networks to agree to share a network ID, and to use different subnetwork IDs eg, a Class B network has 65,000 addresses. If 12 networks had an average of, say, 2000 hosts on their networks, but were all too big to use a Class C network ID, they would apply for a class B network ID
Class-Based IPv4 Subnetting Any of them would waste a lot of address space if they were given a Class B network ID But, together, they could share one network ID Since there are 12 of them, we need four bits as the subnet ID (24 = 16 > 12)
Class-Based IPv4 Subnetting 10 Network ID Subnet ID Host ID Address would now look like this Class ID as before Network ID as before Subnet ID four bits Host ID 12 bits
Class-Based IPv4 Subnetting No of hosts allowed for one subnet is 212 = 4,096 The larger networks could be given more than one subnet ID Would allow address space to be allocated in blocks of 4,096 addresses
Reserved Addresses ID fields of all 0s or all 1s are not allocated to hosts Subnet IDs cannot be all 1s
Class-Based IPv4 Subnetting Host 1.1.2 Host 1.1.1 Subnet 1.1 Host 1.1.3 Network 1 Subnet 1.2 Host 1.2.1 Host 1.2.3 Host 1.2.2
Routing with Subnetting Internet routers only look at the network ID A single gateway (router) could be used for all these subnets The gateway would then look at the subnet ID and send packets to the correct subnet This is a good solution if all networks are within a small geographical area, eg a single building or city block
Routing to a WAN Network could be a WAN, with all subnets owned by the same organisation Each subnet would cover one location Nearby routers could be informed of this situation These routers could look at subnet ID and send packets to appropriate location
Classless Inter-Domain Routing Variable length subnetting - within a single network ID, allow subnets with different length IDs (subnet masks) Allows accommodation of different size subnets within the one network
CIDR Every network which is given a block of addresses in CIDR must be listed in the routing table of all backbone routers This can result in very large routing tables for these routers There is no guarantee that these networks will be geographically close together
Network Address Translation NAT is a quick and nasty solution to the problem of the shortage of IPv4 addresses A single IP address is assigned to a network Even if there are 10,000 computers on the network, they are all given the one IP address, as used by the network This allows one address to cover 10,000 computers
N.A.T. The problem arises when a packet arrives at the network from outside, ie from the Internet How does the network’s router/gateway know where to send the packet? (Usually each computer on the network has its own unique IP address.) We need a NAT box at the router
N.A.T. Box 10.0.0.1 Address before translation Address after translation 198.60.42.12 NAT box To ISP’s router Company router Company LAN Source: A.S. Tanenbaum
N.A.T. Packets leaving the network all have the same source address Packets arriving at the network all have the same destination address, but must be sent to one of 10,000 different machines We get around this problem by misusing the TCP or the UDP field
N.A.T. It was observed that nearly all traffic between Internet networks uses either TCP or UDP as the transport layer protocol This is the layer above the network layer (where the IP address is located) in the packet header It is only used at the two ends of the connection, never in the networks which carry the packet
N.A.T. Therefore it is (usually) safe for the NAT box to change the transport header, as long as it remembers to change it back When an application establishes a connection with another machine, it nominates a “port” on its own machine and another port on the destination machine.
TCP Ports The destination port tells the remote computer where to store an incoming packet The remote computer does not use the source port for anything. It simply returns packets with this port number as the destination port This allows us to use this port number to carry extra informaton
N.A.T. use of TCP ports A packet from a computer in the home network carries its own IP address for use only in the LAN The NAT records this address, and the TCP source port in a table The line of the table is entered in the 16 bits of the TCP source port
N.A.T. use of TCP ports The network IP address is written into the IP header in place of the source address The packet is sent to its destination across the Internet, and returns to the router/gateway of the network The router/gateway reads the 16 bits in the TCP header to find which line of its table to read
N.A.T. use of TCP ports From the table, it finds the internal IP address of the machine for which the packet is intended, and also the correct TCP port to send the packet to It then sends the packet to the correct machine The machine knows which process to send the packet to (from the TCP header), and the connection is complete
Is NAT a Good Idea? NAT uses TCP or UDP for a task it is not intended for This produces many difficulties in practice However, NAT provides us with a little extra time to get IPv6 into widespread use throughout the Internet
Supernetting Organisations with complex networks can acquire contiguous blocks of Class C IDs (eg x00, x01, x10 and x11 where x = first 19 bits of Class C addresses) and advertise a single route for reaching all of them Routers and gateways “advertise” their location to neighboring Internet nodes. This is used in routing
CIDR Network Naming Internet Network Information Center (InterNIC) serves as the Internet central naming registry With CIDR InterNIC delegated naming of local networks to ISPs and other middlemen
Use of Address to Locate a Destination Router looks at first few bits of address to determine the class Then looks at appropriate number of bits to determine the network ID If network is known to router, sends packet on to appropriate next hop Otherwise sends packet to “default router”
Default Router Generally will be available router which is closest to the backbone Routers in backbone do not have a “default router” Must look at network ID and choose intelligent next hop Must therefore have very large routing table
Backbone Router This has become a big problem since there are 2,000,000 Class C IDs CIDR has allowed Class C network IDs to be aggregated So has taken some pressure off backbone routing tables IPv6 has made it easier still
IPv6 Main problems with IPv4 are: Limited size of address space Difficulty using network class system Inflexibility in two level address (network.host) InterNIC did all network naming Size of routing tables in backbone routers
IPv6 Address Uses 128 bits (compare 32 bits for IPv4) Represented as eight numbers divided by : 128 = 8*16, each number represents 16 bits Numbers use hexadecimal system eg 46F3:57:0:0:0:0:5D2C:21AA = 46F3:57::5D2C:21AA (compare eg 223.182.21.93 for IPv4)
IPv6 Address Types Unicast - specific physical interface to a network Multicast - packets sent to all members of a set of physical interfaces Anycast - packets sent to at least one member of a set of interfaces
Allocation of Addresses Nearly all addresses are unassigned Prefix 001 is used for “Aggregatable Global Unicast Addresses” Accounts for 1/8 total address space Prefix 1111 1111 is used for multicast addresses For other allocations, see RFC 2373
Aggregatable Global Unicast These addresses (only) are formatted as follows 3 13 8 24 16 64 bits FP TLA RES NLA SLA Interface ID ID ID ID
Aggregatable Global Unicast FP - Format Prefix - currently 001 TLA ID - Top Level Aggregation Identifier - contains the highest level routing information of the address. Currently 13 bits - limits routing table entries to 8,192 Res - eight bits reserved for future use
Aggregatable Global Unicast NLA ID - Next Level Aggregation Identifier - to be used by organisations that control the top level IDs, eg large ISPs. Within their address space, they are free to configure up to 224 address sub-spaces SLA ID - Site Level Aggregation Identifier - Each organisation can create its own internal hierarchical structure
Aggregatable Global Unicast Interface ID - 64 bit field - Designed to use IEEE EUI-64 interface ID Similar to 48 bit MAC address Unique across global scope 264 interfaces = roughly 18 billion billion different addresses
Aggregatable Global Unicast IPv6 addresses are allocated by the ISPs, and are based on the ISP structural hierarchy IPv6 addressing is designed to help routers, and not to use all the theoretical 2128 possible addresses
ISP Hierarchical Structure Internet backbone Top Level ISP Next Next Next Next Next Next Level Level Level Level Level Level ISP ISP ISP ISP ISP ISP
Routing with IPv6 Addresses As before, routers have a default router Send packets to the default router if they do not have a route to the TLA ID Backbone routers do not have a default router Must have a route to every TLA ID There are only 8,192 TLA IDs
Routing with IPv6 Addresses After packet has reached Top Level ISP, router looks at NLA ID. All these NLA IDs correspond to next level ISPs which are clients of the top level ISP This will be a relatively small number (although 24 bits are allowed at present) Lower levels are treated similarly
Multicast Addresses In both IPv4 and IPv6, multicast addresses are mapped to a set of unicast addresses In IPv4, Class D is the class which contains all multicast addresses. The first four bits are 1110 In IPv6, the first eight bits are all 1s
Anycast Addresses Packet is forwarded to at least one of the nodes which are members of the anycast address Useful when any of the nodes will do the job An example is a DNS (domain name server). It does not matter where the response comes from