Suppose a scenario similar to the above image where Node-A and Node-B are sending data to Node-D via Node-C. Node-A and Node-B each sent one data packet to Node-D. Node-A sent one msg with msg-id = 1 which is received at Node-C with msg-id = 1 and Node-B sent one msg with msg-id = 3 which is received at node-C with msg-id = 3. Now, how I will get to know that the msg forwarded from Node-C with msg-id = 2 is the msg from Node-A or Node-B and msg forwarded from Node-C with msg-id = 4 is the msg from Node-A or Node-B? How I will follow the correct path while traversing the trace.json file of simulation?
The trace.json
file has information about the thread of events and stimulus that is related to each event. This may provide you the relevant information for your tracing.
To illustrate the idea, I take an example of how the ranging
agent works. Other agents such as router
work similarly, so you can use the same idea for tracing routed frames.
See the following entry from a trace.json
output of a ranging simulation:
{
"time":1645606042088,
"component":"ranging::org.arl.unet.localization.Ranging/A",
"threadID":"88b89b82-eb37-4ac5-83da-3695acb80e7f",
"stimulus":{"clazz":"org.arl.unet.phy.RxFrameNtf","messageID":"88b89b82-eb37-4ac5-83da-3695acb80e7f","performative":"INFORM","sender":"phy","recipient":"#phy__ntf"},
"response":{"clazz":"org.arl.unet.phy.TxFrameReq","messageID":"ee9f72f5-5753-4d46-a885-9e446bbf9746","performative":"REQUEST","recipient":"phy"}
}
This entry shows that the received frame (RxFrameNtf
) with ID 88b89b82...
caused the transmission of a new frame (TxFrameReq
) with ID ee9f72f5...
. The threadID
entry can also be helpful, as the same threadID
is maintained for the whole chain of events within a single node.
Each of your frames from nodes A and B will have unique IDs, and so will each of the frames relayed by node C. The trace.json
entry corresponding to each relay transmission should tell you which stimulus
(frame from node A or B) resulted in the transmission.
For your application, I extract a few of the JSON entries from your trace.json
to illustrate this:
{
"time":10000, "component":"router::org.arl.unet.net.Router/A", "threadID":"2e37d6d6-a3d2-4e0f-aacc-456efdae91bb",
"stimulus":{"clazz":"org.arl.unet.DatagramReq", "messageID":"2e37d6d6-a3d2-4e0f-aacc-456efdae91bb", "performative":"REQUEST", "sender":"simulator", "recipient":"router"},
"response":{"clazz":"org.arl.unet.DatagramReq", "messageID":"54a55a12-4051-4934-88bc-beb4fa28c548", "performative":"REQUEST", "recipient":"uwlink"}
}
{
"time":10491, "component":"uwlink::org.arl.unet.link.ReliableLink/A", "threadID":"54a55a12-4051-4934-88bc-beb4fa28c548",
"stimulus":{"clazz":"org.arl.unet.DatagramReq", "messageID":"54a55a12-4051-4934-88bc-beb4fa28c548", "performative":"REQUEST", "sender":"router", "recipient":"uwlink"},
"response":{"clazz":"org.arl.unet.phy.TxFrameReq", "messageID":"87757d67-7510-4856-a9ee-a27924f9548a", "performative":"REQUEST", "recipient":"phy"}
}
{
"time":10491, "component":"phy::org.arl.unet.sim.HalfDuplexModem/A", "threadID":"87757d67-7510-4856-a9ee-a27924f9548a",
"stimulus":{"clazz":"org.arl.unet.phy.TxFrameReq", "messageID":"87757d67-7510-4856-a9ee-a27924f9548a", "performative":"REQUEST", "sender":"uwlink", "recipient":"phy"},
"response":{"clazz":"org.arl.unet.sim.HalfDuplexModem$TX", "messageID":"31b892fd-1b2c-40b1-a1d6-4dc457f57a2c", "performative":"INFORM", "recipient":"phy"}
}
{
"time":11870, "component":"phy::org.arl.unet.sim.HalfDuplexModem/C", "threadID":"31b892fd-1b2c-40b1-a1d6-4dc457f57a2c",
"stimulus":{"clazz":"org.arl.unet.sim.HalfDuplexModem$TX", "messageID":"31b892fd-1b2c-40b1-a1d6-4dc457f57a2c", "performative":"INFORM", "sender":"phy", "recipient":"phy"},
"response":{"clazz":"org.arl.unet.phy.RxFrameNtf", "messageID":"5cd195ef-74b0-4394-8f9a-9077de08bc56", "performative":"INFORM", "sender":"phy", "recipient":"#phy__ntf"}
}
{
"time":11870, "component":"router::org.arl.unet.net.Router/C", "threadID":"5cd195ef-74b0-4394-8f9a-9077de08bc56",
"stimulus":{"clazz":"org.arl.unet.phy.RxFrameNtf", "messageID":"5cd195ef-74b0-4394-8f9a-9077de08bc56", "performative":"INFORM", "sender":"phy", "recipient":"#phy__ntf"},
"response":{"clazz":"org.arl.unet.DatagramReq", "messageID":"e9ecfc32-ff9a-4750-99d5-b3b462dcd660", "performative":"REQUEST", "recipient":"uwlink"}
}
{
"time":12259, "component":"uwlink::org.arl.unet.link.ReliableLink/C", "threadID":"e9ecfc32-ff9a-4750-99d5-b3b462dcd660",
"stimulus":{"clazz":"org.arl.unet.DatagramReq", "messageID":"e9ecfc32-ff9a-4750-99d5-b3b462dcd660", "performative":"REQUEST", "sender":"router", "recipient":"uwlink"},
"response":{"clazz":"org.arl.unet.phy.TxFrameReq", "messageID":"76200f60-2334-4f20-88a3-9c2d42a769ad", "performative":"REQUEST", "recipient":"phy"}
}
{
"time":12259, "component":"phy::org.arl.unet.sim.HalfDuplexModem/C", "threadID":"76200f60-2334-4f20-88a3-9c2d42a769ad",
"stimulus":{"clazz":"org.arl.unet.phy.TxFrameReq", "messageID":"76200f60-2334-4f20-88a3-9c2d42a769ad", "performative":"REQUEST", "sender":"uwlink", "recipient":"phy"},
"response":{"clazz":"org.arl.unet.sim.HalfDuplexModem$TX", "messageID":"f3161e4e-1007-4540-8192-f0d7bf80e126", "performative":"INFORM", "recipient":"phy"}
}
{
"time":13542, "component":"phy::org.arl.unet.sim.HalfDuplexModem/D", "threadID":"f3161e4e-1007-4540-8192-f0d7bf80e126",
"stimulus":{"clazz":"org.arl.unet.sim.HalfDuplexModem$TX", "messageID":"f3161e4e-1007-4540-8192-f0d7bf80e126", "performative":"INFORM", "sender":"phy", "recipient":"phy"},
"response":{"clazz":"org.arl.unet.phy.RxFrameNtf", "messageID":"ab5e15a9-27e0-4495-b0b8-f199159cb2a3", "performative":"INFORM", "sender":"phy", "recipient":"#phy__ntf"}
}
{
"time":13542, "component":"uwlink::org.arl.unet.link.ReliableLink/D", "threadID":"ab5e15a9-27e0-4495-b0b8-f199159cb2a3",
"stimulus":{"clazz":"org.arl.unet.phy.RxFrameNtf", "messageID":"ab5e15a9-27e0-4495-b0b8-f199159cb2a3", "performative":"INFORM", "sender":"phy", "recipient":"#phy__ntf"},
"response":{"clazz":"org.arl.unet.DatagramNtf", "messageID":"bb534fc0-47ec-4b2d-8124-07af87528d37", "performative":"INFORM", "recipient":"#uwlink__ntf"}
}
{
"time":13542, "component":"router::org.arl.unet.net.Router/D", "threadID":"bb534fc0-47ec-4b2d-8124-07af87528d37",
"stimulus":{"clazz":"org.arl.unet.DatagramNtf", "messageID":"bb534fc0-47ec-4b2d-8124-07af87528d37", "performative":"INFORM", "sender":"uwlink", "recipient":"#uwlink__ntf"},
"response":{"clazz":"org.arl.unet.DatagramNtf", "messageID":"5e660793-9a44-4341-8843-fc7fa91aa450", "performative":"INFORM", "recipient":"#router__ntf"}
}
These entries show the sequence of events that occurred:
10000
: DatagramReq
from router@A
to uwlink@A
10491
: TxFrameReq
from uwlink@A
to phy@A
10491
: TX
from phy@A
to phy@C
11870
: RxFrameNtf
from phy@C
(publish on topic)11870
: DatagramReq
from router@C
to uwlink@C
12259
: TxFrameReq
from uwlink@C
to phy@C
12259
: TX
from phy@C
to phy@D
13542
: RxFrameNtf
from phy@D
(publish on topic)13542
: DatagramNtf
from uwlink@D
(publish on topic)13542
: DatagramNtf
from router@D
(publish on topic)You should find that each JSON entry's response.messageID
corresponds to the next JSON entry's stimulus.messageID
. This allows you to follow through the sequence of events.