Copyright © 2017 the Contributors to the Network Information API Specification, published by the Web Incubator Community Group under the W3C Community Contributor License Agreement (CLA) . A human-readable summary is available.
The Network Information API enables web applications to access information about the network connection in use by the device.
This specification was published by the Web Incubator Community Group . It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups .
This document attempts to address the requirements from the Review of Apps that Use Network Information . Those are:
This section is non-normative.
For examples of the kinds of applications one can build with this API, see the Review of Apps that Use Network Information .
// Get the connection type.
var type = navigator.connection.type;
// Get an upper bound on the downlink speed of the first network hop
var max = navigator.connection.downlinkMax;
function changeHandler(e) {
// Handle change to connection here.
}
// Register for event changes.
navigator.connection.onchange = changeHandler;
// Alternatively.
navigator.connection.addEventListener('change', changeHandler);
For
clarity,
a
megabit
is
1,000,000
bits,
and
megabits
per
second
is
equivalent
to
transferring:
This section defines the connection types and the underlying connection technology that the user agent is using (if any):
bluetooth
cellular
ethernet
none
navigator.onLine
===
false
in
HTML.
mixed
other
unknown
wifi
wimax
The
connection
types
are
represented
in
this
API
by
the
ConnectionType
enum.
ConnectionType
enum
enum ConnectionType {
"bluetooth",
"cellular",
"ethernet",
"mixed",
"none",
"other",
"unknown",
"wifi",
"wimax"
};
This section defines the effective connection types (ECT):
| ECT | Minimum RTT (ms) | Maximum downlink (Kbps) | Explanation |
|---|---|---|---|
slow-2g
|
1900 | 50 | The network is suited for small transfers only such as text-only pages. |
2g
|
1300 | 70 | The network is suited for transfers of small images. |
3g
|
200 | 700 | The network is suited for transfers of large assets such as high resolution images, audio, and SD video. |
4g
|
0 | ∞ | The network is suited for HD video, real-time video, etc. |
The above round-trip and bandwidth values are based on real user measurement observations:
slow-2g
is
the
66.6th
percentile
of
2G
observations
2g
is
the
50th
percentile
of
2G
observations
3g
is
the
50th
percentile
of
3G
observations
The absolute values provided above are based on real user measurement on Chrome on Android, as captured in April 2017. The user agent MAY update these values in the future to reflect changes in the measurement data.
The
effective
connection
types
are
represented
in
this
API
by
the
EffectiveConnectionType
enum.
EffectiveConnectionType
enum
enum EffectiveConnectionType {
"2g",
"3g",
"4g",
"slow-2g"
};
NavigatorNetworkInformation
interface
The
NavigatorNetworkInformation
interface
exposes
access
to
interface
by
extending
the
NetworkInformation
Navigator
and
WorkerNavigator
interface.
NavigatorimplementsNavigatorNetworkInformation;WorkerNavigatorimplementsNavigatorNetworkInformation;
connection
attribute
The
connection
attribute,
when
getting,
returns
an
object
that
implements
the
NetworkInformation
interface.
NetworkInformation
interface
The
NetworkInformation
interface
provides
a
means
to
access
information
about
the
network
connection
the
user
agent
is
currently
using.
The
EventTarget
is
defined
in
[
DOM
].
[Exposed=(Window,Worker)] interfaceNetworkInformation:EventTarget{ readonly attributeConnectionTypetype; readonly attributeEffectiveConnectionTypeeffectiveType; readonly attribute MegabitdownlinkMax; readonly attribute Megabitdownlink; readonly attribute Millisecondrtt; attribute EventHandleronchange; }; typedef unrestricted double Megabit; typedef unsigned long long Millisecond;
type
attribute
The
type
attribute,
when
getting,
returns
the
connection
type
that
the
user
agent
is
using.
effectiveType
attribute
The
effectiveType
attribute,
when
getting,
returns
the
effective
connection
type
that
is
determined
using
a
combination
of
recently
observed
round
trip
times
rtt
and
downlink
values.
bandwidth.
downlinkMax
attribute
The
downlinkMax
attribute
represents
an
upper
bound
on
the
downlink
speed
of
the
first
network
hop
.
The
reported
value
is
in
megabits
per
second
and
determined
by
the
properties
of
the
underlying
connection
technology
.
The user agent has no knowledge of the total number or the performance characteristics of the various network hops required to fulfill a particular request; different requests may follow different routes and have different performance characteristics. The reported upper bound on the downlink speed of the first network hop value is determined by the properties of the underlying connection technology of the first network hop. The end-to-end performance of any request cannot exceed this value, but it is also not a guarantee of performance and may be significantly worse.
onchange
attribute
The
onchange
event
handler
attribute
handles
"change"
events
fired
during
the
steps
to
update
the
connection
values
.
downlink
attribute
The
downlink
attribute
represents
the
effective
bandwidth
estimate
in
megabits
per
second
based
on
recently
observed
throughput
on
the
client,
,
rounded
to
nearest
multiple
of
25
kilobits
per
second.
second,
and
is
based
on
recently
observed
transport-layer
throughput
across
recently
active
connections.
In
absence
of
recent
bandwidth
measurement
data,
the
attribute
value
is
determined
by
the
properties
of
the
underlying
connection
technology
.
rtt
attribute
The
rtt
attribute
represents
the
effective
round-trip
time
estimate
in
milliseconds
based
on
recently
observed
round-trip
times
on
the
client,
,
rounded
to
nearest
multiple
of
25
milliseconds.
milliseconds,
and
is
based
on
recently
observed
transport-layer
RTT
measurements
across
recently
active
connections.
In
absence
of
recent
RTT
measurement
data,
the
attribute
value
is
determined
by
the
properties
of
the
underlying
connection
technology
.
The relationship between an underlying connection technology and its upper bound on the downlink speed of the first network hop is determined by the available network interfaces that may be used to fulfill new network requests.
The downlinkMax for an available interface is determined via the standardized, or generally accepted, maximum download data rate captured in the table of maximum downlink speeds . Where possible, this value may be refined to report a more accurate upper bound based on current properties of the interface - e.g. signal strength, modulation algorithm, and other "network weather" variables.
The upper bound on the downlink speed of the first network hop is determined by the rules described in handling changes to the underlying connection .
The
enumeration
of
available
network
interfaces
and
their
generation
and
version
is
not
directly
exposed
to
script.
Instead,
downlinkMax
exposes
a
single
value
in
megabits
per
second
that
accounts
for
all
available
interfaces
and
their
current
network
conditions.
| Connection type | Underlying connection technology | Generation or Version | Max downlink speed ( Mbit/s ) |
|---|---|---|---|
wimax
|
WiMAX 1 | rel 1 | 37 |
| WiMAX 1.5 | rel 1.5 | 141 | |
| WiMAX 2 | rel 2 | 365 | |
cellular
|
GSM | 2G | 0.01 |
| IDEN | 2G | 0.064 | |
| CDMA | 2G | 0.115 | |
| 1xRTT | 2.5G | 0.153 | |
| GPRS | 2.5G | 0.237 | |
| EDGE | 2.75G | 0.384 | |
| UMTS | 3G | 2 | |
| EVDO Rev 0 | 3.5G | 2.46 | |
| EVDO Rev A | 3.5G | 3.1 | |
| HSPA | 3.5G | 3.6 | |
| EVDO Rev B | 3.75G | 14.7 | |
| HSDPA | 3.75G | 14.3 | |
| HSUPA | 3.75G | 14.4 | |
| EHRPD | 3.9G | 21 | |
| HSPAP | 3.9G | 42 | |
| LTE | 4G | 100 | |
| LTE Advanced | 4G | 100 | |
bluetooth
|
1.2 | 1.2 | 1 |
| 2.1 + Enhanced Data Rate (EDR) | 2.1+EDR | 3 | |
| 3.0 + High Speed (HS) | 3.0+HS | 24 | |
| 4.0 + Bluetooth Low Energy (BLE) | 4.0+BLE | 1 | |
ethernet
|
Ethernet | 10 | 10 |
| Fast Ethernet | 100 | 100 | |
| Gigabit Ethernet | GigE | 1000 | |
| 10-gigabit Ethernet | 10 GigE | 10000 | |
wifi
|
b | 802.11b | 11 |
| g | 802.11g | 54 | |
| n | 802.11n | 600 | |
| ac | 802.11ac | 6933.3 | |
| ad | 802.11ad | 7000 | |
unknown
|
unknown | unknown | +Infinity |
none
|
none | none | 0 |
other
|
other | other | user agent specific. |
When
the
properties
of
the
underlying
connection
technology
change,
due
to
a
switch
to
a
different
connection
type
or
effective
connection
type
,
change
in
upper
bound
on
the
downlink
speed
of
the
first
network
hop
,
or
change
in
effective
downlink
or
rtt
estimates,
the
user
agent
MUST
run
the
steps
to
update
the
connection
values
:
downlink
and
rtt
values.
downlink
value
to
nearest
multiple
of
25
kilobits
per
second.
connection.downlink
,
then
set
new-dowlink
to
resulting
value.
Otherwise,
set
new-downlink
to
the
value
of
connection.downlink
.
rtt
value
to
nearest
multiple
of
25
milliseconds.
connection.rtt
,
then
set
new-rtt
to
resulting
value.
Otherwise,
set
new-rtt
to
the
value
of
connection.rtt
.
0
.
+Infinity
.
connection.downlinkMax
,
or
if
new-type
is
not
equal
to
the
value
of
connection.type
,
or
if
new-downlink
is
not
equal
to
the
value
of
connection.downlink
,
or
if
new-rtt
is
not
equal
to
the
value
of
connection.rtt
:
connection.downlinkMax
to
max-value
.
connection.type
to
new-type
.
connection.effectiveType
to
new-effective-type
.
connection.downlink
to
new-downlink
.
connection.rtt
to
new-rtt
.
change
at
the
NetworkInformation
object.
The Network Information API exposes information about the observed network bandwidth, latency and the first network hop between the user agent and the server; specifically, the type of connection and the upper bound of the downlink speed, as well as signals whenever this information changes. Such information may be used to:
However, above considerations are not new, and sufficiently motivated attackers may already obtain such information using other technologies:
onload
event)
of
any
network
fetch
on
the
client,
and
may
get
more
detailed
timing
data
about
the
same
fetch
via
the
Resource
Timing
API.
Further, by repeating one of the above strategies (e.g. via invoking periodic fetch or refresh of a resource; via periodic SSE or WebSocket messages; via periodic STUN requests, etc.), the attacker can observe changes over time in the performance characteristics of client's connection and IP address. Such data can then be used to refine the user fingerprint, infer users location (e.g. are they home, at work, or in transit), and extract various behavioral patterns.
The above list is not a complete overview. However, as the above examples illustrate, the attacks are possible both from the sender and the receiver:
Mitigating such attacks initiated from the client requires preventing the attacker from observing and initiating network requests - e.g., use HTTPS to prevent trivial content injection by malicious parties; disable JavaScript to prevent scripted resource fetch of any kind. Mitigating attacks from the sender is possible via the use of a VPN or an HTTP proxy - e.g. to hide the client's true IP address, to introduce additional latency, and so on.
As such, while the Network Information API makes it easier to obtain information about the first network hop, by avoiding the need to observe or make network requests, it does not expose anything that is not already available to a sufficiently-motivated attacker.
If the client wants to mitigate this class of attacks, they should disable JavaScript, monitor that all outbound requests are made to trusted origins, and make diligent use of anonymizing VPN/proxy services.
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words MAY and MUST are to be interpreted as described in [ RFC2119 ].
There is only one class of product that can claim conformance to this specification: a user agent .
This document reuses text from the [ HTML ] specification as permitted by the license of that specification.