46 .SetGroupName (
"Core")
83 std::cout <<
"Bucket Distribution ";
88 std::cout << std::endl;
108 Bucket::iterator end =
m_buckets[bucket].end ();
109 for (Bucket::iterator i =
m_buckets[bucket].begin (); i != end; ++i)
155 if (next.
key < minEvent.
key)
176 int32_t minBucket = -1;
179 minKey.
m_ts = uint64_t(-int64_t(1));
195 if (next.
key < minKey)
239 Bucket::iterator end =
m_buckets[bucket].end ();
240 for (Bucket::iterator i =
m_buckets[bucket].begin (); i != end; ++i)
301 std::list<Scheduler::Event> samples;
308 for (uint32_t i = 0; i < nSamples; i++)
313 for (std::list<Scheduler::Event>::const_iterator i = samples.begin ();
314 i != samples.end (); ++i)
325 uint64_t totalSeparation = 0;
326 std::list<Scheduler::Event>::const_iterator end = samples.end ();
327 std::list<Scheduler::Event>::const_iterator cur = samples.begin ();
328 std::list<Scheduler::Event>::const_iterator next = cur;
332 totalSeparation += next->key.m_ts - cur->key.m_ts;
336 uint64_t twiceAvg = totalSeparation / (nSamples - 1) * 2;
338 cur = samples.begin ();
343 uint64_t diff = next->key.m_ts - cur->key.m_ts;
344 if (diff <= twiceAvg)
346 totalSeparation += diff;
352 totalSeparation *= 3;
353 totalSeparation = std::max (totalSeparation, (uint64_t)1);
354 return totalSeparation;
365 for (uint32_t i = 0; i < oldNBuckets; i++)
367 Bucket::iterator end = oldBuckets[i].end ();
368 for (Bucket::iterator j = oldBuckets[i].begin (); j != end; ++j)
373 delete [] oldBuckets;
virtual void Insert(const Scheduler::Event &ev)
Insert a new Event in the schedule.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void ResizeDown(void)
Halve the number of buckets if necessary.
ns3::EventImpl declarations.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t CalculateNewWidth(void)
Compute the new bucket size, based on up to the first 25 entries.
uint64_t m_ts
Event time stamp.
uint32_t m_qSize
Number of events in queue.
void DoInsert(const Scheduler::Event &ev)
Insert a new event in to the correct bucket.
EventImpl * impl
Pointer to the event implementation.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void ResizeUp(void)
Double the number of buckets if necessary.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual void Remove(const Scheduler::Event &ev)
Remove a specific event from the event list.
virtual Scheduler::Event PeekNext(void) const
Get a pointer to the next event.
uint64_t m_bucketTop
Priority at the top of the bucket from which last event was dequeued.
virtual bool IsEmpty(void) const
Test if the schedule is empty.
virtual ~CalendarScheduler()
Destructor.
make Callback use a separate empty type
EventKey key
Key for sorting and ordering Events.
uint32_t m_uid
Event unique id.
Definition of assertion macros NS_ASSERT() and NS_ASSERT_MSG().
void Init(uint32_t nBuckets, uint64_t width, uint64_t startPrio)
Initialize the calendar queue.
CalendarScheduler()
Constructor.
uint64_t m_width
Duration of a bucket, in dimensionless time units.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void Resize(uint32_t newSize)
Resize to a new number of buckets, with automatically computed width.
virtual Scheduler::Event RemoveNext(void)
Remove the earliest event from the event list.
Bucket * m_buckets
Array of buckets.
Scheduler::Event DoRemoveNext(void)
Remove the earliest event.
uint32_t m_lastBucket
Bucket index from which the last event was dequeued.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void DoResize(uint32_t newSize, uint32_t newWidth)
Resize the number of buckets and width.
std::list< Scheduler::Event > Bucket
Calendar bucket type: a list of Events.
static TypeId GetTypeId(void)
Register this type.
a calendar queue event scheduler
Declaration of ns3::CalendarScheduler class.
uint64_t m_lastPrio
The priority of the last event removed.
Structure for sorting and comparing Events.
uint32_t Hash(uint64_t key) const
Hash the dimensionless time to a bucket.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint32_t m_context
Event context.
uint32_t m_nBuckets
Number of buckets in the array.
void PrintInfo(void)
Print the configuration and bucket size distribution.