390 likes | 403 Views
Learn about IPv4 addressing and classless addressing, including subnetting and supernetting techniques. Explore subnet configurations and address block allocations.
E N D
IP Logical Networks COMP 3270 Computer Networks Computing Science Thompson Rivers University
An 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. Topics discussed in this section: • Classless Addressing • Network Address Translation (NAT)
Classful addressing, which is almost obsolete, is replaced with classless addressing.
1. Classless Addressing Classless Addressing handles address blocks rather than classful networks. An IP logical network is implemented over an address block.
Example of address block: The next figure 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. 1. The addresses are contiguous. 2. The number of addresses is a power of 2 (16 = 24 in this example). 3. The host id of the first address is 0. 4. The host id of the last address has all bit 1s.
Example: A block of 16 addresses granted to a small organization ☺ Which part is changing? ☺ How to represent the address block, i.e., the address of the address block?
In IPv4 addressing, a block of addresses can be defined as x.y.z.t /n in which x.y.z.t defines the first address and the /n defines the mask. The mask decides the size of an address block, which is 232-n. 205.16.37.32/28; Size: 24 = 16
The first address in the block can be found by setting the rightmost 32 − n bits to 0s. That is the result of BIT_AND with the mask.
Example: A block of addresses is granted to a small organization. The mask /28 is used in the address block. We know that one of the addresses is 205.16.37.39. What is the first address in the block? Find the last address for the block. Find the number of addresses in the block. 11001101 00010000 00100101 00100111 => 11001101 00010000 00100101 00100000 … 11001101 00010000 00100101 00101111
An example network configuration:for the block 205.16.37.32/28 All the addresses in an address block can be reached through one router. An example of routing entry in the rest of the Internet: 205.16.37.32 /28 xxx.xxx.xxx.xxx yyy Any address in the bock AND /28 becomes the first address. This query, Dest addr AND /28 == 205.16.37.32 ???, is used in IP packet forwarding in the intermediate routers
The first address in a block is normally not assigned to any device; it is used as the network addressthat represents the organization to the rest of the world. The last address is not assigned to any device; it is used as the broadcast address in the logical network represented by the network address.
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.
Subnetting and supernetting Subnetting using larger netmask: Subdivision of a network, i.e., address block Supernetting using smaller netmask: Aggregation of networks, i.e., address blocks
Configuration and addresses in a subnetted network 00110000 ~ 00111111 00000000 ~ 00011111 00100000 ~ 00101111 All addresses in the address block, 17.12.14.0/26, can be reached through this router. ... 00000000 ~ ... 00111111 bit patterns
00110000 ~ 00111111 00000000 ~ 00011111 00100000 ~ 00101111 All addresses in the address block, 17.12.14.0/26, can be reached through this router. ... 00000000 ~ ... 00111111 bit patterns
Exmaple:(very important) An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP needs to distribute these addresses to three groups of customers as follows: The first group has 64 customers; each needs 256 addresses. The second group has 128 customers; each needs 128 addresses. The third group has 128 customers; each needs 64 addresses. Design the sub-address blocks and find out how many addresses are still available after these allocations. 256 = 28 64 = 26 128 = 27 1st group: 64 x 256 => 214 2nd group: 128 x 128 => 214 3rd group: 128 x 64 => 213
190.100.0.0 /16 => 11000000 01100100 00000000 00000000 /16 1st group: 64 x 256 => the required size: 214 2nd group: 128 x 128 => the required size: 214 3rd group: 128 x 64 => the required size: 213 214 213 215 216
190.100.0.0 /16 => 11000000 01100100 00000000 00000000 /16 1st group: 64 x 256 => the required size: 214 2nd group: 128 x 128 => the required size: 214 3rd group: 128 x 64 => the required size: 213 190.100.64.0/18 190.100.128.0/19 190.100.0.0/18 190.100.128.0/17 190.100.0.0/17 190.100.0.0/16
11000000 01100100 00000000 00000000 /16 Group 1: For this group, each customer needs 256 addresses. This means that 8 (= log2256) bits are needed to define each host. The prefix length is then 32 − 8 = 24. The addresses are 64 x 256 => 214 ~ ~ ~ 11000000 01100100 00000000 00000000 /24 ~ 11000000 01100100 00111111 00000000 /24 190.100.0.0/18 for the subblock
11000000 01100100 00000000 00000000 /16 2nd group: 128 x 128 Group 2: For this group, each customer needs 128 addresses. This means that 7 (= log2128) bits are needed to define each host. The prefix length is then 32 − 7 = 25. The addresses are ~ ~ ~ 11000000 01100100 01000000 00000000 /25 ~ 11000000 01100100 01111111 10000000 /25 190.100.64.0/18 for the subblock
11000000 01100100 00000000 00000000 /16 Group 3: For this group, each customer needs 64 addresses. This means that 6 (= log264) bits are needed to each host. The prefix length is then 32 − 6 = 26. The addresses are ~ ~ ~ 11000000 01100100 10000000 00000000 /26 ~ 11000000 01100100 10011111 11000000 /26 190.100.128.0/19 for the subblock Number of granted addresses to the ISP: 65,536 Number of allocated addresses by the ISP: 40,960 ☺ Number of available addresses: 24,576 => ???
11000000 01100100 00000000 00000000 /16 • Allocated subblocks: • 190.100.0.0/18 11000000 01100100 00000000 00000000 • 190.100.64.0/18 11000000 01100100 01000000 00000000 • 190.100.128.0/19 11000000 01100100 10000000 00000000 • ☺ What are the remained subblocks? • 190.100.160.0/19 • 190.100.192.0/18
190.100.0.0/24 … 190.100.0.0/18 190.100.63.0/24 190.100.0.0/16 190.100.64.0/18 190.100.128.0/19
Supernettingor address aggregation • Between networks • Too many networks => difficulty for routing and forwarding • Routing: need to exchange much data => traffic overhead • Forwarding: big routing table size => slow decision process • Classless addressing • Base address (i.e., the first address in the address block) + netmask, i.e., network address • X.Y.36.0/22 represents the next four address blocks. • 110xxxxx yyyyyyyy 00100100 ........: X.Y.36.0/24 • 110xxxxx yyyyyyyy 00100101 ........: X.Y.37.0/24 • 110xxxxx yyyyyyyy 00100110 ........: X.Y.38.0/24 • 110xxxxx yyyyyyyy 00100111 ........: X.Y.39.0/24 • 11111111 11111111 11111100 00000000: /22 • BIT_AND operation with any one of the above four networks will produce the same result, i.e., the base network address 110xxxxx yyyyyyyy 00100100 00000000 • 24 – 22 = 2 => 4 address blocks can be aggregated into one entry. • One routing entry of destination X.Y.36/0/22 can be used in the routing table for the above four networks. • E.g., 192.24.44/22 192.24.44.0/24 198.162.22.254 eth0 192.24.45.0/24 198.162.22.254 eth0 => 192.24.44.0/22 198.162.22.254 eth0 192.24.46.0/24 198.162.22.254 eth0 192.24.47.0/24 198.162.22.254 eth0
In this section, we have studied address blocks. • Let's go to 3.3.3 'Deliver, and IP packet forwarding'. IP packet forwarding/delivering uses address blocks. • We will come back here later.
44 -> 00101100 45 -> 00101101 46 -> 00101110 47 -> 00101111 252 11111100 Example of routing and address aggregation 192.24.44.0/24 eth1: 198.162.22.254 eth0: 198.162.22.8 198.162.22.0/24 R1 R2 192.24.45.0/24 ☺ Routing table at R1 for the 4 networks? 192.24.46.0/24 192.24.47.0/24 /22 -> 11111111 11111111 11111100 192.24.45.7 & 255.255.252.0 -> 192.24.44.0
2. NAT(Network Address Translation) • How to use private IP addresses: • ☺ Do we really have to use public IP addresses for home computers? • Accessibility to the public network from a private network • Called Internet sharing on Windows system • Called IP masquerading on Linux system
NAT(Network Address Translation) • Several variants • Address translation • Port address translation • Reverse address translation • ... • Natural for firewalling • Load sharing with port/address redirection • But end-to-end inconsistency; not fit to IPsec (IP Security) ☺ Private address?
Address blocks for private networks 127.0.0.0/8 for localhost ☺ Can you give the addresses of the above address blocks? 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
An Example of ISP and NAT Many computers on the left share 1000 addresses. Supported by NAT
☺ Can the packet arrive at the destination? Yes! ☺ How? ☺ Can the response message come back to the source? No! ☺ Why? 172.18.0.0/16 208.38.45.135 SA: 172.18.3.1 DA: 208.38.45.135
Basic idea of NAT NAT changes the source address for outgoing traffic and the destination address for incoming traffic. It has a private address 172.18.3.30 that is the default gateway of all other internal computers, and a public address 200.24.5.8 Destination 208.38.45.135 ☺ Destination address? ☺ Source address? Default router Cannot access directly. ☺ Why? 208.38.45.135 Source 208.38.45.135 ☺ What if several computes in the private network wants to communicate with computers outside at the same time?
Address translation NAT Default router ☺ What if only one public address is available? It keeps a pool of public addresses routable to the NAT gateway from outside.
This triple is unique in NAT for a pair of private address and port address Port translation NAT translation table 172.18.3.1 2345;80 | 172.18.3.1;25.8.3.2 1400;80 | 200.24.5.8;25.8.3.2 NAT 25.8.3.2 172.18.3.1;25.8.3.2 | 2345;80 200.24.5.8 200.24.5.8;25.8.3.2 | 1400;80 172.18.3.2 It has one public IP address.