Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

help for simulation code

simulation

  • Please log in to reply
11 replies to this topic

#1 DeSiGneR

DeSiGneR

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 25 October 2008 - 06:37 AM

Hi there...

I try to write a program to simulate a wireless network WLAN

Let us suppose that the network consists of 5 nodes (A to E) and the simulation time is 300 seconds.

Also, let us assume the algorithm used as follow: when a node intents to send, it checks the receiver status. If it is a free which means it does not receive or send data from another node, the node starts transmission. If not it delay for a while then try a gain.

let's take the simple scenario:

at T=2 (second no. 2) node A starts sending to B.

at T=3, node C want to send to B. It will check the receiver status and then find the node B is busy. So, it will defer the transmission for a period of time then start a gain.

My question is: I want a way to pick up a transmitter and receiver randomly during simulation time.

for example, at t=4 A sends to C
at t=4.5 D sends to B and so on.

Thank you very much in advance.
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 25 October 2008 - 01:48 PM

It sounds like you'll need a random number generator.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 DeSiGneR

DeSiGneR

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 25 October 2008 - 06:46 PM

Not exact..

I have one... but I don't know how can I use it?!!
  • 0

#4 Steve.L

Steve.L

    CC Addict

  • Member
  • PipPipPipPipPip
  • 382 posts
  • Location:Kingston, Canada
  • Programming Language:C, Java, C++, PHP, Python, Ruby, PL/SQL, Delphi/Object Pascal, Lisp, Pascal, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 25 October 2008 - 07:40 PM

Then you need to RTFM.
  • 0

#5 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 25 October 2008 - 08:38 PM

Are you asking how to use a random number generator, or how to use it to solve your problem?
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#6 DeSiGneR

DeSiGneR

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 25 October 2008 - 08:44 PM

I am asking how to use it to solve your problem?!!
  • 0

#7 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 25 October 2008 - 09:10 PM

You will need a list of inactive nodes. Count those nodes and generate a random number between 1 and n (the number of inactive nodes). That node becomes the new transmitter.

Next you will need a list of all the nodes except the transmitter. Generate another random number between 1 and m (the number of other nodes). That node becomes the new desired receiver.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#8 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 25 October 2008 - 09:10 PM

You will need a list of inactive nodes. Count those nodes and generate a random number between 1 and n (the number of inactive nodes). That node becomes the new transmitter.

Next you will need a list of all the nodes except the transmitter. Generate another random number between 1 and m (the number of other nodes). That node becomes the new desired receiver.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#9 DeSiGneR

DeSiGneR

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 25 October 2008 - 09:21 PM

Ok ... but that means I simulate one transmission (between one transmitter and one receiver) .

what about the others nodes? Are they still inactive ?!!

I want simulate a number of transmitter and receivers at the same time
  • 0

#10 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 26 October 2008 - 02:23 PM

How many are going to be starting at any given second? You will need to model which ones are busy, of course.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#11 DeSiGneR

DeSiGneR

    CC Lurker

  • Just Joined
  • Pip
  • 5 posts

Posted 27 October 2008 - 05:38 AM

at any given second, there is a random number of nodes will transmit or receive. maybe there are 3, 4 or maybe just 1

this is my problem, how can i do this?

think for your helping
  • 0

#12 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 27 October 2008 - 07:50 AM

I think you need a clearer specification of the desired behavior then. It was not clear to me that multiple nodes could start sending at the same time.

For any second, there are several possibilities that I can imagine:
1) a node is busy (sending or receiving data)
2) a node is doing nothing
3) a node wants to initiate a new send activity
4) a node wants to send but is waiting for the desired recipient to be free

In case 2, we can simply have each node randomly switch state to 3.
After processing those that switched to state 3, for each node we can randomly select a desired target node and set remaining wait time to 0
After processing those in state 3, we can look at all those waiting with wait time 0 and attempt to initiate a send. On failure, set the wait time to some positive value.

The key to getting ANY program to work is moving from a general description of behavior, "I want a simulator where nodes can try to contact other nodes to send data," to more precise descriptions of behavior, "I want a simulator with n nodes, where each non-busy node has an n% chance if initiating a transmission and will wait a-b seconds if the initiationg fails before re-initiating the transmission".
Usually, a precise description will resolve many of your questions about how to implement the program, because the description reduces the number of options down to something very simple.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/






Also tagged with one or more of these keywords: simulation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download