0

I want to stop transmission of packets in between and want to start transmission again after some time. Also I want to calculate total simulation time ( before stopping, during stopping plus after resuming) how can I do that?

ykaragol
  • 5,800
  • 3
  • 23
  • 51
  • Please stick to a single issue per question. It's not possible to decide whether an answer is correct if multiple questions are asked at the same time. – Rudi Jun 08 '16 at 09:19

1 Answers1

0

This is a variation of the "How to change a parameter value over time?" question.

Let's assume that you want to send packets between 0 and 20s with exp(300ms) inter arrival time. At 20s you want to stop sending the packets and then resume sending the packets at 60s again, but with exp(200ms) inter arrival time.

For volatile parameters you can use the ? : operator (chained) along with the simTime() NED function to change the returned inter arrival time based on the actual simulation time:

**.interArrivalTime = simTime() < 20s ? exponential(300ms) : 
  simTime() < 60s ? 60s-simTime() : exponential(200ms)

The interesting part is the 60s-simTime() expression which actually returns the inter arrival time in a way that the next packet will be generated exactly at 60s (i.e. at simTime() + (60s-simTime()))

Rudi
  • 4,880
  • 1
  • 14
  • 19