[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: issue on class TrafficGenerator: improvement?
Joerg,
Thanks for your suggested improvement-- I've changed the code in the
repository accordingly.
Tom
On Fri, 25 Jun 1999, Joerg Diederich wrote:
>
> I would suggest to add two small things to the above code to avoid
> this behaviour:
>
> At first, calling stop, when the traffic generator is not running,
> should not lead to an abort of the tcl interpreter, which can be
> avoided by adding one line to stop() as shown below.
>
> Second, the traffic generator must go into 'not running' state
> (running_ = 0), when next_interval() does not give another time to
> schedule the next packet. In this way, a later call to stop() will not
> cause an abort.
>
> ---------------
> void TrafficGenerator::stop()
> {
> /* added JD */
> if (running_)
> /* added end */
> timer_.cancel();
>
> running_ = 0;
> }
>
>
> void TrafficGenerator::timeout()
> {
> if (! running_)
> return;
>
> /* send a packet */
> send(size_);
> /* figure out when to send the next one */
> nextPkttime_ = next_interval(size_);
> /* schedule it */
> if (nextPkttime_ > 0)
> timer_.resched(nextPkttime_);
> /* added JD */
> else
> running_ = 0;
> /* added JD end */
> }