source: trunk/doc/src/network-programming/bearermanagement.qdoc@ 1036

Last change on this file since 1036 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 14.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29\page bearer-management.html
30
31\title Bearer Management
32\ingroup qt-network
33\brief An API to control the system's connectivity state.
34
35Bearer Management controls the connectivity state of the system so that
36the user can start or stop interfaces or roam transparently between
37access points.
38
39\tableofcontents
40
41
42\section1 Overview
43
44The Bearer Management API controls the system's connectivity state. This
45incorporates simple information such as whether the device is online and
46how many interfaces there are as well as enables the application developer
47to start, stop network interfaces and influences other connection specific
48details. Depending on the platform's capabilities it may even provide
49session management so that a network interface remains up for as long as
50clients have a registered interest in them while at the same time
51optimizes the interface's uptime.
52
53This API does not provide support for management of network configurations
54themselves. It is up to the platform to provide infrastructure which
55enables to user to create, edit or delete network configurations.
56
57\section2 The API in Detail
58
59Computer systems manage their network interfaces via a set of configurations.
60Each configuration describes a set of parameters which instruct the system
61how a particular network interface is started. One of the most simplistic
62examples might be an Ethernet configuration that links a network card to a
63DHCP server. A more complex example might be a Wireless LAN configuration
64which may comprise of hardware details such as the WLAN card address,
65WLAN access point details (e.g ESSID, encryption details) and user specific
66information (for example username and password). Once the network interface
67was configured and started according to the configuration blue print,
68multiple applications are free to use this link layer connection/session
69for their own socket operations. Note that the QNetworkConfiguration object
70only provides limited information about the configuration details themselves.
71It's main purpose is to act as a configuration identifier through which link
72layer connections can be created, destroyed and monitored.
73
74QNetworkSession provides two types of use cases. It enables the monitoring of
75physical network interfaces and management of network sessions. Network sessions
76are a common feature on mobile devices where multiple applications
77can request network sessions as they see fit. The system consolidates and tracks
78active network sessions for the same network interface by maintaining the link
79layer connections until the last session has been closed. The subsequent table
80lists the major QNetworkSession functions and how they fit into the session and
81hardware management categories:
82
83\table 60%
84\header \o Interface management \o Session management
85\row \o QNetworkSession::stop() \o QNetworkSession::open()
86\row \o QNetworkSession::interface() \o QNetworkSession::close()
87\row \o QNetworkSession::state() \o QNetworkSession::isOpen()
88\row \o QNetworkSession::bytesWritten() \o QNetworkSession::migrate()
89\row \o QNetworkSession::bytesReceived() \o QNetworkSession::ignore()
90\row \o QNetworkSession::activeTime() \o QNetworkSession::accept()
91\row \o QNetworkSession::stateChanged() \o QNetworkSession::reject()
92\row \o \o QNetworkSession::opened()
93\row \o \o QNetworkSession::closed()
94\endtable
95
96The state of the session represents the state of the underlying access point
97whereas the session's openness implies the networking/connectivity state available
98to the current process.
99
100Possible use cases for interface management are network management related
101applications which intend to monitor the connectivity state but do not engage
102in network communication themselves. Any application wanting to open a socket
103to a remote address will typically use session management related functionality.
104
105\section3 Service networks
106
107Some mobile platforms use the concept of grouped access points (also
108called SNAP or Service Network Access Point). In principle multiple
109configurations are grouped together and possibly even prioritized when
110compared to each other. This is useful for use cases where all
111configurations serve a similar purpose or context. A common context could
112be that they provide access to the public Internet or possibly only to the
113office Intranet. By providing a pool of configurations the system can make
114a decision based on given priorities which usually map to factors such as
115speed, availability and cost. Furthermore the system can automatically
116roam from one access point to the next one while ensuring minimal impact on
117the user experience.
118
119The \l{QNetworkConfiguration::Type} flag specifies to what category a
120configuration belongs. The \l{QNetworkConfiguration::InternetAccessPoint}
121type is the most common example. It represents a configuration that can be
122used to create a session. The above mentioned grouping behavior is provided
123by \l {QNetworkConfiguration::ServiceNetwork} configurations. Service
124networks are place holders until such time when the user attempts to
125\l {QNetworkSession::open()}{open()} a new session. At that point in time
126the system determines which of the configurations \l{QNetworkConfiguration::children()}
127is best to use. The selection algorithm is provided by the platform and is usually managed
128by network settings applications. A service network can only have one level of indirection
129which implies children can only be of type \l {QNetworkConfiguration::InternetAccessPoint}.
130
131Most systems allow the user to define the systems default configuration.
132Usually the default behavior is either a service network, a particular
133Internet access point or the user instructs the platform to ask the user
134once an application requests the network. User interaction is generally
135implemented by some sort of system dialog which shows up at the appropriate
136point in time. The application does not have to handle the user input. This
137API provides the \l QNetworkConfigurationManager::defaultConfiguration()
138call which serves a similar purpose. The subsequent code snippet provides
139a quick way how an application can quickly create a new network session
140without (or only minimal) user interaction:
141
142\code
143 // Set Internet Access Point
144 QNetworkConfigurationManager manager;
145 const bool canStartIAP = (manager.capabilities()
146 & QNetworkConfigurationManager::CanStartAndStopInterfaces);
147 // Is there default access point, use it
148 QNetworkConfiguration cfg = manager.defaultConfiguration();
149 if (!cfg.isValid() || (!canStartIAP && cfg.state() != QNetworkConfiguration::Active)) {
150 QMessageBox::information(this, tr("Network"), tr(
151 "No Access Point found."));
152 return;
153 }
154
155 session = new QNetworkSession(cfg, this);
156 session->open();
157 session->waitForOpened(-1);
158\endcode
159
160To accommodate the "Ask user" use case the default configuration can be of
161type QNetworkConfiguration::UserChoice. A user choice configuration is
162resolved as part of the \l {QNetworkSession::open()} call. Note that a
163\l{QNetworkConfiguration::UserChoice}{UserChoice} configuration is only
164ever returned via \l {QNetworkConfigurationManager::defaultConfiguration()}
165and not \l QNetworkConfigurationManager::allConfigurations().
166
167On systems which do not maintain a list of
168\l {QNetworkConfigurationManager::defaultConfiguration()}{defaultConfiguration()}
169an invalid configuration is returned. A possible workaround could be to
170implement a custom dialog which is populated based on what
171\l QNetworkConfigurationManager::allConfigurations() returns.
172
173\section3 Managing network sessions
174
175A QNetworkSession object separates a \l {QNetworkSession::state()}{state()}
176and an \l{QNetworkSession::isOpen()}{isOpen()} condition.
177
178The state() attribute enables developers to detect whether the system
179currently maintains a global network session for the given
180QNetworkConfiguration. If \l {QNetworkSession::isOpen()}{isOpen()}
181returns true the QNetworkSession instance at hand was at least one of the
182entities requesting the global network session. This distinction is
183required to support the notion of session registrations. For as long as
184there are one or more open QNetworkSession instances the underlying
185network interface is not shut down. Therefore the session
186\l{QNetworkSession::state()}{state()} can be used to monitor the state of
187network interfaces.
188
189An open session is created by calling \l {QNetworkSession::open()} and
190closed via \l{QNetworkSession::close()}, respectively. If the session
191is \l{QNetworkSession::Disconnected}{disconnected} at the time of the
192\l{QNetworkSession::open()}{open()} call the underlying interface is started;
193otherwise only the reference counter against the global session is
194incremented. The opposite behavior can be observed when using
195\l{QNetworkSession::close()}{close()}.
196
197In some use cases it may be necessary to turn the interface off despite of
198open sessions. This can be achieved by calling
199\l{QNetworkSession::stop()}{stop()}. An example use case could be a
200network manager type of application allowing the user to control the
201overall state of the devices connectivity.
202
203Global (inter-process) session support is platform dependent and can be
204detected via \l {QNetworkConfigurationManager::SystemSessionSupport}.
205If the system does not support global session calling
206\l{QNetworkSession::close()}{close()} never stops the interface.
207
208\section3 Roaming
209
210Roaming is the process of reconnecting a device from one network to another
211while minimizing the impact on the application. The system notifies the application
212about link layer changes so that the required preparation can be taken.
213The most common reaction would be to reinitialize sockets and to renegotiate
214stateful connections with other parties. In the most extreme cases applications
215may even prevent the roaming altogether.
216
217Roaming is initiated when the system determines that a more appropriate access point
218becomes available to the user. In general such a decision is based on cost, network speed
219or network type (access to certain private networks may only be provided via certain access points).
220Almost all devices providing roaming support have some form of global configuration application
221enabling the user to define such groups of access points (service networks) and priorities.
222
223This API supports two types of roaming. Application level roaming (ALR)
224provides the most control over the process. Applications will be notified about upcoming
225link layer changes and get the opportunity to test the new access point. Eventually they can
226reject or accept the link layer change. The second form of roaming is referred to as Forced Roaming.
227The system simply changes the link layer without consulting the application. It is up to
228the application to detect that some of its internal socket may have become invalid. As a consequence
229it has to reinitialize those sockets and reestablish the previous user session without
230any interruption. Forced roaming has the advantage that applications don't have to
231manage the entire roaming process by themselves.
232
233QNetworkSession is the central class for managing roaming related issues.
234
235\section3 Platform capabilities
236
237Some API features are not available on all platforms. The
238\l QNetworkConfigurationManager::Capability should be used to detect
239platform features at runtime. The following table lists the various
240platform APIs being used by this API. This may assist in the process of
241determining the feature support:
242
243\table
244 \header
245 \o Platform
246 \o Backend capabilities
247 \row
248 \o Linux\unicode{0xAE}
249 \o Linux uses the \l {http://projects.gnome.org/NetworkManager}{NetworkManager API} which supports interface notifications and starting and stopping of network interfaces.
250 \row
251 \o Windows\unicode{0xAE} XP
252 \o This platform supports interface notifications without active polling.
253 \row
254 \o Windows XP SP2+Hotfixes, Windows XP SP3, Windows Vista, Windows 7
255 \o In addition to standard Windows XP wifi access point monitoring has been improved which includes the ability to start and stop wifi interfaces. This requires Windows to manage the wifi interfaces.
256 \row
257 \o Symbian\unicode{0xAE} Platform & S60 3.1
258 \o Symbian support is based on Symbian platforms RConnection. In addition to interface notifications, starting and stopping of network it provides system wide session support and direct connection routing.
259 \row
260 \o Symbian Platform & S60 3.2+
261 \o This platform enjoys the most comprehensive feature set. In addition to the features support by the S60 3.1 Network roaming is supported.
262 \row
263 \o Mac OS\unicode{0xAE}
264 \o This platform has full support by way of CoreWLAN offered in Mac OS 10.6. Previous
265 versions of Mac OS - 10.5 and 10.4 have limited support.
266 \row
267 \o All other platforms (*nix, Windows Mobile)
268 \o This backend is the fallback for all platforms supports network interface notifications via active polling only.
269\endtable
270
271*/
Note: See TracBrowser for help on using the repository browser.