A Candidate Queue used in routing calculations. More...
#include "candidate-queue.h"
Public Member Functions | |
CandidateQueue () | |
Create an empty SPF Candidate Queue. | |
CandidateQueue (const CandidateQueue &)=delete | |
virtual | ~CandidateQueue () |
Destroy an SPF Candidate Queue and release any resources held by the contents. | |
void | Clear () |
Empty the Candidate Queue and release all of the resources associated with the Shortest Path First Vertex pointers in the queue. | |
bool | Empty () const |
Test the Candidate Queue to determine if it is empty. | |
SPFVertex * | Find (const Ipv4Address addr) const |
Searches the Candidate Queue for a Shortest Path First Vertex pointer that points to a vertex having the given IP address. | |
CandidateQueue & | operator= (const CandidateQueue &)=delete |
SPFVertex * | Pop () |
Pop the Shortest Path First Vertex pointer at the top of the queue. | |
void | Push (SPFVertex *vNew) |
Push a Shortest Path First Vertex pointer onto the queue according to the priority scheme. | |
void | Reorder () |
Reorders the Candidate Queue according to the priority scheme. | |
uint32_t | Size () const |
Return the number of Shortest Path First Vertex pointers presently stored in the Candidate Queue. | |
SPFVertex * | Top () const |
Return the Shortest Path First Vertex pointer at the top of the queue. | |
Private Types | |
typedef std::list< SPFVertex * > | CandidateList_t |
container of SPFVertex pointers | |
Static Private Member Functions | |
static bool | CompareSPFVertex (const SPFVertex *v1, const SPFVertex *v2) |
return true if v1 < v2 | |
Private Attributes | |
CandidateList_t | m_candidates |
SPFVertex candidates. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const CandidateQueue &q) |
Stream insertion operator. | |
A Candidate Queue used in routing calculations.
The CandidateQueue is used in the OSPF shortest path computations. It is a priority queue used to store candidates for the shortest path to a given network.
The queue holds Shortest Path First Vertex pointers and orders them according to the lowest value of the field m_distanceFromRoot. Remaining vertices are ordered according to increasing distance. This implements a priority queue.
Although a STL priority_queue almost does what we want, the requirement for a Find () operation, the dynamic nature of the data and the derived requirement for a Reorder () operation led us to implement this simple enhanced priority queue.
Definition at line 52 of file candidate-queue.h.
|
private |
container of SPFVertex pointers
Definition at line 176 of file candidate-queue.h.
ns3::CandidateQueue::CandidateQueue | ( | ) |
Create an empty SPF Candidate Queue.
Definition at line 75 of file candidate-queue.cc.
References NS_LOG_FUNCTION.
|
virtual |
Destroy an SPF Candidate Queue and release any resources held by the contents.
Definition at line 81 of file candidate-queue.cc.
References Clear(), and NS_LOG_FUNCTION.
|
delete |
void ns3::CandidateQueue::Clear | ( | ) |
Empty the Candidate Queue and release all of the resources associated with the Shortest Path First Vertex pointers in the queue.
Definition at line 88 of file candidate-queue.cc.
References m_candidates, NS_LOG_FUNCTION, and Pop().
Referenced by ~CandidateQueue().
|
staticprivate |
return true if v1 < v2
SPFVertexes are added into the queue according to the ordering defined by this method. If v1 should be popped before v2, this method return true; false otherwise
v1 | first operand |
v2 | second operand |
Definition at line 187 of file candidate-queue.cc.
References ns3::SPFVertex::GetDistanceFromRoot(), ns3::SPFVertex::GetVertexType(), NS_LOG_FUNCTION, ns3::SPFVertex::VertexNetwork, and ns3::SPFVertex::VertexRouter.
Referenced by Push(), and Reorder().
bool ns3::CandidateQueue::Empty | ( | ) | const |
Test the Candidate Queue to determine if it is empty.
Definition at line 138 of file candidate-queue.cc.
References m_candidates, and NS_LOG_FUNCTION.
SPFVertex * ns3::CandidateQueue::Find | ( | const Ipv4Address | addr | ) | const |
Searches the Candidate Queue for a Shortest Path First Vertex pointer that points to a vertex having the given IP address.
addr | The IP address to search for. |
Definition at line 152 of file candidate-queue.cc.
References ns3::SPFVertex::GetVertexId(), m_candidates, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::SPFNext().
|
delete |
SPFVertex * ns3::CandidateQueue::Pop | ( | ) |
Pop the Shortest Path First Vertex pointer at the top of the queue.
The caller is given the responsibility for releasing the resources associated with the vertex.
Definition at line 112 of file candidate-queue.cc.
References m_candidates, and NS_LOG_FUNCTION.
Referenced by Clear(), GlobalRouteManagerImplTestCase::DoRun(), and ns3::GlobalRouteManagerImpl::SPFCalculate().
void ns3::CandidateQueue::Push | ( | SPFVertex * | vNew | ) |
Push a Shortest Path First Vertex pointer onto the queue according to the priority scheme.
On completion, the top of the queue will hold the Shortest Path First Vertex pointer that points to a vertex having lowest value of the field m_distanceFromRoot. Remaining vertices are ordered according to increasing distance.
vNew | The Shortest Path First Vertex to add to the queue. |
Definition at line 100 of file candidate-queue.cc.
References CompareSPFVertex(), m_candidates, and NS_LOG_FUNCTION.
Referenced by GlobalRouteManagerImplTestCase::DoRun(), and ns3::GlobalRouteManagerImpl::SPFNext().
void ns3::CandidateQueue::Reorder | ( | ) |
Reorders the Candidate Queue according to the priority scheme.
On completion, the top of the queue will hold the Shortest Path First Vertex pointer that points to a vertex having lowest value of the field m_distanceFromRoot. Remaining vertices are ordered according to increasing distance.
This method is provided in case the values of m_distanceFromRoot change during the routing calculations.
Definition at line 170 of file candidate-queue.cc.
References CompareSPFVertex(), m_candidates, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by ns3::GlobalRouteManagerImpl::SPFNext().
uint32_t ns3::CandidateQueue::Size | ( | ) | const |
Return the number of Shortest Path First Vertex pointers presently stored in the Candidate Queue.
Definition at line 145 of file candidate-queue.cc.
References m_candidates, and NS_LOG_FUNCTION.
Referenced by ns3::GlobalRouteManagerImpl::SPFCalculate().
SPFVertex * ns3::CandidateQueue::Top | ( | ) | const |
Return the Shortest Path First Vertex pointer at the top of the queue.
This method does not pop the SPFVertex* off of the queue, it simply returns the pointer.
Definition at line 126 of file candidate-queue.cc.
References m_candidates, and NS_LOG_FUNCTION.
|
friend |
Stream insertion operator.
os | the reference to the output stream |
q | the CandidateQueue |
Definition at line 58 of file candidate-queue.cc.
|
private |