Randomness on different computers

18 views
Skip to first unread message

Eduardo Freitas

unread,
Nov 19, 2025, 6:18:36 AM (yesterday) Nov 19
to ns-3-...@googlegroups.com
Hello, everyone.
I've been writing some 5G experiments on my laptop, using a modified
version of cttc-nr-demo.cc. I used random uniform variables throughout
the code (as the original does) to ensure statistical validity, and when
running multiple experiments with -- --RngSeed=1 --RngRun=1, for
example, the results were the same, as expected.

After this, I sent the code to a VM on our lab's server to run multiple
executions with varying seeds and runs. However, it yielded different
results (server RTT and throughput, as well as UE's CQI) when compared
to my laptop. I even tested an isolated execution with the same
parameters (and seeds/runs), and the results from my laptop are
different from the VM's.

What I've checked so far is: I used the same script to clone ns-3 and
enter the right version (3.46 and LENA's 4.1.1). I have diffed src/ and
scratch/ and contrib/ and the directories are the same. I checked that
when looking at the mobility pattern of the UEs, they move the same way
on both my laptop and VM, but the network results are different. When I
run the same execution on the VM, the results are the same.

Is there something I'm missing? What could cause differences from
different machines but same results on the same machine? I didn't attach
the script since it is too large, but examples of random variables I use
are:

// used to place UEs
Ptr<UniformRandomVariable> longitudeX =
CreateObject<UniformRandomVariable>();
---
randomStream += nrHelper->AssignStreams(gnbNetDev, randomStream);
---
mobility.SetMobilityModel("ns3::RandomWalk2dOutdoorMobilityModel", ...)


--
Thank you for your time,
Eduardo Freitas

Gabriel Ferreira

unread,
Nov 19, 2025, 1:27:57 PM (22 hours ago) Nov 19
to ns-3-users
You are not. This can indeed happen. And the reason is most likely is a feature was enabled in one build and not in other.
We have this problem, with multiple random streams being silently not assigned, and they get shifted around if more random streams are statically initialized, or initialized in a different order.
This is a longstanding issue that we have been slowly addressing, but it is tough to completely fix. See 

https://gitlab.com/nsnam/ns-3-dev/-/work_items/1248
https://gitlab.com/nsnam/ns-3-dev/-/issues/1274
https://gitlab.com/nsnam/ns-3-dev/-/issues/586
https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/2497

Tom Henderson

unread,
Nov 19, 2025, 4:35:08 PM (19 hours ago) Nov 19
to ns-3-...@googlegroups.com

In general, what you describe could be due to different libraries supported on the VM vs. the laptop; particularly the Eigen3 dependency.  Do you see these configure outputs reported the same on both machines?

SQLite support                : ON
Eigen3 support                : ON

Do you see a different list of modules enabled for each machine? ("Modules configured to be built:")

If the libraries on each machine are the same and the code is the same, and modules enabled are the same, and you use the ns-3 random variable system for all randomness, then I would expect the results to be the same.

- Tom

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ns-3-users/d64a8049-b3d4-4c94-a6c3-7c05d9122c89n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages