IP Mask Operations
Download
Report
Transcript IP Mask Operations
Mask Operations
• Masks were introduced in Chapter 3
• IP addresses alone do not tell you the size of their
network or subnet parts
• Network Mask
– Has 1s in the network part
– Has 0s in the remaining bits
• Subnet Mask
– Has 1s in the network plus subnet parts
– Has 0s in the remaining bits
Mask Operations
• Based on Logical AND
– Both must be true for the result to be true
• Example
– 1010101010
– 1111100000
– 1010100000
Data
Mask
Result
Mask Operations
• Based on Logical AND
– If mask bit is 1, get back original data
– If mask bit is 0, bet back zero
• Example
– 1010101010
– 1111100000
– 1010100000
Data
Mask
Result
Mask Operations
• IP packet arrives at a router
– Router sees destination IP address
– 11111111 01000000 10101010 00000000
• Compares to each router forwarding table row
– Address Part in First Entry
– 11111111 01000000 00000000 00000000
– Mask in First Entry
– 11111111 11100000 00000000 00000000
Mask Operations
• Mask the IP destination Address
– 11111111 01000000 10101010 00000000 (IP address)
– 11111111 11100000 00000000 00000000 (mask)
– 11111111 01000000 00000000 00000000 (result)
• Compare Result with First Entry
Address part
– 11111111 01000000 00000000 00000000 (address part)
– 11111111 01000000 00000000 00000000 (result)
• The Entry is a Match!
Mask Operations
• Recap
– Read destination IP address of incoming IP
packet
– For each entry in the router forwarding table
•
•
•
•
Read the mask (prefix)
Mask the incoming IP address
Compare the result with the entry’s IP address part
Do they match or not?
Mask Operations
• Simple for Computers
– Computers have circuitry to AND to numbers
– Computers have circuitry to COMPARE two
numbers to see if they are equal or not
– Very computer-friendly, so used on routers
• Difficult for people, unfortunately