Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    function - IP plan

    Hi, I need to make an IP plan
    for explanation gives an example:

    I have as IP 192.168.0.0

    user completes it wants in any network guests .. I can adjust it to the nearest power of 2 and there is my example:
    8,16,32,64,128,256,512,1024,2048 and so on ..

    Now I can sort the values ​​from largest to smallest
    for example: 2048,64,32

    I have these values ​​saved in ARRAY and now I need to create a FUNCTION that will do this
    The first value in the array is 2048 it means that
    network address is:
    192.168.0.0 - 192.168.7.255

    the next value in the array is 64
    network address is:
    192.168.8.0 - 192.168.8.63

    the next value in a field of 32
    network address is:
    192.168.8.64 - 192.168.8.95

    I need to calculate:
    1. Network address
    2. Broadcast

    Anyone knows what function create this calculated? Thank you very much for any assistance.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,633
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Not sure what exactly it is you are trying to do but 192.168.0.0 identifies a block of 254 IP addresses and is not a usable address. Usable addresses have a value between 1 and 254 in the last position. 192.168.0.255 means broadcast to those 254 addresses.

    The mask identifies whether two addresses are on the same network. 255.255.255.0 means that the addresses must have the exact same values in the first three positions to be on the same network.

    Of course this is all completely changed in IPv6 which is currently in replacing IPv4 since the IPv4 addresses ran out in 2011.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •