|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
49 .SetGroupName (
"Core")
51 .AddAttribute (
"Reverse",
52 "Store events in reverse chronological order",
83 return bucket.back ();
98 return bucket.front ();
129 std::cout <<
"Bucket Distribution ";
132 std::cout <<
m_buckets[i].size () <<
" ";
134 std::cout << std::endl;
154 Bucket::iterator end =
m_buckets[bucket].end ();
155 for (Bucket::iterator i =
m_buckets[bucket].begin (); i != end; ++i)
189 minEvent.
key.
m_ts = UINT64_MAX;
201 if (next.
key < minEvent.
key)
222 int32_t minBucket = -1;
225 minKey.
m_ts = uint64_t (-int64_t (1));
241 if (next.
key < minKey)
285 Bucket::iterator end =
m_buckets[bucket].end ();
286 for (Bucket::iterator i =
m_buckets[bucket].begin (); i != end; ++i)
347 std::list<Scheduler::Event> samples;
354 for (uint32_t i = 0; i < nSamples; i++)
359 for (std::list<Scheduler::Event>::const_iterator i = samples.begin ();
360 i != samples.end (); ++i)
371 uint64_t totalSeparation = 0;
372 std::list<Scheduler::Event>::const_iterator end = samples.end ();
373 std::list<Scheduler::Event>::const_iterator cur = samples.begin ();
374 std::list<Scheduler::Event>::const_iterator next = cur;
378 totalSeparation += next->key.m_ts - cur->key.m_ts;
382 uint64_t twiceAvg = totalSeparation / (nSamples - 1) * 2;
384 cur = samples.begin ();
389 uint64_t diff = next->key.m_ts - cur->key.m_ts;
390 if (diff <= twiceAvg)
392 totalSeparation += diff;
398 totalSeparation *= 3;
399 totalSeparation =
std::max (totalSeparation, (uint64_t)1);
400 return totalSeparation;
411 for (uint32_t i = 0; i < oldNBuckets; i++)
413 Bucket::iterator end = oldBuckets[i].end ();
414 for (Bucket::iterator j = oldBuckets[i].begin (); j != end; ++j)
419 delete [] oldBuckets;
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool m_reverse
Bucket ordering.
virtual Scheduler::Event RemoveNext(void)
Remove the earliest event from the event list.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
AttributeValue implementation for Boolean.
Scheduler::Event DoRemoveNext(void)
Remove the earliest event.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::BooleanValue attribute value declarations.
static TypeId GetTypeId(void)
Register this type.
EventImpl * impl
Pointer to the event implementation.
std::list< Scheduler::Event > Bucket
Calendar bucket type: a list of Events.
void(* Pop)(Bucket &)
Pop the next event from the bucket, according to m_reverse.
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
virtual Scheduler::Event PeekNext(void) const
Get a pointer to the next event.
CalendarScheduler()
Constructor.
Scheduler::Event &(* NextEvent)(Bucket &bucket)
Get the next event from the bucket, according to m_reverse.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void DoResize(uint32_t newSize, uint64_t newWidth)
Resize the number of buckets and width.
void ResizeDown(void)
Halve the number of buckets if necessary.
uint64_t m_lastPrio
The priority of the last event removed.
ns3::CalendarScheduler class declaration.
uint64_t m_ts
Event time stamp.
uint64_t m_bucketTop
Priority at the top of the bucket from which last event was dequeued.
void Resize(uint32_t newSize)
Resize to a new number of buckets, with automatically computed width.
uint32_t m_nBuckets
Number of buckets in the array.
EventKey key
Key for sorting and ordering Events.
uint32_t m_context
Event context.
Structure for sorting and comparing Events.
ns3::EventImpl declarations.
virtual void Remove(const Scheduler::Event &ev)
Remove a specific event from the event list.
void DoInsert(const Scheduler::Event &ev)
Insert a new event in to the correct bucket.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
bool(* Order)(const EventKey &newEvent, const EventKey &it)
Ordering function to identify the insertion point, according to m_reverse.
void Init(uint32_t nBuckets, uint64_t width, uint64_t startPrio)
Initialize the calendar queue.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual void Insert(const Scheduler::Event &ev)
Insert a new Event in the schedule.
Bucket * m_buckets
Array of buckets.
uint32_t Hash(uint64_t key) const
Hash the dimensionless time to a bucket.
ns3::TypeId declaration; inline and template implementations.
uint32_t m_lastBucket
Bucket index from which the last event was dequeued.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
uint64_t m_width
Duration of a bucket, in dimensionless time units.
virtual bool IsEmpty(void) const
Test if the schedule is empty.
virtual ~CalendarScheduler()
Destructor.
void PrintInfo(void)
Print the configuration and bucket size distribution.
uint64_t CalculateNewWidth(void)
Compute the new bucket size, based on up to the first 25 entries.
void SetReverse(bool reverse)
Set the insertion order.
void ResizeUp(void)
Double the number of buckets if necessary.
uint32_t m_qSize
Number of events in queue.
make Callback use a separate empty type
a calendar queue event scheduler
uint32_t m_uid
Event unique id.