[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generating events
> I am at the moment writing an application for ns, I have now come as far
> as to looking at event generation. I need to generate events randomly, the
> randomness I reckon I can sort out by using the random number generator.
> But how can I say that an event is to happend(e.g. sending a packet) in 10
> or n seconds. In other words, how do I do the scheduling of events?
> Can anybody help me?
It depends on whether you are operating at the c++ level or the OTcl
level. I suspect that if you are interested in generating packets at
random times, that you are probably operating at the c++ level. If so,
then a call to the Scheduler::schedule(Handler *h, Event *p) method can be
used to schedule an event. You need to specify a handler for the event -
each packet is an event, so the event argument can simply be the packet.
You are probably putting the packet into a queue, in which case you need
to supply the queue handler as a parameter - this is a data member of the
queue class (although it's private - you could write a method that returns
it, or simply make it public).
In the unlikely event that you are operating at the OTcl level, you can
use the much simpler OTcl
$ns at [defaultRNG uniform $start_time $end_time] "OTcl command"
Hth,
Sean.
-----
Sean Murphy, Email: [email protected]
Teltec Ireland, Phone: +353-1-7045080
DCU, Dublin 9, Fax: +353-1-7045092
Ireland.