Add a subnet calculator function to the kit

Add a subnet calculator function to the kit

Postby troysorzano » Sun Sep 22, 2013 2:19 pm

I added a subnet calculator fuction to the stock 1.1 sketch. It allows you to caclualte the first usable host IP and the last usable host IP from a known IP and subnet.

If you want to add other funcitons to the calculator take a look at my sketch. I commented all my code so just seach for "subnet". I am sure it will save you hours of serial.print() reverse engineering.

There are three main blocks of logic when adding a new function to the caclulator sketch.
1. Keypress : Catch new functions keypress. I used a double plus "++" to enable the subnet calc functionality.
2. Calculate the result when equals "=" is pressed
3. Display: the result. I modified it to use leading zeros instead of blanks when displaying subnet results.

Why would you need a subnet calculator? If you work at an ISP or manage a large volume of network devices you need to know what static IP's are owned by the customer. The concept is: If I know one of the customers IP's and I know the customers subnet mask. Using this subnet calculator we can find the usable range of IP's that the customer owns. Most of my customers own 6 usable static IPs. They call and say they are adding a new webserver and they want to use one of their free IPs. But they don't know which of the 6 they own are free. I ask them for a public IP by having them check www.ipchicken.com. I take that IP and the subnet 248 (99%of my customers have 6 IPs which is a 248 subnet or a /29 CIDR). My calcualtor
will spit out the first usable and the last usable IP. So we can see if any of them are free to be used by their new webserver.

You can find the subnet calculator sketch here.
http://abraindump.com/blog/2013/09/04/s ... alculator/

Troy
troysorzano
 
Posts: 1
Joined: Sat Aug 24, 2013 7:42 pm

Return to Calculator Kit



Who is online

Users browsing this forum: No registered users and 1 guest

cron