summaryrefslogtreecommitdiff
path: root/doc/session-overview.txt
blob: 82e3f89a1b8f45e21e717fe4729af5234790468a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
Session API
***********


Connection management algorithm basics
======================================

When a session is created, a sorted list of services is added to the
session. The services are filtered and stable sorted according
following rules:

 - AllowedBearers (filter and sort)
 - RoamingPolicy (filter and sort)

A stable sorting algorithm maintains the relative order.

If a service is removed or added all sessions are updated according
the above rules.

There are three triggers which lead to evaluate the connect
algorithm:

 - Session.Connect()
 - PeriodicConnect
 - Offline

Connect algorithm:

              Session.Connect()     Offline
              PeriodicConnect        |
                       | Yes  +------+-------+  No
                       +------+StayConnected?+------ Do nothing
                       |      +--------------+
Session.Change() ------+
                       |
                +------+-------+
          +-----+EmergencyCall?+-----+
       Yes|     +--------------+     |No
          |                          |
        Connect to            +--------------+
        first available   +---+AvoidHandover?+---+
        Service           |   +--------------+   |
                       Yes|                      |No
                 +----------------+              |
             +---+In service_list +---+          |
          Yes|   |and online?     |   |No        |
             |   +----------------+   |          |
             |                        |          |
         Take that one                Take first in
                                      the service list

There are two triggers which lead to evaluate the disconnect
algorithm

 - Session.Disconnect()
 - IdleTimeout

Disconnect algorithm:

  Session.Disconnect()
  IdleTimeout
       |
       +--- Session.Change()
       |
+-----------------+    Yes
|service not used +-------------+
|by other session?|             |
+------.----------+             |
       |No                      |
       |                        |
    Service.Disconnect()   Do nothing


Session States and Transitions
==============================

There are three main strategies for state changes.

 - Free Ride
 - Connect
 - Disconnect

The initial state for all new sessions is Free Ride.

The Free Ride state means that a session will go online if a matching
service goes online without calling Service.Connect() itself. The idea
behind this is that a session doesn't request a connection for itself
instead waits until another session actively requires to go online.
This is comparable to piggy-backing.

When a session is in the Connect state ConnMan tries to find a
matching service (see Connect algorithm) and then decides either to
connect the service or delay the request. ConnMan is allowed to
connect to the service or to delay it, e.g. group PeriodicConnects
together. The session will leave the Connect state when the service
goes offline unless StayConnected is True. It will enter the Free Ride
mode again.

When the application calls Disconnect() the session enters the
Disconnect state and stays there until the application calls Connect()
again.


                 State Change to offline & StayConnected = True
                              +------+
                              |      v
+-----------+                +---------+ -- Disconnect() --> +------------+
| Free Ride |-- Connect() -->| Connect |                     | Disconnect |
+-----------+                +---------+  <-- Connect() ---  +------------+
      |  ^                         |                               ^
      |  +------------------------ +                               |
      |   State Change to offline & StayConnected = False          |
      |                                                            |
      |                                                            |
      +----------------------- Disconnect() -----------------------+

Note: this documents the current behavior it is likely to change in near
future.


Additional Information on Settings
==================================

PeriodicConnect and IdleTimeout
-------------------------------

If an application wants to go online periodically (e.g. checking for
new mails) then the application should use PeriodicConnect instead of
calling Session.Connect() periodically. There is no need for the
application to maintain timers. ConnMan is also able to try to combine
several PeriodicConnect calls into one. Applications should not rely on a
very precise periodic connect. Apart from merging periodic connect
timeouts there is also the problem that no service might be available
at that point and ConnMan will defer the connect call.

The IdleTimeout tells ConnMan when a link is idle for given period it
is okay to disonnect.

PeriodicConnect and IdleTimeout should only consired as hints. ConnMan
will try to meet them but there is no garantee for doing so. For
example global settings have precedence over session settings.