ns3, Avoiding random value collision

63 views
Skip to first unread message

Dorice Diane Ngueguia

unread,
Dec 17, 2009, 4:51:31 AM12/17/09
to ns-3-...@googlegroups.com
Hi,

I am trying to simulate a network application that uses random values. I have 10 000 nodes and during the simulation, each node can generate up to 100 random integer values. I would like all my 1 000 000 (10 000 nodes * 100 values per node) random integers to be distinct trough the simulation. So this is what I did :

The application installed on each node has a uniform random value,  0..1 000 000
          m_hit_generator = UniformVariable(0, 1000000);
To avoid collisions, I have divided my value space in 10 000 parts of 100 possible integer values. Each application has a parameter named HITRange ( = 0, 1, 2,...9999). So to have a random value from each application I do
          m_tag_hit = m_hit_generator.GetInteger(m_hitRange*100,(m_hitRange+1)*100);
Can see that for the first node, range 0, I will be doing GetInteger(0, 100); for the second node GetInteger(100, 200); for the last GetInteger(9900, 10 000)

I thought it was sufficient to avoid collision, but I am still having redundancy.

Does someone know what I should do ?

Tank.

francesco

unread,
Dec 17, 2009, 4:20:52 PM12/17/09
to ns-3-users
Are you having collisions on the border values, such as 100, 200...?
If this is the case, it's due to the fact that the return value of
GetInteger(a,b) falls in [a,b], including both ends; so the intervals
GetInteger is called on every nodes do overlap.
In other words, consider adding a "-1" somewhere, in order to call
GetInteger(0,99) on node 0, GetInteger(100,199) on node 2 and so on.

vaibhav tayal

unread,
Dec 19, 2009, 12:17:10 PM12/19/09
to ns-3-...@googlegroups.com
how do you will get to know about those collisions...
Regards
Vaibhav Tayal



--

You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.



Mathieu Lacage

unread,
Dec 20, 2009, 2:52:48 AM12/20/09
to ns-3-...@googlegroups.com

A random distribution of numbers is not a set of unique numbers. What you appear to want is a random permutation of a fixed set of numbers. My knuth book explains how to do this but wikipedia has a nice discussion of this topic:

http://en.wikipedia.org/wiki/Random_permutation
http://en.wikipedia.org/wiki/Knuth_shuffle

Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>

vaibhav tayal

unread,
Dec 22, 2009, 9:56:40 AM12/22/09
to ns-3-...@googlegroups.com
Can you please elaborate your explaination??


Regards
Vaibhav Tayal


Mathieu Lacage

unread,
Dec 26, 2009, 12:30:17 PM12/26/09
to ns-3-...@googlegroups.com
On Tue, Dec 22, 2009 at 3:56 PM, vaibhav tayal <vaibhav...@gmail.com> wrote:
Can you please elaborate your explaination??

Did you read the wikipedia articles I pointed out ?
--
Mathieu Lacage <mathieu...@gmail.com>
Reply all
Reply to author
Forward
0 new messages