Jumat, 06 Mei 2011

subnetting calculator buatan sendiri

silahkan compile source berikut

#include

using namespace std;
int sum_subnet(int x);
int sum_host(int y);
int avail(int z);
int main()
{
    int cidr, netw = 0;
    for(;;){
    cout<<"subnet formulas"<
        <<"this software will calculate"<
        <<"value of CIDR from your ip"<
    cout<<"enter value of CIDR : ";
    cin >> cidr;
    if (cidr>=24 && cidr<=32)                                       //limiting input
    break;
    else cout<<"sorry, you CIDR is other from C class"<<
    }
    cout<<<"sum subnet "<<<
    cout<<"sum host "<<<
        <<"available IP : "<<
    for (;;){
    cout<<"network = x.x.x."<
        <<" hosts = x.x.x."<<<" - x.x.x."<
        <<" broadcast = x.x.x."<
        <
    netw = netw + avail(cidr);
    if (netw+avail(cidr)-1 > 255){                                 //limiting ouput to 255
    break;
    }
    }
    return 0;
}
int sum_subnet(int x){
    int a = 2;
    int xy = x - 24;
    for (int counter = 1;counter
        a = a * 2;
        }
    return a;
    }
int sum_host(int y){
    int a = 2;
    int xy = 32 -y;
    for (int counter = 1;counter < xy;counter++){
        a = a * 2;
        }
    return a - 2;
    }
int avail(int z){
    int sum = z - 24;
    int temp;
    switch(sum){
        case 1 : temp = 128;
        break;
        case 2 : temp = 128 + 64;
        break;
        case 3 : temp = 128 + 64 + 32;
        break;
        case 4 : temp = 128 + 64 + 32 + 16;
        break;
        case 5 : temp = 128 + 64 + 32 + 16 + 8;
        break;
        case 6 : temp = 128 + 64 + 32 + 16 + 8 + 4;
        break;
        case 7 : temp = 128 + 64 + 32 + 16 + 8 + 4 + 2;
        break;
        case 8 : temp = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1;
        break;
        }
    int min = 256 - temp;
    return min;
    }


kalau masih ada bug, bisa dilaporkan di kotak komentar. semoga bermanfaat

Posting Komentar

Give Ur eXPerience about this eXPerience...

Ads