pittmesh / ip-calculator

A browser-based calculator for determining PittMesh IP addresses
http://www.pittmesh.net/ipcalc
1 stars 0 forks source link

Collisions #25

Open jasonkhanlar opened 8 years ago

jasonkhanlar commented 8 years ago

With written example provided by Protagonistics:

Mesh: 100.64.65.66 Ethermesh: 100.66.65.54

and

Mesh: 100.64.65.170 Ethermesh: 100.170.65.64 (which should convert to 100.106.65.64 to fit in 100.64-127.x.x range)

there are collisions if 2nd octect == 4th octet, example: Mesh: 100.64.65.64 Ethermesh: 100.64.65.64

To avoid such collisions, ensure that 4th octet never equals (after adjusting to fit in 64-127 range) 2nd octet.

Cut 2nd octet in half. Rather than 64-127, split into 64-95 and 96-127, and ensure that 2nd octet always is within one range, and 4th octet is within the other range.

For example, 2nd octet will always be 96-127 and 4th octet will always be 0-31, 64-95, 128-159, 192-223 and will never be 32-63, 96-127, 160-191, 224-255 (because those when adjusted to fit within 64-127 range will collide with 2nd octet when reversing 2nd/3rd/4th octets from mesh to 4th/3rd/2nd octets for ethermesh)

jasonkhanlar commented 8 years ago

https://github.com/pittmesh/ip-calculator/pull/26