You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanid="id1"></span><h1>Connection Manager<aclass="headerlink" href="#connection-manager" title="Link to this heading"></a></h1>
102
+
<p>To use a data transport layer in your simulator, the first thing you have to do it to call <codeclass="xref cpp cpp-func docutils literal notranslate"><spanclass="pre">DTL::create()</span></code> in
103
+
the <codeclass="docutils literal notranslate"><spanclass="pre">main</span></code> function of your code. This will trigger the creation of the <strong>DTLMod connection manager</strong> and an instance
104
+
of a <aclass="reference internal" href="app_API.html#concept-dtl"><spanclass="std std-ref">DTL</span></a> object.</p>
105
+
<p>The connection manager is a <strong>daemon</strong> SimGrid actor (i.e., an simulated process running in the background and
106
+
automatically killed when the simulation ends) that runs on the first host declared in your platform description. This
107
+
daemon actor takes the newly created <aclass="reference internal" href="app_API.html#concept-dtl"><spanclass="std std-ref">DTL</span></a> object as argument.</p>
108
+
<p>Once started, the connection manager creates two SimGrid message queues (i.e., a rendez-vous point between actors
109
+
thanks to which actors can exchange information without inducing any simulated cost): one to receive <strong>connection</strong> or
110
+
<strong>disconnection</strong> requests and the other to send back a handler (i.e., a shared pointer) on the <aclass="reference internal" href="app_API.html#concept-dtl"><spanclass="std std-ref">DTL</span></a> object in
111
+
answer to a connection request.</p>
112
+
<p>Then, the connection manager enters an infinite loop in which it waits for connection and disconnection requests on the
113
+
first message queue. If it gets a <strong>connection request</strong>, meaning that an actor in your simulator called
114
+
<codeclass="xref cpp cpp-func docutils literal notranslate"><spanclass="pre">DTL::connect()</span></code>, the connection manager checks if this actor is already connected. If it is, it emits a
115
+
warning message advising you to check your code logic. Otherwise, it adds the calling actor to a list of <strong>active
116
+
connections</strong>, put the shared pointer on the <aclass="reference internal" href="app_API.html#concept-dtl"><spanclass="std std-ref">DTL</span></a> object in its second
117
+
message queue, and proceeds with waiting for the next request.</p>
118
+
<p>Conversely, if it gets a <strong>disconnection request</strong>, meaning that an actor in your simulator called
119
+
<codeclass="xref cpp cpp-func docutils literal notranslate"><spanclass="pre">DTL::disconnect()</span></code>, the connection manager checks whether this actor was still connected. If it was not, it
120
+
advises you to check your code logic. Otherwise, the connection manager removes the actor from the list of the active
121
+
connections, puts an acknowlegment to the disconnecting actor in the second message queue, and waits for the next
122
+
request.</p>
123
+
<p>Note that if during the execution of your simulator all your actors disconnect themselves from the DTL you will receive
124
+
a harmless message warning you that there is <strong>no active connection</strong> at the moment. However, the connection manager
125
+
remains active in the background and ready to process subsequent connection requests.</p>
126
+
<p>If you want to ignore this message you can either add <codeclass="docutils literal notranslate"><spanclass="pre">--log=dtlmod.t:critical</span></code> to the command line or call
127
+
<codeclass="docutils literal notranslate"><spanclass="pre">xbt_log_control_set("dtlmod.t:critical")</span></code> in your code (see <aclass="reference internal" href="Logging.html#logging"><spanclass="std std-ref">Logging and Debugging</span></a> for more details).</p>
0 commit comments