Comments (17)
Hi @eakteam Can you try increasing the timeout of the scan to see if more devices are discovered? Maybe 5 - 10 seconds is enough
SubnetDevices.fromLocalAddress().setTimeoutMillis(10000).findDevices(new SubnetDevices.OnSubnetDeviceFound() {
@Override
public void onDeviceFound(Device device) {
// Stub: Found subnet device
}
@Override
public void onFinished(ArrayList<Device> devicesFound) {
// Stub: Finished scanning
}
});
from androidnetworktools.
Hello , i just tried to set the timeout to 10000 ms , it's the same thing. Anyway i don't think that the problem stay in the ping responding timeout. In fact your implementation work really good for devices that accept ICMP ping request , but there are some other types of devices that they don't allow that and returns "timeout" .... to try to explain well this is my implementation of LAN Scanner in my App , i wish to replace with yours.
boolean filloi;
Process p = null;
try {
p = Runtime.getRuntime().exec("ping " + "-v " + "-c " + 1 + " " + testIp);
filloi = true;
} catch (IOException e) {
filloi = false;
e.printStackTrace();
}
String readData;
if (filloi) {
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader reader1 = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while ((readData = reader.readLine()) != null) {
Log.d("PINGIMI", readData);
totalReadData.add(readData);
if (!readData.startsWith("---")) {
// Pergjigje ping
Pattern M = Pattern.compile("(^[\\d]+) bytes from ([^:]+): icmp_seq=([^ ]+) ttl=([\\d]+) time=([^ ]+) ms");
Matcher MM = M.matcher(readData);
// Statistikat e pingimit
Pattern M3 = Pattern.compile("(^[\\d]+) packets transmitted, ([^ ]+) received, ([\\d]+)% packet loss, time ([^ ]+)ms");
Matcher MM3 = M3.matcher(readData);
// TimeOut
Pattern M6 = Pattern.compile("^no answer yet for icmp_seq=([\\d]+)");
Matcher MM6 = M6.matcher(readData);
if (MM.find()) // Ping OK
{
// HERE I ADD DEVICES THAT RESPONDS TO PING
}
else if (MM6.find()) // Timeout
{
// HERE ADD DEVICES TOO THAT RETURN TIMEOUT BUT THEY ARE ONLINE IN THAT LAN
}
from androidnetworktools.
Ok, so to confirm you have some devices that don't respond to ping and they cause the native ping binary to output "no answer yet for icmp_seq="? I don't think it'd be a good idea to return a positive match in this case as this could also be the same output for a device that don't exist.
from androidnetworktools.
Yes , the problem is that you are just checking the negative or positive results of ping binary and than calculate the results. In fact you should parse and read the results before and after that calculate if they should be added or not as Online Devices. So "no answer yet for icmp_seq=" may returned from some devices which they have disabled ping feature to reply back maybe because of protecting from DDOS , but anyway those devices are in the network and working. Sorry for my low English , hope to understand what im trying to say :) :D :)
from androidnetworktools.
Ok, I understand. Can you send the full output of ping to one of these devices?
from androidnetworktools.
THIS ARE THE COMMON TERMINAL OUTPUT OF PING BINARY :
// Ping
Pattern M = Pattern.compile("(^[\\d]+) bytes from ([^:]+): icmp_seq=([^ ]+) ttl=([\\d]+) time=([^ ]+) ms");
// Time Stats
Pattern M1 = Pattern.compile("^rtt [^0-9]*([\\d][^/]+)/([^/]+)/([^/]+)/([^ ]+) ms$");
// Host Unreachable
Pattern M2 = Pattern.compile("\\bFrom ([^:]+): icmp_seq=([^ ]+) (Destination Host Unreachable)");
// Ping Stats
Pattern M3 = Pattern.compile("(^[\\d]+) packets transmitted, ([^ ]+) received, ([\\d]+)% packet loss, time ([^ ]+)ms");
// Error Stats
Pattern M4 = Pattern.compile("(^[\\d]+) packets transmitted, ([^ ]+) received, [+]([^ ]+) errors, ([\\d]+)% packet loss, time ([^ ]+)ms");
// Network Unreachable
Pattern M5 = Pattern.compile("^[ping:]+ [sendmg:]+ ([Network isunachbl]+)");
// TimeOut
Pattern M6 = Pattern.compile("^no answer yet for icmp_seq=([\\d]+)");
//TTL Expired
Pattern M7 = Pattern.compile("\\bFrom ([^:]+): icmp_seq=([^ ]+) (Time to live exceeded)");
When the device is there but i doesn't allow ping it send to the console Pattern M6 when it is not there maybe it returns Unreachable or Nothing just end the execution
from androidnetworktools.
Can I see the output of ping directly? like this
[email protected] ~ $ ping -v -i 1 192.168.0.3
PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
64 bytes from 192.168.0.3: icmp_req=1 ttl=64 time=0.233 ms
from androidnetworktools.
NORMAL DEVICE PING :
shell@hct6580_weg_c_m:/ $ ping -v -c 1 192.168.88.1
PING 192.168.88.1 (192.168.88.1) 56(84) bytes of data.
64 bytes from 192.168.88.1: icmp_seq=1 ttl=64 time=157 ms
--- 192.168.88.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 157.430/157.430/157.430/0.000 ms
DEVICE DONT EXIST ON NETWORK :
shell@hct6580_weg_c_m:/ $ ping -v -c 1 192.168.88.88
PING 192.168.88.88 (192.168.88.88) 56(84) bytes of data.
From 192.168.88.152: icmp_seq=1 Destination Host Unreachable
--- 192.168.88.88 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
DEVICE EXIST BUT IT DON'T ACCEPT PING ( This is not found in ur lib)
1|shell@hct6580_weg_c_m:/ $ ping -v -c 1 192.168.88.21
PING 192.168.88.21 (192.168.88.21) 56(84) bytes of data.
--- 192.168.88.21 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
Here it returns nothing as message from ping binary... But they may return "no answer yet from icmp_seq" if you increase the ping count to 2 : "-c 2" . Those type of devices should be marked as Online in the LAN.
from androidnetworktools.
@eakteam @stealthcopter are you able do some workaround for this?
from androidnetworktools.
I have solved it in my app by self writing all the ping class...
The workaround is :
DEVICE EXIST BUT IT DON'T ACCEPT PING ( This is not found in ur lib)
1|shell@hct6580_weg_c_m:/ $ ping -v -c 1 192.168.88.21
PING 192.168.88.21 (192.168.88.21) 56(84) bytes of data.
--- 192.168.88.21 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
Here it returns nothing as message from ping binary... But they may return "no answer yet from icmp_seq" if you increase the ping count to 2 : "-c 2" . Those type of devices should be marked as Online in the LAN.
from androidnetworktools.
@eakteam can you fork the library and show the fix you made? I too struggling with this thing. Not all devices found on the network :(
from androidnetworktools.
Hi @osfunapps , this would be great to help but i have solved it with my own implementation. I am not using this lib implementation. But i can say that the issue is happening because of native ping results. So there is a case when devices doesn't reply to ping request but in fact they are active on LAN. So just try to "play" with the ping results when executed by Android process. You may understand the issue.
Anyway, i will try to post the solution here later because i can't for the moment.
from androidnetworktools.
The library has the issue not to find all the devices in LAN as @eakteam stated,
Is there any update or workaround, @stealthcopter , @eakteam ?
from androidnetworktools.
@BrentPollyn , i have implemented in my app, custom subnet scanner. This library needs much changes to full support it and being compatible with Android 10+ since they disabled access to sys/arp too
from androidnetworktools.
Oh, great! Can I get your help to have a creative subnet scanner class in my app?
from androidnetworktools.
@BrentPollyn , i am sorry but my source code cannot be shared. The app which contains it is : https://play.google.com/store/apps/details?id=com.eakteam.networkmanager.pro
Try to implement it yourself it is not so much to write.
I suggest you
- First make an ip neightbour scan and cache all IP in range
- Make a ICMP request to all IPs in range
- Who responds get the MAC address, make a request to external API to find the vendor from the MAC, and display it together with their IP address.
Sorry for my nit good English, hope to be understandable
from androidnetworktools.
So it could not be done by this library..
from androidnetworktools.
Related Issues (20)
- Android 10 SubnetDevices.fromLocalAddress().findDevices() Throw exception HOT 3
- Sub
- Me
- Em
- markdown HOT 1
- put a fork intoit
- stick tags on pathetic oracle electrons that snap to many rips of un quadra complicated hexi decimaleted cuntish green pin
- A
- Ip
- https://chromium.googlesource.com/chromium/src/+/master/docs/security/faq.md HOT 1
- 1010
- Y
- Tools
- Data
- NullPointerException when scanning subnet devices for Android Tv
- ip neigh command does not work after upgrading targetSDK to 30 HOT 3
- Duno
- Ping 0.00 ms HOT 2
- Same port ip list HOT 1
- Subnet device scan doesn't work on Samsung
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidnetworktools.