Make queues copyable; change p2p-topology.cc to reflect this
parent
39d15f6f7e
commit
a3663bc40c
|
@ -209,9 +209,17 @@ int main (int argc, char *argv[])
|
|||
DebugComponentEnable("PointToPointNetDevice");
|
||||
DebugComponentEnable("PointToPointPhy");
|
||||
#endif
|
||||
|
||||
ObjectContainer container;
|
||||
|
||||
// Optionally, specify some default values for Queue objects.
|
||||
// For this example, we specify that we want each queue to
|
||||
// be a DropTail queue, with a limit of 30 packets.
|
||||
// Specify DropTail for default queue type (note. this is actually
|
||||
// the default, but included here as an example).
|
||||
Queue::Default(DropTailQueue());
|
||||
// Specify limit of 30 in units of packets.
|
||||
// Queue::Default().SetLimitPackets(30);
|
||||
|
||||
// The node factory is designed to allow user specification
|
||||
// of the "type" of node desired for each node creation. This
|
||||
// is done by creating a node object (the inNode below), configuring
|
||||
|
|
|
@ -57,10 +57,8 @@ PointToPointTopology::AddPointToPointLink(
|
|||
Ipv4Mask netmask("255.255.255.252");
|
||||
NS_ASSERT (netmask.IsMatch(addra,addrb));
|
||||
|
||||
DropTailQueue* dtqa = new DropTailQueue();
|
||||
|
||||
PointToPointNetDevice* neta = new PointToPointNetDevice(a);
|
||||
neta->AddQueue(dtqa);
|
||||
neta->AddQueue(Queue::Default().Copy());
|
||||
Ipv4Interface *interfA = new ArpIpv4Interface (a, neta);
|
||||
uint32_t indexA = a->GetIpv4 ()->AddInterface (interfA);
|
||||
neta->Attach (channel);
|
||||
|
@ -69,10 +67,8 @@ PointToPointTopology::AddPointToPointLink(
|
|||
interfA->SetNetworkMask (netmask);
|
||||
interfA->SetUp ();
|
||||
|
||||
DropTailQueue* dtqb = new DropTailQueue();
|
||||
|
||||
PointToPointNetDevice* netb = new PointToPointNetDevice(b);
|
||||
netb->AddQueue(dtqb);
|
||||
netb->AddQueue(Queue::Default().Copy());
|
||||
Ipv4Interface *interfB = new ArpIpv4Interface (b, netb);
|
||||
uint32_t indexB = b->GetIpv4 ()->AddInterface (interfB);
|
||||
netb->Attach (channel);
|
||||
|
|
|
@ -24,6 +24,14 @@ NS_DEBUG_COMPONENT_DEFINE ("DropTailQueue");
|
|||
|
||||
namespace ns3 {
|
||||
|
||||
static class QueueStackInitializationClass {
|
||||
public:
|
||||
QueueStackInitializationClass () {
|
||||
Queue::Default (DropTailQueue ());
|
||||
}
|
||||
} queue_stack_initialization_class;
|
||||
|
||||
|
||||
DropTailQueue::DropTailQueue () :
|
||||
Queue (),
|
||||
m_packets (),
|
||||
|
@ -37,6 +45,11 @@ DropTailQueue::~DropTailQueue ()
|
|||
NS_DEBUG("DropTailQueue::~DropTailQueue ()");
|
||||
}
|
||||
|
||||
DropTailQueue* DropTailQueue::Copy() const
|
||||
{
|
||||
return new DropTailQueue(*this);
|
||||
}
|
||||
|
||||
void
|
||||
DropTailQueue::SetMaxPackets (uint32_t npackets)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
DropTailQueue ();
|
||||
|
||||
virtual ~DropTailQueue();
|
||||
virtual DropTailQueue* Copy() const;
|
||||
|
||||
void SetMaxPackets (uint32_t npackets);
|
||||
uint32_t GetMaxPackets (void);
|
||||
|
|
|
@ -25,6 +25,8 @@ NS_DEBUG_COMPONENT_DEFINE ("Queue");
|
|||
|
||||
namespace ns3 {
|
||||
|
||||
Queue* Queue::defaultQueue = 0;
|
||||
|
||||
Queue::Queue() :
|
||||
m_nBytes(0),
|
||||
m_nTotalReceivedBytes(0),
|
||||
|
@ -182,4 +184,20 @@ Queue::Drop (const Packet& p)
|
|||
m_traceDrop (p);
|
||||
}
|
||||
|
||||
// Static methods for managing default queue
|
||||
|
||||
// Set new default
|
||||
void Queue::Default(const Queue& q)
|
||||
{
|
||||
delete defaultQueue; // delete previous (if any)
|
||||
defaultQueue = q.Copy(); // set new default
|
||||
}
|
||||
|
||||
// Get current default
|
||||
Queue& Queue::Default()
|
||||
{
|
||||
// ! Need to schedule an "at end" event to delete the default
|
||||
return *defaultQueue;
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
Queue ();
|
||||
virtual ~Queue ();
|
||||
|
||||
virtual Queue* Copy() const = 0;
|
||||
|
||||
TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
|
||||
bool IsEmpty (void);
|
||||
|
@ -104,7 +106,7 @@ private:
|
|||
uint32_t m_nTotalDroppedBytes;
|
||||
uint32_t m_nTotalDroppedPackets;
|
||||
|
||||
#if 0
|
||||
public:
|
||||
// Static methods to manage queue default
|
||||
// Set desired queue default
|
||||
static void Default(const Queue& q);
|
||||
|
@ -112,7 +114,6 @@ private:
|
|||
static Queue& Default();
|
||||
// Static variable pointing to current default queue
|
||||
static Queue* defaultQueue;
|
||||
#endif
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
|
Loading…
Reference in New Issue