Bill, inline below.
On 1/23/23 16:18, Bill Tao wrote:
> Hi.
>
> After some more investigation, it seems a possible approach for me would
> be to create an ns-3 callback for the external program (so the callback
> would be cross-thread too).
>
> Is this possible to do? Are there any guidelines or examples I could follow?
The most recent examples of interactions between external programs and
ns-3 that I'm aware of are probably the AI/ML frameworks for ns-3:
ns3-gym:
https://apps.nsnam.org/app/ns3-gym/
ns3-ai:
https://apps.nsnam.org/app/ns3-ai/
Another example in the existing codebase is the support for the PyViz
visualizer, which allows the GUI to interact and control the execution
of the ns-3 program (via a VisualSimulatorImpl specialization of the
SimulatorImpl class).
More below...
> lots of wrong terms here so please correct me). _My question is,_
> for approach 2 everything is still on a single thread in sequential
> function calls, and for approach 1 ns-3 on one thread just for
> packet transportation and the external software is on another
> listening on the incoming packets, _so is it possible at all to
> create an implementation that is both approach 1 and approach
> 2?_ That is, is it possible to interact ns3 with the same piece of
> external software via both tap bridge and direct function call?
I don't see why you couldn't use both approaches. Generally the Tap
bridge is for interacting with external processes that are running in
real time; ns-3 either has to be able to read/interpret the packets to
interact with the outside world, or it has to provide transport (sending
packets through a simulated topology without trying to read their contents).
If your application uses SSL transport, and you want to read these
packets in ns-3, you would need SSL support in ns-3 (which I'm not sure
whether anyone has tried).
>
> Or, how would you go about this implementation?
>
Another SDN approach that Jared Ivey followed a few years ago was to use
Direct Code Execution to support the controller directly in ns-3 DCE.
Most controllers are written in Java or Python, while ns-3 DCE is for
C/C++, but Jared was able to build DCE versions of Python and Java and
use those to run the controllers. Unfortunately, I don't think he left
any software artifacts about this, but you can read about this approach
here:
https://dl.acm.org/doi/10.1145/2915371.2915383
Hope this helps,
Tom