CS470 Computer Networking Protocols 4/26/2017 CS470 Computer Networking Protocols 6. IP Addressing Huiping Guo Department of Computer Science California State University, Los Angeles
Outline IP addresses Subnetting 5. IP addressing CS470_W12
TCP/IP Addresses Addressing in TCP/IP is specified by the Internet Protocol (IP) Each host is assigned a 32-bit number Called the IP address or Internet address Unique across entire Internet Each IP address is divided into a prefix and a suffix Prefix identifies network to which computer is attached No two networks can be assigned the same network number Suffix identifies computer within that network No two computers on the same network can have the same suffix, but computers on different networks can have the same suffix Address format makes routing efficient 5. IP addressing CS470_W12
Properties of IP Addresses Network numbers (prefix) are unique Assignment of network numbers must be coordinated globally to ensure uniqueness Assigned by ICANN: Internet Corporation of Assigned Names and Numbers Host addresses (suffix) may be reused on different networks combination of network number prefix and host address suffix will be unique assignment of host addresses can be managed locally 5. IP addressing CS470_W12
Designing IP IP designers chose 32-bit addresses Still 32 bits in IP version 4 used today May cause a problem soon, not a large enough address space! Allocate some bits for prefix, some for suffix Large prefix, small suffix - many networks, few hosts per network Small prefix, large suffix - few networks, many hosts per network Because of variety of technologies, need to allow for both large and small networks 5. IP addressing CS470_W12
Classful Addressing Designers chose a compromise - multiple address formats that allow both large and small prefixes Each format is called an address class Class of an address is identified by first four bits 5. IP addressing CS470_W12
Address Classes Class A, B and C are primary classes Used for ordinary host addressing Owner of a class is assigned a prefix, gets to pick what machines they want in the suffix Classes A and B are all allocated! Class D is used for multicast, a limited form of broadcast Class E is reserved for future use 5. IP addressing CS470_W12
Compute the Class of an Address IP needs to separate the destination address into a prefix and suffix when it handles a packet Look at first dotted decimal number, and use this table: Just a little binary number conversion based on first 4 bits 5. IP addressing CS470_W12
Division of the Address Space Classing scheme does not yield equal number of networks in each class Class A: First bit must be 0 7 remaining bits identify Class A net 27 (= 128) possible class A nets For the rest: 5. IP addressing CS470_W12
Classful Addressing Example Organization with four networks, completely private network Assign Class A,B,C addresses as appropriate for number of hosts on each network 5. IP addressing CS470_W12
Limitations of the classful addressing scheme The IP address space is being exhausted All networks had to choose one of the three possible sizes, many addresses were wasted. Ex. A company requests a network address with a block of 1000 host address Has to get a class B address 216-1000 addresses are unused 5. IP addressing CS470_W12
Subnet and Classless Addressing Mechanisms to overcome the limitations Subnetting and Classless Addressing Take a single IP network number and allocate the IP addresses with that network number to several physical networks, which are referred to as subnets The postfix of the IP address is further divided into two parts: subnet id and host address Each subnet is assigned a subnet number All host in the same subnet share the same subnet number The network number and the subnet number now become the new network prefix 5. IP addressing CS470_W12
Subnet masks Classless and subnet addressing requires an additional piece of information stored with each address Known as address masks or subnet masks Used to specify the boundary between the network prefix and the host prefix 1 bits mark the network prefix 0 bits mark the host portion Default subnet mask: Class A: 255.0.0.0 Class B: 255.255.0.0 Class C: 255.255.255.0 5. IP addressing CS470_W12
Example We want to share a single class B address among several physical networks (subnets) We can use a subnet mask of 255.255.255.0 Top 24 bits are now defined to be the network number Lower 8 bits are the host number Since the top 16 bits identify the network in a class B address, there are 3 parts in the IP address: a network part, a subnet part and a host part 5. IP addressing CS470_W12
Subnetting example 5. IP addressing CS470_W12
Subnets and Subnet Masks Each host is configured with both an IP address and a subnet mask for the subnet to which it’s attached The bitwise AND of the two numbers defines the subnet number of the host and of all other hosts on the same subnet Eg: At H1, 128.96.34.15 AND 255.255.255.128 = 128.96.34.0 How will hosts use the subnet mask? A host: decides whether a destinations address in a packet is local or not When sending to a destination IP address, perform bitwise AND between the destination IP address and its own subnet mask If the result equals the subnet number of the sender, then it knows that the destination host is on the same subnet Otherwise, the packet needs to be sent to a router to be forwarded to another subnet. 5. IP addressing CS470_W12
Routers and subnets For simple IP, a router has a forwarding table that consists of entries of the form (networkNumber, NextHop) To support subnetting, the table now hold entries of the form Subnet number Subnet mask Next hop 128.96.34.0 255.255.255.128 Interface 0 128.96.34.128 Interface 1 128.96.33.0 255.255.255.0 Interface 2 5. IP addressing CS470_W12
Data forwarding algorithm D = destination IP address For each forwarding table entry(subnetNumber, subnetMask, nextHop) D1 = SubnetMask & D If D1 = subnetNumber, deliver datagram to nextHop (a router or a network) 5. IP addressing CS470_W12
What’s a subnet ? Another name of physical network 223.1.1.1 223.1.1.2 223.1.1.3 223.1.1.4 223.1.2.9 223.1.2.2 223.1.2.1 223.1.3.2 223.1.3.1 223.1.3.27 network consisting of 3 subnets subnet Another name of physical network A subnet is a collection of machines that can communicate with each other without the need for routing Every subnet has at least one router/gateway. If it didn’t, then the subnet couldn’t talk to any machines outside of its network. 5. IP addressing CS470_W12
Subnets Recipe To determine the subnets, detach each interface from its router, creating islands of isolated networks. Each isolated network is a subnet. 5. IP addressing CS470_W12
Subnets How many subnets? 6! 223.1.2.1 223.1.1.2 223.1.1.1 223.1.1.3 223.1.1.4 223.1.2.2 223.1.2.6 223.1.3.2 223.1.3.1 223.1.3.27 223.1.7.0 223.1.7.1 223.1.8.0 223.1.8.1 223.1.9.1 223.1.9.2 Subnets How many subnets? 6! 5. IP addressing CS470_W12
CIDR Notation CIDR = Classless Inter-Domain Routing Notation for classless addresses Specifies the mask associated with an address Appends a slash to the address with the size of the mask in decimal Examples: 128.10.0.0/16 says 16 bit prefix, 16 bit suffix (Class B) 128.211.0.16/28 28 bit prefix, 4 bit suffix 5. IP addressing CS470_W12
CIDR Example 1 5. IP addressing CS470_W12
Reserved Addresses RFC 1597 – Address Allocation for Private networks The following blocks are reserved for private networks 10.0.0.0 - 10.255.255.255 Class A 172.16.0.0 - 172.31.255.255 Class B 192.168.0.0 - 192.168.255.255 Class C We’ll need a gateway to translate from these addresses to the Internet addresses Network Address Translation We should never see a machine on the Internet with one of these network prefixes (hopefully) 5. IP addressing CS470_W12
Special IP Addresses Network Address Directed Broadcast Address The network itself is assigned an address So no host can have all zero’s as its IP address suffix Prefix is the network prefix, suffix is all zero’s Eg. 128.211.0.0/16 Directed Broadcast Address Broadcast message to a network Prefix is the network prefix, suffix is all one’s So no host can have all one’s as its IP address suffix Limited Broadcast Address Broadcast on the local LAN Entire address is all 1’s, i.e. 255.255.255.255 5. IP addressing CS470_W12
More Special IP Addresses This Computer Address To obtain an address automatically when booting, we may use IP to communicate… but we don’t have a correct IP address yet Use an address of all zero’s to indicate “this computer” Loopback Address Any address beginning with 127 indicates the local computer E.g. 127.0.0.1 most common, but could be 127.0.44.53 Use for testing network applications, no packets leave the computer 5. IP addressing CS470_W12
Special Address Summary 5. IP addressing CS470_W12
Subnetting Subnetting is the division of a single network into smaller subnets. Each subnet functions as if it were an independent network As far as entries in the routing table are concerned All subnets of a given network number use the same network-prefix but different subnet numbers. 5. IP addressing CS470_W12
Why are subnets created? Provides greater organization of large networks. Remember: a Class A network can have up to 16 million hosts. It allows you to have additional networks without applying for more IP addresses. Decreases broadcast traffic by reducing broadcast domain size. Broadcasts are not forwarded out of a subnet. 5. IP addressing CS470_W12
How to subnet a network? Borrow bits from the host field of an IP address. All the subnets have the same network prefix Subnets are only visible to routers inside the network Netid subnetid hostid 16 24 31 5. IP addressing CS470_W12
Subnet a network: steps Determine the number of subnets How many bits to be borrowed? For each subnet, determine The network address subnet bits cannot be all on or off at the same time The host address range The broadcast address Determine the number of required host per subnet: One for each host One for each router interface 5. IP addressing CS470_W12
Subnetting example 1: You are assigned a network address 214.97.254/23. You want to create 2 subnets. What are the network addresses and broadcast addresses of the 2 subnets? What are the address range in the 2 subnets? 5. IP addressing CS470_W12
Subnetting example 1: 11010110 01100001 11111110 0 000 0000 Subnet 1: 23 Subnet bits 11010110 01100001 11111110 0 000 0000 Subnet 1: Network address: 11010110 01100001 11111110 1000 0000/25 Broadcast address: 11010110 01100001 11111110 1111 1111/25 Address range: 11010110 01100001 11111110 1000 0001/25 11010110 01100001 11111110 1111 1110/25 126 IP addresses 5. IP addressing CS470_W12
Subnetting example 1: Subnet 2: Network address: 11010110 01100001 11111111 0000 0000/25 Broadcast address: 11010110 01100001 11111111 0111 1111/25 Address range: 11010110 01100001 11111111 0000 0001/25 11010110 01100001 11111111 0111 1110/25 126 IP addresses 5. IP addressing CS470_W12
Subnetting example 2: You are assigned a network address 214.97.254/23. If you assign 3 bits to the subnets. How many subnets can be created What are the network addresses and broadcast addresses of the subnets? What are the address range of the subnets? 5. IP addressing CS470_W12
Subnetting example 2: 23 Subnet bits 11010110 01100001 11111110 0000 0000 The number of subnets: 23-2=6 Subnet 1: Network address: 11010110 01100001 11111110 0100 0000/26 Broadcast address: 11010110 01100001 11111110 0111 1111/26 Address range: 11010110 01100001 11111110 0100 0001/26 11010110 01100001 11111110 0111 1110/26 26-2=62 IP addresses 5. IP addressing CS470_W12
Subnetting example 2: Subnet 2: Network address: 11010110 01100001 11111110 1000 0000/26 Broadcast address: 11010110 01100001 11111110 1011 1111 Address range: 11010110 01100001 11111110 1000 0001 11010110 01100001 11111110 1011 1110 26-2=62 IP addresses 5. IP addressing CS470_W12
Subnetting example 2: Subnet 3: Network address: 11010110 01100001 11111110 1100 0000/26 Broadcast address: 11010110 01100001 11111110 1111 1111 Address range: 11010110 01100001 11111110 1100 0001 11010110 01100001 11111110 1111 1110 26-2=62 IP addresses 5. IP addressing CS470_W12
Subnetting example 2: Subnet 4: Network address: 11010110 01100001 11111111 0000 0000/26 Broadcast address: 11010110 01100001 11111111 0011 1111 Address range: 11010110 01100001 11111111 0000 0001 11010110 01100001 11111111 0011 1110 26-2=62 IP addresses 5. IP addressing CS470_W12
Subnetting example 2: Subnet 5: Network address: 11010110 01100001 11111111 0100 0000/26 Broadcast address: 11010110 01100001 11111111 0111 1111 Address range: 11010110 01100001 11111111 0100 0001 11010110 01100001 11111111 0111 1110 26-2=62 IP addresses 5. IP addressing CS470_W12
Subnetting example 2: Subnet 6: Network address: 11010110 01100001 11111111 1000 0000/26 Broadcast address: 11010110 01100001 11111111 1011 1111 Address range: 11010110 01100001 11111111 1000 0001 11010110 01100001 11111111 1011 1110 26-2=62 IP addresses 5. IP addressing CS470_W12