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
Bind ("Queue", "DropTailQueue");
Bind ("on-off-app-packet-size", "210");
Bind ("OnOffApplicationPacketSize", "210");
Bind ("OnOffApplicationDataRate", "448kb/s");
//Bind ("DropTailQueue::m_maxPackets", 30);

View File

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

View File

@ -81,7 +81,7 @@ public:
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);
@ -121,9 +121,6 @@ private:
EventId m_sendEvent; // Eventid of pending "send packet" event
bool m_sending; // True if currently in sending state
public:
static DataRate g_defaultRate; // Default sending rate when on
private:
void ScheduleNextTx();
void ScheduleStartEvent();