Saturday 15 February 2014

networking - Calculating the distance to the next available IP address -


Assume I want to give IPv6 address to people from 2001: 0db8 :: / 32 range. Most are given out sequentially but some non sequential, this DB table shows which addresses have already been assigned.

  + ---------------------------- ----------- - + | Address + ----------------------------------------- + | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 0001 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 0002 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 0003 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 000 9. | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0F00: 0001 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0F00: 0002 | + ----------------------------------------- +   

Note that this is very low - the first 3 is taken, then there are 5 available addresses until the next available, then the interval of several million addresses before another one is done.

Do I want to assign users the next available address , which starts with the beginning of the subnet, in this case it will be easy to start at the beginning, it shows that 2001: There is no record for 0 DB 8 :: 4, and use one, but eventually the next available address can be thousands or even millions away from the start of the subnet. Running a time at an address in the database would be a bad idea.

I thought that to add another area to the table so that each address indicates how many available addresses are there and list in the next:

  + - ----------------------------------- ---- + ---------- ---------- + | Address Steps to the next size. + ----------------------------------------- + ------- ------------- + | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 0001 | 1 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 0002 | 1 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 0003 | 6 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0000: 000 9. 15728632 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0F00: 0001 | 2 | | 2001: 0dB 8: 0000: 0000: 0000: 0000: 0F00: 0003 | | + ----------------------------------------- + ------- ------------- +   

But I'm not sure if it helps me if an IP address is assigned somewhere between a rare section I still have to calculate how many steps are taken from that address at the next address, and then go back to the address given in the closet before the new one and fix its "next step in the next steps" but still slow process Sounds like

Is there a better way to do this?

It is capable of resolving your view with a little power. I am convinced that You want to fill the unused interval, because that's because you have an existing low population database that you want to use better.

Place your original table, but store it separately say a next_address field (in a settings table). When you first deploy your codes, then start with next_address with 2001: db8 :: 1 .

: Settings.set ('next_address', IPv6 ('2001: db8:: 1')) def get_next_address (): next = Settings.get ('next_address') # Check for already filled rows - Database. Loop breaks down when searching for intervals between ooXists ({'address': next}): next + 1 settings.set ('next_address', next + 1) return next get_next_address () # 2001: db8 :: 4 get_next_address () # 2001: db8 :: 5 get_next_address () # 2001: db8 :: 6 # ... get_next_address () # 2001: db8 :: f00: 0 get_next_address () # 2001: db8 :: f00: 2 get_n Ext_address () # 2001: db8 :: f00: 4 get_next_address () # 2001: db8 :: f00: 5

No comments:

Post a Comment