Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if system is connected to ad hoc or infrastructure wifi?

I am working on an application that checks, before enabling a download, that the connection is reliable (basically the connection should be an infrastructure wifi and not data pack) But in case the user is either

  1. using an ad hoc network, or
  2. mobile device's internet connection as WAP

and then connecting and starting the download on desktop, it is still undesired. Is there a way to detect if some wifi connection is actually not from ad hoc or using phone's WAP?

like image 642
notrai Avatar asked Jan 18 '16 18:01

notrai


People also ask

What is the difference between infrastructure based Wi-Fi and adhoc Wi-Fi networks?

In infrastructure mode, all devices on a wireless network communicate with each other through an access point (wireless router). In ad hoc mode, a computer with a wireless network adapter communicates directly with a printer equipped with a wireless print server.

Is Wi-Fi a Adhoc Network?

In fact, Wi-Fi access points work in either ad hoc or infrastructure mode. Typically, Wi-Fi networks in infrastructure mode are created and managed using equipment such as Wi-Fi routers, wireless access points (WAPs) and wireless controllers.

Which is example of wireless ad hoc network?

A typical example of an ad-hoc network is connecting two or more laptops (or other supported devices) to each other directly without any central access point, either wirelessly or using a cable. When to use an ad-hoc network: If you want to quickly set up a peer-to-peer (P2P) network between two devices.


Video Answer


1 Answers

You can detect...

  1. ...the Ad-Hoc Network by checking if you actually can access a server on the internet - usually, Ad-Hoc does not include fully connectivity so if you have network but no internet access, a download won't work
  2. ...the usage of a phone access point by measuring the round-trip time of a request - they are usually quite high on mobile broadband.

    long start = System.nanoTime();
    HttpGet requestForTest = new HttpGet("http://m.google.com");
    try {
        new DefaultHttpClient().execute(requestForTest); // can last...
    } 
    catch (Exception e) {
    }
    long rtt = System.nanoTime() - start;
    // ... evaluate the rtt
    

    This table may be relevant for the evaluation (source)

    Generation | Data rate      | Latency
    2G         | 100–400 Kbit/s | 300–1000 ms
    3G         | 0.5–5 Mbit/s   | 100–500 ms
    4G         | 1–50 Mbit/s    | < 100 ms
    

Apart from those two options: why do you specifically ban Ad-Hoc or mobile broadband? Shouldn't you either

  • ban nothing and let the user decide if they want to wait for ages

or

  • ban ALL slow connections, i.e. monitoring the transfer rate for a couple of seconds and cancel the download automatically if it is too small
like image 98
PhilLab Avatar answered Oct 04 '22 01:10

PhilLab