IP Address Prefixes - PowerPoint PPT Presentation

About This Presentation
Title:

IP Address Prefixes

Description:

IP Address Prefixes ACM programming practice problem. Ron Smith CIDR Notation Block: 190.101.118.99/22 IP Address: 190.101.118.99 Network Prefix: 22 Represents ip ... – PowerPoint PPT presentation

Number of Views:155
Avg rating:3.0/5.0
Slides: 10
Provided by: RonS193
Category:
Tags: address | prefixes

less

Transcript and Presenter's Notes

Title: IP Address Prefixes


1
IP Address Prefixes
  • ACM programming practice problem.
  • Ron Smith

2
CIDR Notation
  • Block 190.101.118.99/22
  • IP Address 190.101.118.99
  • Network Prefix 22
  • Represents ip addresses with prefixes
  • 190.101.116.
  • 190.101.117.
  • 190.101.118.
  • 190.101.119.

3
Our Notation
  • ip 190.101.118.99 n 22
  • 190.101 . 116 .
  • 190.101 . 117 .
  • 190.101 . 118 .
  • 190.101 . 119 .

4
Critical Byte
  • Given
  • ip IP network (type list)
  • n network prefix (type int)
  • Compute
  • cByte n/8 integer division
  • common ip0cByte
  • crit int(ipcByte)

5
Splitting the critical byte
  • Given
  • Network prefix n 22
  • Critical byte crit 118 (01110110)2
  • 011101 10

fixed bits n 8
variable bits 8 - n 8
6
Finding total, start
  • Given
  • Critical bit crit 118
  • Variable bits vbits 2
  • Find
  • total 2vbits
  • start crit crit total

7
How to treat ip as an array
  • def getitem(s,n,delim'.')
  • s s.split(delim)
  • s sn
  • if type(s) list
  • s '.'.join(s)
  • return s

8
How to handle dots.
  • Dot after common
  • preDot (cByte gt 0 and cBtye lt 4)'.'
  • If cByte 0, common is empty No '.'
  • If cByte 4, everything common No '.'
  • Final dot
  • postDot (cByte lt 4)'.'

9
Ready to Code!
Write a Comment
User Comments (0)
About PowerShow.com