Interacting with UDP Simulation Software Using Your Own Code
Environment
I used Windows 10 x64 for this example, although the operating system should not make much difference. The programs are written in Python. I will use the two simulated devices from the first stage to demonstrate the exchange.
Start two instances of the simulator. In the first, select Device 1 Interface 0; in the second, select Device 2 Interface 0. Click Reload parameters in each window to populate its settings:

On both instances, click Connect link and then Test connectivity. I tried sending a few pieces of data between them and confirmed that the link worked:

Understanding the ports

How they relate
Before writing the programs, it helps to understand which ports talk to which. Here is the analogy I used.
Think of the upper-layer port as a boss and the physical layer as its messenger. The boss hands over a message; the messenger does not interpret it, but carries it to its destination. The simulator’s remote port setting tells that messenger where to deliver it.
For example, suppose software 1’s upper layer sends 11111111 to software 2. It hands the data to its own physical-layer local port 11100. Since the remote port is set to 12100, that layer forwards the data to port 12100 on software 2’s physical layer.
When software 2’s physical layer receives the data, it passes the message up to its boss: upper-layer port 12400.
That completes the path from the first upper-layer port to the second.
What tells software 1 that the packet arrived? Nothing in this exchange: the simulator sends it over UDP, which does not itself confirm delivery.
Python implementation
With that path in mind, we can write two programs. Each binds to one upper-layer port; the connected simulated physical ports carry the data between them.
Software 1
1 | import socket |
Software 2
1 | import socket |
Save the programs as 1.py and 2.py and run them in powershell. That is simply my preferred way to run socket programs; cmd or another environment works too. Here is the result:

The two windows separately:


The output suggests that software 2 received the message from software 1. The simulator’s status information shows the exchange as well:

We have now sent a UDP packet through the simulator from our own code.
Next, let’s reverse the direction: software 2 will send and software 1 will receive. Since the bit-string test worked, I changed the Python scripts to try a text message.
Software 1
1 | import socket |
Software 2
1 | import socket |
Start 1.py in one powershell window so the receiver is waiting, then run 2.py in a second window:

The simulator’s port display looks like this:

The receiver shows garbled characters because frame synchronization has not yet been performed. I will leave that topic for later.
There are other things to experiment with. For example, I later set software 1’s remote address directly to software 2’s upper-layer address; I will leave out the implementation details here.

That worked too. In the earlier analogy, software 1’s messenger delivered the message straight to software 2’s boss.
That wraps up the experiment! (●ˇ∀ˇ●)