Hi all,
Recently, Taipei team had a internal discussion about the NetworkManager
enhancement. We think it is worth sharing to you about the details. Any
suggestion or comment is always welcome!!
In current b2g, NetworkManager is a module that takes care of the
routing decision and provides some network/connection related
information. We propose to enhance it to handle more things. I tried to
summaries as below:
_Why we are going to do this?_
1. Connection policy is an important feature on device. In current b2g,
the connection policy is controlled in each interface. For example, when
Wifi connection is established, device should drop mobile connection to
save battery power [1]. This policy is controlled in RIL side, RIL needs
to monitor the wifi connection. When wifi connection is established, RIL
will close it's data connection. And when wifi connection is dropped,
RIL will try to establish it's connection back. This seems trivial, but
when the policy is becoming more and more complicate, it is not easy to
maintain in a disperse way. So it is necessary to have a central module
to make a decision based on the policy.
2. Some feature will request a special connection for sending data.
Taking mms in current b2g as example, mms service needs to establish a
mms connection to send message (Use MMS APN to make a data call).
Imagine that if there are two modules, A and B, need the same
connection, X. Module A makes a release request cause it finish it's
task and need not the connection any more. But module B is still in use.
In this case, the connection X should not be released because it is
still used by module B. Now we don't have a generic way to handle those
establish/release requests for a specific connection, and also have no a
central manager to manage them.
_Goals:_
1. Policy control in a centralize way.
** Policy can be configurable.
2. Easy to add a new network.
** We believe there are more and more networks will be supported in
b2g.
3. Manage establish/release request for a specific connection in a
centralize way.
4. Maybe it can be a platform independent module.
_Proposal:_
1. Having a general network interface.
- To add a new network, we just need to implement this interface
and register/unregister it to NetworkManager.
- NetworkManager can control registered network through this interface.
2. When does a network register/unregister.
- Register: when the network is available to use, i.e radio is on
or driver is loaded .. etc.
- Unregister: when the network is unavailable to use or not existed
anymore, i.e radio is off or driver is unloaded .. etc.
3. How dose NetworkManager control the registered network?
- connect(): Ask the network try to establish connection.
- disconnect(): Ask the network drop connection.
_Draft software architecture:_
https://docs.google.com/drawings/d/1wldBv82IsGwls-a3yAFDB-Jj1HeOtUnDuJRg7JfzRQU/edit?usp=sharing
_Proposed network interface:_
interface nsINetworkInterface {
readonly attribute nsINetworkInfo info;
readonly attribute DOMString[] hostRoutes;
readonly attribute DOMString poxyHost;
readonly attribute long proxyPort;
void connect(); // Request network establish connection.
void disconnect(); // Request network drop connection.
attribute nsIDOMEventListener onnetworkinfochanged; // Trigger
when network status is changed
}
interface nsINetworkInfo {
readonly attribute long type;
readonly attribute DOMString serviceId;
readonly attribute DOMString ip;
readonly attribute DOMString netmask;
readonly attribute DOMString broadcast;
readonly attribute DOMString gateway;
readonly attribute DOMString dns1;
readonly attribute DOMString dns2;
}
We are still under discussion, we will share to you when having any
progress.
Thanks
[1]
https://bugzilla.mozilla.org/show_bug.cgi?id=817985
Best Regards,
Edgar Chen
--
Mozilla Taiwan
ec...@mozilla.com