Ask the Expert

Performing binary calculation on the IP address

I am developing a program in Visual Basic.NET for a class that I am taking and I would like to see if I can get some guidance. What I am doing is developing a program where I can take a class A,B, or C IP address and Subnet form that address. I will need to verify subnet masks, and develop the formula to Subnet. I am new to this and have reached a barrier here on this portion of the program. Any help would be greatly appreciated.
I'm not exactly sure what the goal of the application is, because I'm not sure what you mean by "formula to subnet." Well, I'm sure they want you to perform some binary calculation on the IP address. Your best bet is probably to use, and possibly extend, the System.Net.IPAddress class. Here's the related page in MSDN: http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemnetipaddressclasstopic.asp.

You can use the IPAddress.Parse() method to accept a standard x.x.x.x IP address format, and then use GetAddressBytes() to get the IP address' four bytes for binary processing.

This was first published in April 2004

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.