OnOffApplication

3,520 views
Skip to first unread message

Giovanna Garcia

unread,
Apr 5, 2013, 12:48:53 PM4/5/13
to ns-3-...@googlegroups.com
Hi everyone!
I am using OnOffHelper to create the application but, I had configured the onTime like this:

std::ostringstream onTime;
        onTime << "ns3::ConstantRandomVariable[Constant=" << on << "]";
        std::ostringstream offTime;
        offTime << "ns3::ConstantRandomVariable[Constant=" << off << "]";
OnOffHelper onoffUe0 (socketFactory, Address ()); // Address() - Create an invalid address
        onoffUe0.SetAttribute ("OnTime", StringValue (onTime.str()));
        onoffUe0.SetAttribute ("OffTime", StringValue (offTime.str()));


and, the output:

7.80563s OnOffApplication:ScheduleNextTx(): nextTime = +3125000.0ns

It was not using the correct param.

I need that the ONOff generates the application by seconds.

Could someone show me how to set onoffApp OnTime and OffTime?

I had tried somethings like this:

OnOffHelper onoffUe0 (socketFactory, Address ()); // Address() - Create an invalid address

        onoffUe0.SetAttribute ("OnTime",  UniformRandomVariable(on,on));
        onoffUe0.SetAttribute ("OffTime", UniformRandomVariable(off,off));

but I got an error.



Thank you!
----------------------------------------------------------------------
   _     [GGarciaBas @ mail ~] $ uname --information 
  °v°     > Giovanna Garcia
 /(_)\    > Student at the Universidade Tecnológica Federal do Paraná
  ^ ^     > +55 45 9931-3158 (TIM)

 FREEDOM, BE FREE!
----------------------------------------------------------------------

Konstantinos

unread,
Apr 5, 2013, 1:17:05 PM4/5/13
to ns-3-...@googlegroups.com
From the doxygen:
Generate traffic to a single destination according to an OnOff pattern.

This traffic generator follows an On/Off pattern: after Application::StartApplication is called, "On" and "Off" states alternate. The duration of each of these states is determined with the onTime and the offTime random variables. During the "Off" state, no traffic is generated. During the "On" state, cbr traffic is generated. This cbr traffic is characterized by the specified "data rate" and "packet size".

Note: When an application is started, the first packet transmission occurs after a delay equal to (packet size/bit rate). Note also, when an application transitions into an off state in between packet transmissions, the remaining time until when the next transmission would have occurred is cached and is used when the application starts up again. Example: packet size = 1000 bits, bit rate = 500 bits/sec. If the application is started at time 3 seconds, the first packet transmission will be scheduled for time 5 seconds (3 + 1000/500) and subsequent transmissions at 2 second intervals. If the above application were instead stopped at time 4 seconds, and restarted at time 5.5 seconds, then the first packet would be sent at time 6.5 seconds, because when it was stopped at 4 seconds, there was only 1 second remaining until the originally scheduled transmission, and this time remaining information is cached and used to schedule the next transmission upon restarting.


The default times for on and off are 1 (ns3::ConstantRandomVariable[Constant=1.0]).

If you want just to send constantly packets (CBR traffic) you have only to set the off time 0. If for example you want 1 packet/sec, set the data rate equal to the packet size (e.g. packet 500B, datarate 500Bps).
If you want a variable rate you set on and off with random variables.

Giovanna Garcia

unread,
Apr 5, 2013, 2:06:41 PM4/5/13
to ns-3-...@googlegroups.com
Thank you, Konstantinos!
=D

Thank you!
----------------------------------------------------------------------
   _     [GGarciaBas @ mail ~] $ uname --information 
  °v°     > Giovanna Garcia
 /(_)\    > Student at the Universidade Tecnológica Federal do Paraná
  ^ ^     > +55 45 9931-3158 (TIM)

 FREEDOM, BE FREE!
----------------------------------------------------------------------


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

Prosper

unread,
Jul 17, 2013, 5:49:13 AM7/17/13
to ns-3-...@googlegroups.com
Hey Konstantinos,
Could you please help to clear my doubts?

On Saturday, 6 April 2013 02:17:05 UTC+9, Konstantinos wrote:
From the doxygen:
Generate traffic to a single destination according to an OnOff pattern.

This traffic generator follows an On/Off pattern: after Application::StartApplication is called, "On" and "Off" states alternate. The duration of each of these states is determined with the onTime and the offTime random variables. During the "Off" state, no traffic is generated. During the "On" state, cbr traffic is generated. This cbr traffic is characterized by the specified "data rate" and "packet size".

Note: When an application is started, the first packet transmission occurs after a delay equal to (packet size/bit rate). Note also, when an application transitions into an off state in between packet transmissions, the remaining time until when the next transmission would have occurred is cached and is used when the application starts up again. Example: packet size = 1000 bits, bit rate = 500 bits/sec. If the application is started at time 3 seconds, the first packet transmission will be scheduled for time 5 seconds (3 + 1000/500) and subsequent transmissions at 2 second intervals. If the above application were instead stopped at time 4 seconds, and restarted at time 5.5 seconds, then the first packet would be sent at time 6.5 seconds, because when it was stopped at 4 seconds, there was only 1 second remaining until the originally scheduled transmission, and this time remaining information is cached and used to schedule the next transmission upon restarting.


The default times for on and off are 1 (ns3::ConstantRandomVariable[Constant=1.0]).

If you want just to send constantly packets (CBR traffic) you have only to set the off time 0. If for example you want 1 packet/sec, set the data rate equal to the packet size (e.g. packet 500B, datarate 500Bps).
Does this mean setting onTime = 1 and OffTime = 1 will lead to variable rate traffic?

I thought CBR means: bits are sent out at a constant rate. And this is context(onTime =1, offTime =0) it simply means the sending of bits will be continuous(non stop) because the offTime is zero(i.e there is no time duration over which the application is OFF).

On the other hand, setting onTime=1 and offTime = 1, means the application will be alternating between sending bits(onTime = 1)  and pausing the sending of bits(offTime =1). That is to say, over the duration of every second the application will be sending a stream of bits(at constant rate) and over the next second the application will be OFF(sending no bits at all). This also results in a CBR traffic.

In both cases, the behaviour of the traffic is determined by the configured data rate and packet size as the documentation says. This is to say: one does NOT HAVE to set offTime =0 to get CBR traffic, right?



 

Konstantinos

unread,
Jul 17, 2013, 6:55:28 AM7/17/13
to ns-3-...@googlegroups.com
It depends how you define a CBR.

If for example you want 20kbps constantly as a CBR, then putting OffTime a non-zero value will result in a flow that is not 20kbps constantly.

However, if you set On/Off times as constant, non-zero values you can find a "pattern" in the flow. Your flow will be a 'pulse'. I don't think that this is defined as a CBR based on the previous definition. 

Prosper

unread,
Jul 17, 2013, 8:17:18 AM7/17/13
to ns-3-...@googlegroups.com
Ok.Thank you for the quick response Konstantinos.
If I got your point right: as for constantly, you mean continuously constant from when the application starts to when it ends. 
Well, I tried to google and found this: http://goo.gl/Hs1p2 from which I gather that, "the pulse" might be CBR traffic as well.
I'll keep searching and I find something good will get back....
Thank you so much.

Zahra Nasr

unread,
Feb 1, 2014, 3:57:30 AM2/1/14
to ns-3-...@googlegroups.com


If you want just to send constantly packets (CBR traffic) you have only to set the off time 0. If for example you want 1 packet/sec, set the data rate equal to the packet size (e.g. packet 500B, datarate 500Bps).
If you want a variable rate you set on and off with random variables.

Dear Konstantinos 
 I want simulate VoIP traffic and UDP and TCP with OnOffApplication
Assumptions based paper:

1.     The VoIP traffic is

a.     modeled as CBR traffic

b.     With 208 bytes frame payload size

c.      And 20 ms packet generation interval

d.     Assuming G.711 voice codec without silence suppression.

2.     where each TCP/UDP flow

a.     has 2 Mb/s traffic load from the application layer

b.     with 1508 byte frame payload size


I simulated those with OnOffApplication but i have some vague point in simulation 

//first VoIP traffic
  // VoIP receiver--- 
  Address remoteAddress4 = InetSocketAddress(wifiInterfaces.GetAddress (6), 4000);
  PacketSinkHelper receiver4 ("ns3::UdpSocketFactory", remoteAddress4);
  ApplicationContainer receiverapp4 =receiver4.Install(wifiStaNodes.Get (6));
  receiverapp4.Start (Seconds (5.0));
  receiverapp4.Stop (Seconds (10.0));
  
  // VoIP Sender ---- 
  OnOffHelper sender4("ns3::UdpSocketFactory", remoteAddress4);
    sender4.SetConstantRate( DataRate("65.625Kbps") , 208 );
sender4.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
    sender4.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
  ApplicationContainer senderapps4 = sender4.Install(wifiStaNodes.Get(5));
  senderapps4.Start(Seconds(5.0));
  senderapps4.Stop(Seconds(10.0)); 
1.you explained but I completely do not understand, so what do i ? packet size  in my paper 208B and i calculated data rate base it  that is 65.625kbps
please help me




Zahra Nasr

unread,
Feb 1, 2014, 4:08:46 AM2/1/14
to ns-3-...@googlegroups.com
Hi everyone
how do i calculate data rate and packet size for CBR traffic According to assumptions? and  how do i set Ontime and Oftime for CBR and TCP?
please help me

 

Tommaso Pecorella

unread,
Feb 1, 2014, 6:57:33 AM2/1/14
to ns-3-...@googlegroups.com
Hi,

sorry if this sounds strange, but the only answer is:
1) you do some assumptions,
2) you consider what you want to measure (application-level, L4, L3, MAC, PHY?)
3) you do some math
4) you obtain the results.

The results might be correct or not, it depends if you can take into account everything. E.g., TCP's willingness to build a MTU-size packet, etc.

The simulation will tell you if your calc is right.
Simple, isn't it ? It is, and if you can't do it... then you either did incomplete assumptions, or you didn't take into account the headers size.

Cheers,

T.

moudan2012

unread,
Jul 2, 2014, 8:34:07 AM7/2/14
to ns-3-...@googlegroups.com
hallo, Mr Konstantinos:
if i want to just set offtime 0 for constant datatransmission:
is this instruction correct?
  OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));//the code in wifi-ap.cc
onoff.SetAttribute ("OffTime",0);//to set OffTime 0

I do not know how to set Off Time, can you send me the instruction to my email?(mouda...@hotmail.com)
with best regards
Dan 
02.07.2014

在 2013年7月17日星期三UTC+2下午12时55分28秒,Konstantinos写道:
Reply all
Reply to author
Forward
0 new messages