implement and use the OnOffApplication default values

Mathieu Lacage 2007-05-14 12:33:17 +02:00
parent 1a70acc7c5
commit 94c5cf7457
3 changed files with 14 additions and 10 deletions

View File

@ -92,7 +92,8 @@ int main (int argc, char *argv[])
// instantiate, when the queue factory is invoked in the topology code // instantiate, when the queue factory is invoked in the topology code
Bind ("Queue", "DropTailQueue"); Bind ("Queue", "DropTailQueue");
Bind ("on-off-app-packet-size", "210"); Bind ("OnOffApplicationPacketSize", "210");
Bind ("OnOffApplicationDataRate", "448kb/s");
//Bind ("DropTailQueue::m_maxPackets", 30); //Bind ("DropTailQueue::m_maxPackets", 30);

View File

@ -38,11 +38,12 @@ using namespace std;
namespace ns3 { namespace ns3 {
// Defaults for rate/size // Defaults for rate/size
DataRate OnOffApplication::g_defaultRate = DataRate(500000); static DataRateDefaultValue g_defaultRate ("OnOffApplicationDataRate",
static IntegerDefaultValue<uint32_t> g_defaultSize ("on-off-app-packet-size", "The data rate in on state for OnOffApplication",
"The size of packets send by OnOffApplication instances", DataRate ("500kb/s"));
static IntegerDefaultValue<uint32_t> g_defaultSize ("OnOffApplicationPacketSize",
"The size of packets sent in on state for OnOffApplication",
512, 1); 512, 1);
// Constructors // Constructors
OnOffApplication::OnOffApplication(Ptr<INode> n, OnOffApplication::OnOffApplication(Ptr<INode> n,
@ -51,7 +52,7 @@ OnOffApplication::OnOffApplication(Ptr<INode> n,
const RandomVariable& ontime, const RandomVariable& ontime,
const RandomVariable& offtime) const RandomVariable& offtime)
: Application(n), : Application(n),
m_cbrRate (g_defaultRate) m_cbrRate (g_defaultRate.GetValue ())
{ {
Construct (n, rip, rport, ontime, offtime, Construct (n, rip, rport, ontime, offtime,
g_defaultSize.GetValue ()); g_defaultSize.GetValue ());
@ -101,6 +102,11 @@ OnOffApplication::SetMaxBytes(uint32_t maxBytes)
m_maxBytes = maxBytes; m_maxBytes = maxBytes;
} }
void
OnOffApplication::SetDefaultRate (const DataRate &rate)
{
g_defaultRate.SetValue (rate);
}
void void
OnOffApplication::SetDefaultSize (uint32_t size) OnOffApplication::SetDefaultSize (uint32_t size)
{ {

View File

@ -81,7 +81,7 @@ public:
void SetMaxBytes(uint32_t maxBytes); void SetMaxBytes(uint32_t maxBytes);
static void DefaultRate(uint64_t r) { g_defaultRate = r;} static void SetDefaultRate(const DataRate & r);
static void SetDefaultSize (uint32_t size); static void SetDefaultSize (uint32_t size);
@ -121,9 +121,6 @@ private:
EventId m_sendEvent; // Eventid of pending "send packet" event EventId m_sendEvent; // Eventid of pending "send packet" event
bool m_sending; // True if currently in sending state bool m_sending; // True if currently in sending state
public:
static DataRate g_defaultRate; // Default sending rate when on
private: private:
void ScheduleNextTx(); void ScheduleNextTx();
void ScheduleStartEvent(); void ScheduleStartEvent();