web - Detect user connection 3g,4g,wifi or lite by using php -



web - Detect user connection 3g,4g,wifi or lite by using php -

is there way observe connection of user using php script. want observe 3g,wifi,4g , lite. want observe users come from. have solution in javascript want in php reasons.

you can tell difference between wifi , non-wifi, , can't tell difference.

you can never tell difference between 3g/4g/lte php.

assumptions , terminology

i assuming smartphone connecting http server via browser, , server uses php handle request. if not case, please clarify question.

terminology: utilize word "isp" refer companies provide net service not phone carriers.

what info server get?

when device connects php server, tells server info itself, server can know device's ip address, user agent, etc.

the problem

the problem browser "doesn't care" connection on, , has no effect on info browser sends server. if browser on 3g/4g/lte, send exact same info have sent if on wifi.

semi "proof": http protocol transfers info device http server ignorant of underlying network stack.

how identify connection, then?

the difference between wifi/non-wifi is: ip address.

isp's have big list of reserved ip addresses. if can observe ip address belongs particular isp, must wifi connection.

similarly, phone carriers have big list of reserved ip addresses. if can observe ip address belongs particular phone carrier, must 3g/4g/lte connection!

doing in practice

we need somehow correlate each ip address isp/carrier, 1 way have huge database of isp's / carriers , respective reserved ip's. in practice, simple whois lookup can reveal source.

for example, whois lookup random ip: 109.168.97.31 revealed among other things:

descr: 013 netvision

netvision israeli net provider. therefore, if phone connection (you can check using user-agent), must wifi connection!

doing in php

i have little knowledge of php, perhaps improve knowledge improve edit section. code goes this:

$company_name = geoip_isp_by_name($_server['remote_addr']); $this_is_a_wifi_connection = is_this_wifi($company_name);

the function is_this_wifi should lookup company name in database , decide whether phone carrier or isp company.

problems

you still need have list of isp's / carriers in order compare whois lookups them.

some people utilize vpn's / anonymity networks, ip address can lie.

some companies both isp's , carriers, never know whether or not it's wifi connection in such case.

php web wifi detection 4g

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -