i trying fetch nodes connected router , try control bandwidth of router
int depth = 10; //where depth range of ip address int subdepth = 255; // subdepth subnet mask of network int timeout = 500; // timeout maximum wait host device string ip = inetaddress.getlocalhost().tostring().split("/")[1]; string tmp = ip.substring(0, ip.lastindexof(".", ip.lastindexof(".") - 1)) + "."; arraylist<inetaddress> lanmachines = new arraylist<>(); (int j = 1; j < depth; j++) { (int = 1; < subdepth; i++) { inetaddress = inetaddress.getbyname(tmp + j + "." + i); if (a.isreachable(timeout)) lanmachines.add(a); } } after getting details need control bandwidth of nodes..
no machine added because of this:
for (int j = 1; j < depth; j++) { and
int depth=1; at first case 1<1 false , cycle body won't executed, declare cycle condition folows:
for (int j = 0; j < depth; j++) { edit
your ip address prefix 127.0.xxx.xxx, should ask user ip adress space 192.168.xxx.xxx:
int depth = 1; //where depth range of ip address int subdepth = 255; // subdepth subnet mask of network int timeout = 500; // timeout maximum wait host device /* * user input better * there exists way lan ip, used * localhost address 127.0.0.1 */ string ip = fromuser; string tmp = ip.substring(0, ip.lastindexof(".", ip.lastindexof(".") - 1)) + "."; arraylist<inetaddress> lanmachines = new arraylist<>(); (int j = 0; j < depth; j++) { (int = 1; < subdepth; i++) { inetaddress = inetaddress.getbyname(tmp + j + "." + i); system.out.println(tmp + j + "." + i); if (a.isreachable(timeout)) lanmachines.add(a); } } for(inetaddress ina: lanmachines){ system.out.println("found: "+ina.tostring()); }
Comments
Post a Comment