├── .pr-preview.json ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── downlink.json ├── examples └── example1.html ├── index.html └── w3c.json /.pr-preview.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_file": "index.html", 3 | "type": "respec" 4 | } 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Web Platform Incubator Community Group 2 | 3 | This repository is being used for work in the Web Platform Incubator Community Group, governed by the [W3C Community License 4 | Agreement (CLA)](http://www.w3.org/community/about/agreements/cla/). To contribute, you must join 5 | the CG. 6 | 7 | If you are not the sole contributor to a contribution (pull request), please identify all 8 | contributors in the pull request's body or in subsequent comments. 9 | 10 | To add a contributor (other than yourself, that's automatic), mark them one per line as follows: 11 | 12 | ``` 13 | +@github_username 14 | ``` 15 | 16 | If you added a contributor by mistake, you can remove them in a comment with: 17 | 18 | ``` 19 | -@github_username 20 | ``` 21 | 22 | If you are making a pull request on behalf of someone else but you had no part in designing the 23 | feature, you can remove yourself with the above syntax. 24 | 25 | ## Style guide 26 | The spec is written in markdown and generated with [ReSpec](http://dev.w3.org/2009/dap/ReSpec.js/documentation.html). 27 | 28 | When contributing text, just follow the conventions in the document. Please note that some GitHub flavored markdown won't work (e.g., denoting the programming language in a code block). 29 | 30 | Please check that everything is ok locally (by opening index.html in the browser) before sending a pull request. 31 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | All Reports in this Repository are licensed by Contributors under the 2 | [W3C Software and Document 3 | License](http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document). Contributions to 4 | Specifications are made under the [W3C CLA](https://www.w3.org/community/about/agreements/cla/). 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Network Information API 2 | This repository is the home of the **Network Information API**, currently incubating at the [WICG](https://wicg.io). 3 | 4 | ## Contributing 5 | Everyone is welcome to contribute to this specification, but please see our [contributors guide](CONTRIBUTING.md). 6 | 7 | ## Useful links 8 | * [Network Information API specification](http://wicg.github.io/netinfo/) 9 | * [Use cases and requirements](http://w3c-webmob.github.io/netinfo-usecases/) 10 | -------------------------------------------------------------------------------- /downlink.json: -------------------------------------------------------------------------------- 1 | { 2 | "wimax":[{ 3 | "name": "WiMAX 1", 4 | "version": "rel 1", 5 | "max": { 6 | "downlink": 37.0, 7 | "uplink": 17.0 8 | }, 9 | "ref": { 10 | "url": "http://en.wikipedia.org/wiki/WiMAX#Comparison_with_other_mobile_Internet_standards" 11 | } 12 | },{ 13 | "name": "WiMAX 1.5", 14 | "version": "rel 1.5", 15 | "max": { 16 | "downlink": 141.0, 17 | "uplink": 138.0 18 | }, 19 | "ref": { 20 | "url": "http://en.wikipedia.org/wiki/WiMAX#Comparison_with_other_mobile_Internet_standards" 21 | } 22 | },{ 23 | "name": "WiMAX 2", 24 | "version": "rel 2", 25 | "max": { 26 | "downlink": 365.0, 27 | "uplink": 376.0 28 | }, 29 | "ref": { 30 | "url": "http://en.wikipedia.org/wiki/WiMAX#Comparison_with_other_mobile_Internet_standards" 31 | } 32 | }], 33 | "cellular": [{ 34 | "name": "GSM", 35 | "version": "2G", 36 | "max": { 37 | "downlink": 0.010, 38 | "uplink": 0.010 39 | }, 40 | "latencyRange": "1000+", 41 | "ref": { 42 | "url1": "http://en.wikipedia.org/wiki/High-Speed_Circuit-Switched_Data", 43 | "url2": "http://www.cni.co.th/download/cni_co_th/kb_dc_gsm%20vs.%20gprs.pdf" 44 | } 45 | }, { 46 | "name": "IDEN", 47 | "version": "2G", 48 | "max": { 49 | "downlink": 0.064, 50 | "uplink": 0.064 51 | }, 52 | "latencyRange": "500-1500", 53 | "ref": { 54 | "url": "http://www.rfcafe.com/references/electrical/wireless-comm-specs-new.htm" 55 | } 56 | }, { 57 | "name": "CDMA", 58 | "version": "2G", 59 | "max": { 60 | "downlink": 0.115, 61 | "uplink": 0.115 62 | }, 63 | "latencyRange": "500-1500", 64 | "ref": { 65 | "url": "http://www.rfcafe.com/references/electrical/wireless-comm-specs-new.htm" 66 | } 67 | }, { 68 | "name": "1xRTT", 69 | "version": "2.5G", 70 | "max": { 71 | "downlink": 0.153, 72 | "uplink": 0.153 73 | }, 74 | "latencyRange": "500-1000", 75 | "ref": { 76 | "url": "http://en.wikipedia.org/wiki/CDMA2000#1X" 77 | } 78 | }, { 79 | "name": "GPRS", 80 | "version": "2.5G", 81 | "max": { 82 | "downlink": 0.237, 83 | "uplink": 0.237 84 | }, 85 | "latencyRange": "500-1000", 86 | "ref": { 87 | "url": "http://en.wikipedia.org/wiki/General_Packet_Radio_Service" 88 | } 89 | }, { 90 | "name": "EDGE", 91 | "version": "2.75G", 92 | "max": { 93 | "downlink": 0.384, 94 | "uplink": 0.384 95 | }, 96 | "latencyRange": "500-600", 97 | "ref": { 98 | "url": "http://www.umtsworld.com/technology/edge.htm" 99 | } 100 | }, { 101 | "name": "UMTS", 102 | "version": "3G", 103 | "max": { 104 | "downlink": 2.0, 105 | "uplink": 2.0 106 | }, 107 | "latencyRange": "150-450", 108 | "ref": { 109 | "url": "http://www.radio-electronics.com/info/cellulartelecomms/3g-hspa/umts-high-speed-packet-access-tutorial.php" 110 | } 111 | }, { 112 | "name": "EVDO Rev 0", 113 | "version": "3.5G", 114 | "max": { 115 | "downlink": 2.46, 116 | "uplink": 2.46 117 | }, 118 | "latencyRange": "150-350", 119 | "ref": { 120 | "url": "http://en.wikipedia.org/wiki/Comparison_of_wireless_data_standards#Peak_bit_rate_and_throughput" 121 | } 122 | }, { 123 | "name": "EVDO Rev A", 124 | "version": "3.5G", 125 | "max": { 126 | "downlink": 3.1, 127 | "uplink": 3.1 128 | }, 129 | "latencyRange": "100-250", 130 | "ref": { 131 | "url": "http://en.wikipedia.org/wiki/Evolution-Data_Optimized#TIA-856_Rev._A" 132 | } 133 | }, { 134 | "name": "HSPA", 135 | "version": "3.5G", 136 | "max": { 137 | "downlink": 3.6, 138 | "uplink": 3.6 139 | }, 140 | "latencyRange": "100-250", 141 | "ref": { 142 | "url": "http://www.4gamericas.org/index.cfm?fuseaction=page§ionid=247" 143 | } 144 | }, { 145 | "name": "EVDO Rev B", 146 | "version": "3.75G", 147 | "max": { 148 | "downlink": 14.7, 149 | "uplink": 14.7 150 | }, 151 | "latencyRange": "70-150", 152 | "ref": { 153 | "url": "http://en.wikipedia.org/wiki/Evolution-Data_Optimized#TIA-856_Rev._B" 154 | } 155 | }, { 156 | "name": "HSDPA", 157 | "version": "3.75G", 158 | "max": { 159 | "downlink": 14.3, 160 | "uplink": 0.384 161 | }, 162 | "latencyRange": "70-150", 163 | "ref": { 164 | "url1": "http://www.4gamericas.org/index.cfm?fuseaction=page§ionid=247", 165 | "url2": "http://en.wikipedia.org/wiki/High-Speed_Downlink_Packet_Access#Other_improvements", 166 | "note": "HSDPA/HSUPA max downlink speeds are 14.4Mbps. However, reporting the same value via maxDownlink does not allow us to differentiate between these versions, and given the uplink performance difference (0.384Mbps vs 5.76Mbps), this is an important distinction. As a result, we're intentionally setting the downlink value for HSDPA to 14.3." 167 | } 168 | }, { 169 | "name": "HSUPA", 170 | "version": "3.75G", 171 | "max": { 172 | "downlink": 14.4, 173 | "uplink": 5.76 174 | }, 175 | "latencyRange": "70-150", 176 | "ref": { 177 | "url1": "http://www.4gamericas.org/index.cfm?fuseaction=page§ionid=247", 178 | "url2": "http://en.wikipedia.org/wiki/High-Speed_Uplink_Packet_Access" 179 | } 180 | }, { 181 | "name": "EHRPD", 182 | "version": "3.9G", 183 | "max": { 184 | "downlink": 21.0, 185 | "uplink": 21.0 186 | }, 187 | "latencyRange": "50-150", 188 | "ref": { 189 | "url": "http://www.cdg.org/news/events/cdmaseminar/09_TechForum_Sept/presentations/5-Spirent-ehrpd_9_handouts.pdf", 190 | "note": "eHRPD is a method of interworking multiple access networks (eHRPD, E-UTRAN), as such it's a mix of 3.75G-4G technologies, and there isn't a single max value. As a result, 21.0 Mbps is an in-between value." 191 | } 192 | }, { 193 | "name": "HSPAP", 194 | "version": "3.9G", 195 | "max": { 196 | "downlink": 42.0, 197 | "uplink": 42.0 198 | }, 199 | "latencyRange": "50-100", 200 | "ref": { 201 | "url": "http://www.4gamericas.org/index.cfm?fuseaction=page§ionid=248" 202 | } 203 | }, { 204 | "name": "LTE", 205 | "version": "4G", 206 | "max": { 207 | "downlink": 100.0, 208 | "uplink": 100.0 209 | }, 210 | "latencyRange": "20-70", 211 | "ref": { 212 | "url": "http://www.4gamericas.org/index.cfm?fuseaction=page§ionid=249" 213 | } 214 | }, { 215 | "name": "LTE Advanced", 216 | "version": "4G", 217 | "max": { 218 | "downlink": 100.0, 219 | "uplink": 100.0 220 | }, 221 | "latencyRange": "20-50", 222 | "ref": { 223 | "url": "http://www.4gamericas.org/index.cfm?fuseaction=page§ionid=249" 224 | } 225 | }], 226 | 227 | "bluetooth": [{ 228 | "name": "1.2", 229 | "version": "1.2", 230 | "max": { 231 | "downlink": 1.0, 232 | "uplink": 1.0 233 | }, 234 | "latencyRange": "75-125", 235 | "ref": { 236 | "url": "http://en.wikipedia.org/wiki/Bluetooth#Uses" 237 | } 238 | }, { 239 | "name": "2.1 + Enhanced Data Rate (EDR)", 240 | "version": "2.1+EDR", 241 | "max": { 242 | "downlink": 3.0, 243 | "uplink": 3.0 244 | }, 245 | "latencyRange": "75-125", 246 | "ref": { 247 | "url": "http://en.wikipedia.org/wiki/Bluetooth#Uses" 248 | } 249 | }, { 250 | "name": "3.0 + High Speed (HS)", 251 | "version": "3.0+HS", 252 | "max": { 253 | "downlink": 24.0, 254 | "uplink": 24.0 255 | }, 256 | "latencyRange": "75-125", 257 | "ref": { 258 | "url1": "http://en.wikipedia.org/wiki/Bluetooth#Uses", 259 | "url2": "https://learn.sparkfun.com/tutorials/bluetooth-basics/common-versions" 260 | } 261 | }, { 262 | "name": "4.0 + Bluetooth Low Energy (BLE)", 263 | "version": "4.0+BLE", 264 | "max": { 265 | "downlink": 1.0, 266 | "uplink": 1.0 267 | }, 268 | "latencyRange": "3-6", 269 | "ref": { 270 | "url": "http://en.wikipedia.org/wiki/Bluetooth_low_energy" 271 | } 272 | }], 273 | 274 | "ethernet": [{ 275 | "name": "Ethernet", 276 | "version": "10", 277 | "max": { 278 | "downlink": 10.0, 279 | "uplink": 10.0 280 | }, 281 | "latencyRange": "0+", 282 | "ref": { 283 | "url": "http://en.wikipedia.org/wiki/Ethernet" 284 | } 285 | }, { 286 | "name": "Fast Ethernet", 287 | "version": "100", 288 | "max": { 289 | "downlink": 100.0, 290 | "uplink": 100.0 291 | }, 292 | "latencyRange": "0+", 293 | "ref": { 294 | "url": "http://en.wikipedia.org/wiki/Fast_Ethernet" 295 | } 296 | }, { 297 | "name": "Gigabit Ethernet", 298 | "version": "GigE", 299 | "max": { 300 | "downlink": 1000.0, 301 | "uplink": 1000.0 302 | }, 303 | "latencyRange": "0+", 304 | "ref": { 305 | "url": "http://en.wikipedia.org/wiki/Gigabit_Ethernet" 306 | } 307 | }, { 308 | "name": "10-gigabit Ethernet", 309 | "version": "10 GigE", 310 | "max": { 311 | "downlink": 10000.0, 312 | "uplink": 10000.0 313 | }, 314 | "latencyRange": "0+", 315 | "ref": { 316 | "url": "http://en.wikipedia.org/wiki/10-gigabit_Ethernet" 317 | } 318 | }], 319 | 320 | "wifi": [{ 321 | "name": "b", 322 | "version": "802.11b", 323 | "max": { 324 | "downlink": 11.0, 325 | "uplink": 11.0 326 | }, 327 | "latencyRange": "0+", 328 | "ref": { 329 | "url": "http://en.wikipedia.org/wiki/IEEE_802.11#802.11b" 330 | } 331 | }, { 332 | "name": "g", 333 | "version": "802.11g", 334 | "max": { 335 | "downlink": 54.0, 336 | "uplink": 54.0 337 | }, 338 | "latencyRange": "0+", 339 | "ref": { 340 | "url": "http://en.wikipedia.org/wiki/IEEE_802.11#802.11g" 341 | } 342 | }, { 343 | "name": "n", 344 | "version": "802.11n", 345 | "max": { 346 | "downlink": 600.0, 347 | "uplink": 600.0 348 | }, 349 | "latencyRange": "0+", 350 | "ref": { 351 | "url": "http://en.wikipedia.org/wiki/IEEE_802.11#802.11n" 352 | } 353 | }, { 354 | "name": "ac", 355 | "version": "802.11ac", 356 | "max": { 357 | "downlink": 6933.3, 358 | "uplink": 6933.3 359 | }, 360 | "latencyRange": "0+", 361 | "ref": { 362 | "url": "http://www.cisco.com/c/en/us/solutions/collateral/enterprise-networks/802-11ac-solution/q-and-a-c67-734152.html" 363 | } 364 | }, { 365 | "name": "ad", 366 | "version": "802.11ad", 367 | "max": { 368 | "downlink": 7000.0, 369 | "uplink": 7000.0 370 | }, 371 | "latencyRange": "0+", 372 | "ref": { 373 | "url": "http://en.wikipedia.org/wiki/IEEE_802.11#802.11ad" 374 | } 375 | }], 376 | 377 | "unknown": [{ 378 | "name": "unknown", 379 | "version": "unknown", 380 | "max": { 381 | "downlink": "+Infinity", 382 | "uplink": "+Infinity" 383 | } 384 | }], 385 | "none": [{ 386 | "name": "none", 387 | "version": "none", 388 | "max": { 389 | "downlink": 0, 390 | "uplink": 0 391 | } 392 | }], 393 | "other": [{ 394 | "name": "other", 395 | "version": "other", 396 | "max": { 397 | "downlink": "user agent specific.", 398 | "uplink": "user agent specific." 399 | } 400 | }] 401 | } 402 | -------------------------------------------------------------------------------- /examples/example1.html: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 |

This is a free ACME service. However, your operator may 11 | charge you for the amount of data you use. If you are unsure how much data 12 | costs on your tariff, please contact your network operator. 13 | 14 |

15 | 16 |
17 | 18 |
19 |

This is a free ACME service. However, your operator may 20 | charge you for the amount of data you use. If you are unsure how much data 21 | costs on your tariff, please contact your network operator. 22 | 23 |

24 | 25 |
26 |
27 |

This is a free ACME service. However, your operator may 28 | charge you for the amount of data you use. If you are unsure how much data 29 | costs on your tariff, please contact your network operator. 30 | 31 |

32 | 33 |
34 | 35 | 104 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Network Information API 4 | 5 | 103 | 104 |
105 | The Network Information API enables web applications to access information about the network connection in use by the device. 106 |
107 | 108 |
109 | 110 | ## Requirements and use cases 111 | 112 | This document describes an API that addresses two specific requirements: 113 | 114 | ### Provide an interface for determining the [connection type](https://wicg.github.io/netinfo/#dfn-connection-types) currently used to communicate with the network. 115 | 116 | It should be queryable in an ad hoc fashion from client pages, and should also be available in other contexts, like exposed to [service workers](https://w3c.github.io/ServiceWorker/v1/). 117 | 118 | **Example use cases:** 119 | 120 | * A web application whose primary purpose is to stream media could check `navigator.connection.type` prior to playback. When it's set to `'cellular'`, it could advise users that their mobile network operator might be charging for the bandwidth, and only start automatic playback of previously cached content. 121 | * A web application that makes use of a service worker to [cache](https://w3c.github.io/ServiceWorker/v1/#cache-objects) resources during [installation](https://w3c.github.io/ServiceWorker/v1/#installation-algorithm) might have different bundles of assets that it might cache: a list of crucial assets that are cached unconditionally, and a bundle of larger, optional assets that are only cached ahead of time when `navigator.connection.type` is `'ethernet'` or `'wifi'`. 122 | * A web application that uses a service worker with a [background sync](https://github.com/WICG/BackgroundSync/blob/master/explainer.md) handler might check the current `navigator.connection.type` value, and only transfer data inside the `sync` event handler if it is is `'ethernet'` or `'wifi'`. 123 | * A web application might make decision to enable offline mode based on network condition (e.g., when EDGE is not enough). 124 | 125 | ### Provide a way for scripts to be notified if the connection type changes. 126 | 127 | This allows developers to make dynamic changes to their user interface to inform the user that the network connection type has changed, and that it could impact them in some way. It also allows applications that were deferring the transfer of large amounts of data to automatically begin once a high-bandwidth network is detected. 128 | 129 | **Example use cases:** 130 | 131 | * A web application whose primary purpose is to stream media could dynamically change its user interface in response to updates to the connection type. This may afford a better user experience than waiting until a user attempts to playback and performing a one-off query. It allows applications to provide context about the connection in advance of user interaction. 132 | * A web application that allows for uploads or downloads might defer initiating the request when `navigator.connection.type` is set to `'cellular'`, and add a listener for changes to the connection. When a change to a high-bandwidth network type is detected, the request could be automatically started. 133 | 134 |
135 | ## Examples of usage 136 | For examples of the kinds of applications one can build with this API, see the [Review of Apps that Use Network Information](https://github.com/w3c-webmob/netinfo). 137 | 138 |
139 |   // Get the connection type.
140 |   var type = navigator.connection.type;
141 | 
142 |   // Get an upper bound on the downlink speed of the first network hop
143 |   var max = navigator.connection.downlinkMax;
144 | 
145 |   function changeHandler(e) {
146 |     // Handle change to connection here.
147 |   }
148 | 
149 |   // Register for event changes.
150 |   navigator.connection.onchange = changeHandler;
151 | 
152 |   // Alternatively.
153 |   navigator.connection.addEventListener('change', changeHandler);
154 |   
155 |
156 | 157 | 158 | ## Definitions 159 | 160 | For clarity, a megabit is 1,000,000 bits, and megabits per second is equivalent to transferring: 161 | 162 | * 1,000,000 bits per second 163 | * 1,000 kilobits per second 164 | * 125,000 bytes per second 165 | * 125 kilobytes per second 166 | * and so on... 167 | 168 | 169 | ## Connection types 170 | 171 | ### Underlying connection technology 172 | 173 | This section defines the connection types and the underlying connection technology that the user agent is using (if any): 174 | 175 |
176 |
bluetooth
177 |
A Bluetooth connection.
178 |
cellular
179 |
A cellular connection (e.g., EDGE, HSPA, LTE, etc.).
180 |
ethernet
181 |
An Ethernet connection.
182 |
none
183 |
No network connection. The user agent will not contact the network when the user follows links or when a script requests a remote page (or knows that such an attempt would fail) - i.e., equivalent to navigator.onLine === false in HTML.
184 |
mixed
185 |
The user agent is using multiple connection types.
186 |
other
187 |
The connection type that is known, but not one of enumerated connection types.
188 |
unknown
189 |
The user agent has established a network connection, but is unable, or unwilling, to determine the underlying connection technology.
190 |
wifi
191 |
A Wi-Fi connection.
192 |
wimax
193 |
A WiMAX connection.
194 |
195 | 196 | The connection types are represented in this API by the ConnectionType enum. 197 | 198 | ### ConnectionType enum 199 | 200 |
201 |   enum ConnectionType {
202 |     "bluetooth",
203 |     "cellular",
204 |     "ethernet",
205 |     "mixed",
206 |     "none",
207 |     "other",
208 |     "unknown",
209 |     "wifi",
210 |     "wimax"
211 |   };
212 | 
213 | 214 | ### Effective connection types 215 | 216 | This section defines the effective connection types (ECT): 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 |
Table of effective connection types
ECTMinimum RTT (ms)Maximum downlink (Kbps)Explanation
slow-2g200050The network is suited for small transfers only such as text-only pages.
2g140070The network is suited for transfers of small images.
3g270700The network is suited for transfers of large assets such as high resolution images, audio, and SD video.
4g0The network is suited for HD video, real-time video, etc.
255 | 256 | The above round-trip and bandwidth values are based on real user measurement observations: 257 | 258 | * `slow-2g` is the 66.6th percentile of 2G observations 259 | * `2g` is the 50th percentile of 2G observations 260 | * `3g` is the 50th percentile of 3G observations 261 | 262 | 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. 263 | 264 | The effective connection types are represented in this API by the EffectiveConnectionType enum. 265 | 266 | ### EffectiveConnectionType enum 267 | 268 |
269 |   enum EffectiveConnectionType {
270 |     "2g",
271 |     "3g",
272 |     "4g",
273 |     "slow-2g"
274 |   };
275 | 
276 | 277 | 278 | ## NavigatorNetworkInformation interface 279 | 280 | The Navigator and WorkerNavigator interface expose access to NetworkInformation interface by mixing in NavigatorNetworkInformation. 281 | 282 |
283 |   interface mixin NavigatorNetworkInformation {
284 |     [SameObject] readonly attribute NetworkInformation connection;
285 |   };
286 | 
287 |   Navigator includes NavigatorNetworkInformation;
288 |   WorkerNavigator includes NavigatorNetworkInformation;
289 | 
290 | 291 |
292 | ### connection attribute 293 | 294 | The connection attribute, when getting, returns an object that implements the NetworkInformation interface. 295 |
296 | 297 |
298 | ## NetworkInformation interface 299 | 300 | 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]]. 301 | 302 |
303 |   [Exposed=(Window,Worker)]
304 |   interface NetworkInformation : EventTarget {
305 |     readonly attribute ConnectionType type;
306 |     readonly attribute EffectiveConnectionType effectiveType;
307 |     readonly attribute Megabit downlinkMax;
308 |     readonly attribute Megabit downlink;
309 |     readonly attribute Millisecond rtt;
310 |     attribute EventHandler onchange;
311 |   };
312 | 
313 |   typedef unrestricted double Megabit;
314 |   typedef unsigned long long Millisecond;
315 |   
316 | 317 | This section also defines a number of HTTP request header fields that expose details about the user's network conditions, which servers can opt-into receiving. They can do that via the Client Hints infrastructure defined in [[CLIENT-HINTS]] and bound by the processing model defined in [[CLIENT-HINTS-INFRASTRUCTURE]]. 318 | 319 | ### type attribute 320 | 321 | The type attribute, when getting, returns the connection type that the user agent is using. 322 | 323 | ### effectiveType attribute 324 | 325 | The effectiveType attribute, when getting, returns the effective connection type that is determined using a combination of recently observed rtt and downlink values. 326 | 327 | #### ECT Request Header Field 328 | 329 | The ECT request header field is a token that indicates the effectiveType, which is one of EffectiveConnectionType values, at the time when the request is made by the user agent. 330 | It is a Structured Header whose value must be a Token. [[STRUCTURED-HEADERS]] 331 | 332 | ### downlinkMax attribute 333 | 334 | 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. 335 | 336 |
337 | 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. 338 |
339 | 340 | ### onchange attribute 341 | 342 | The onchange event handler attribute handles "change" events fired during the steps to update the connection values. 343 | 344 | ### downlink attribute 345 | 346 | The downlink attribute represents the effective bandwidth estimate in megabits per second, rounded to nearest multiple of 25 kilobits per second, and is based on recently observed application layer throughput across recently active connections, excluding connections made to private address space [[!RFC1918]]. In absence of recent bandwidth measurement data, the attribute value is determined by the properties of the underlying connection technology. 347 | 348 | #### `Downlink` Request Header Field 349 | 350 | The Downlink request header field is a number that indicates the downlink value at the time when the request is made by the user agent. 351 | It is a Structured Header whose value must be a Decimal. [[STRUCTURED-HEADERS]] 352 | 353 | ### rtt attribute 354 | 355 | The rtt attribute represents the effective round-trip time estimate in milliseconds, rounded to nearest multiple of 25 milliseconds, and is based on recently observed application-layer RTT measurements across recently active connections, excluding connections made to private address space [[!RFC1918]]. In absence of recent RTT measurement data, the attribute value is determined by the properties of the underlying connection technology. 356 | 357 | #### `RTT` Request Header Field 358 | 359 | The RTT request header field is a number that indicates the rtt value at the time when the request is made by the user agent. 360 | It is a Structured Header whose value must be an Integer. [[STRUCTURED-HEADERS]] 361 | 362 | ## Underlying connection technology 363 | 364 | 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. 365 | 366 | 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. 367 | 368 | 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. 369 | 370 |
371 | 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. 372 |
373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 |
393 | ### Handling changes to the underlying connection 394 | 395 | 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: 396 | 397 | 1. Let new-type be the connection type that represents the underlying connection technology. 398 | 1. Let new-effective-type be the effective connection type determined by current downlink and rtt values. 399 | 1. Let new-downlink be the result of: 400 | 1. Rounding downlink value to nearest multiple of 25 kilobits per second. 401 | 1. If the resulting value is 10% greater or smaller than the value of `connection.downlink`, then set new-dowlink to resulting value. Otherwise, set new-downlink to the value of `connection.downlink`. 402 | 1. Let new-rtt be the result of: 403 | 1. Rounding rtt value to nearest multiple of 25 milliseconds. 404 | 1. If the resulting value is 10% greater or smaller than the value of `connection.rtt`, then set new-rtt to resulting value. Otherwise, set new-rtt to the value of `connection.rtt`. 405 | 1. If new-type is "none", set max-value to `0`. 406 | 1. if new-type is "unknown", set max-value to `+Infinity`. 407 | 1. If new-type is "mixed", set max-value to an applicable value for the interface configuration used to service new network requests - e.g. if multiple interfaces may be used, sum their downlinkMax for an available interface values. 408 | 1. Otherwise, set max-value to downlinkMax for an available interface. 409 | 1. If max-value is not equal to the value of `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`: 410 | 1. Using the networking task source, queue a task to perform the following: 411 | 1. Set `connection.downlinkMax` to max-value. 412 | 1. Set `connection.type` to new-type. 413 | 1. set `connection.effectiveType` to new-effective-type. 414 | 1. Set `connection.downlink` to new-downlink. 415 | 1. Set `connection.rtt` to new-rtt. 416 | 1. Fire an event named `change` at the `NetworkInformation` object. 417 |
418 | 419 |
420 | ## Privacy Considerations 421 | 422 | The Network Information API exposes information about the observed end-to-end network bandwidth and 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: 423 | 424 | * Fingerprint a user based on characteristics of a particular network (e.g. type and downlink estimates) at a point in time, and by observing change in such characteristics over a period of time. 425 | * Fingerprint a user based on transitions between one or more networks (e.g. based on order of transitions by type, downlink estimates, and time). 426 | * Infer user location (e.g. are they home, at work, or in transit) based on above criteria. 427 | 428 | However, above considerations are not new, and sufficiently motivated attackers may already obtain such information using other technologies: 429 | 430 | * The attacker can use JavaScript to observe the duration (e.g. time from start of fetch to `onload` event) of any network fetch (same or cross-origin) on the client, and may get more detailed timing data about the same fetch via the Resource Timing API. 431 | * The attacker can use WebRTC to identify client's public and private IP addresses via STUN, or similar mechanisms. 432 | * The attacker can observe the client IP, fetch duration, RTT, transfer speed, and other low-level socket metrics of a fetch on the server. 433 | 434 | 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. 435 | 436 | 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: 437 | 438 | * If the attacker can initiate or observe a network fetch of any kind from the client, then they can observe its performance characteristics and how they change over time. 439 | * If the attacker can convince the client to fetch a resource from their server, then they can similarly observe the performance characteristics of the fetch and how they change over time. 440 | 441 | 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. 442 | 443 | As such, while the Network Information API makes it easier to obtain information about the end-to-end network throughput, latency, and 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. 444 | 445 | 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. 446 |
447 | 448 |
449 | ## IANA Considerations 450 | 451 | The following three HTTP request header fields should be added to the permanent registry of message header fields (see [[!RFC3864]]), taking into account the guidelines given by HTTP/1.1 [[!RFC7231]]. 452 | 453 |
454 | ### `ECT` Request Header Field Registration 455 | 456 | * Header Field Name: ECT 457 | * Applicable Protocol: Hypertext Transfer Protocol (HTTP) 458 | * Status: Standard 459 | * Author/Change controller: W3C 460 | * Specification document(s): W3C TR https://www.w3.org/TR/netinfo/ 461 | 462 |
463 | 464 | 474 | 475 |
476 | ### `RTT` Request Header Field Registration 477 | 478 | * Header Field Name: RTT 479 | * Applicable Protocol: Hypertext Transfer Protocol (HTTP) 480 | * Status: Standard 481 | * Author/Change controller: W3C 482 | * Specification document(s): W3C TR https://www.w3.org/TR/netinfo/ 483 | 484 |
485 | 486 |
487 | 488 |
489 | There is only one class of product that can claim conformance to this 490 | specification: a user agent. 491 |
492 | 493 |
494 | ## Acknowledgments 495 | This document reuses text from the [[!HTML]] specification 496 | as permitted by the license of that specification. 497 |
498 | -------------------------------------------------------------------------------- /w3c.json: -------------------------------------------------------------------------------- 1 | { 2 | "group": ["80485"] 3 | , "contacts": ["marcoscaceres"] 4 | , "shortName": "netinfo", 5 | "repo-type": "cg-report" 6 | } 7 | --------------------------------------------------------------------------------