diff --git a/bindings/python/ns3_module_olsr.py b/bindings/python/ns3_module_olsr.py index 5e5f2e2a3..7e7b633cd 100644 --- a/bindings/python/ns3_module_olsr.py +++ b/bindings/python/ns3_module_olsr.py @@ -51,8 +51,6 @@ def register_types_ns3_internal(module): def register_types_ns3_olsr(module): root_module = module.get_root() - ## olsr-agent-impl.h: ns3::olsr::AgentImpl [class] - module.add_class('AgentImpl', parent=root_module['ns3::Ipv4RoutingProtocol']) ## olsr-repositories.h: ns3::olsr::DuplicateTuple [struct] module.add_class('DuplicateTuple') ## olsr-repositories.h: ns3::olsr::IfaceAssocTuple [struct] @@ -83,7 +81,9 @@ def register_types_ns3_olsr(module): module.add_enum('Status', ['STATUS_NOT_SYM', 'STATUS_SYM'], outer_class=root_module['ns3::olsr::NeighborTuple']) ## olsr-header.h: ns3::olsr::PacketHeader [class] module.add_class('PacketHeader', parent=root_module['ns3::Header']) - ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry [struct] + ## olsr-routing-protocol.h: ns3::olsr::RoutingProtocol [class] + module.add_class('RoutingProtocol', parent=root_module['ns3::Ipv4RoutingProtocol']) + ## olsr-routing-protocol.h: ns3::olsr::RoutingTableEntry [struct] module.add_class('RoutingTableEntry') ## olsr-repositories.h: ns3::olsr::TopologyTuple [struct] module.add_class('TopologyTuple') @@ -94,7 +94,6 @@ def register_types_ns3_olsr(module): def register_methods(root_module): register_Ns3OlsrState_methods(root_module, root_module['ns3::OlsrState']) - register_Ns3OlsrAgentImpl_methods(root_module, root_module['ns3::olsr::AgentImpl']) register_Ns3OlsrDuplicateTuple_methods(root_module, root_module['ns3::olsr::DuplicateTuple']) register_Ns3OlsrIfaceAssocTuple_methods(root_module, root_module['ns3::olsr::IfaceAssocTuple']) register_Ns3OlsrLinkTuple_methods(root_module, root_module['ns3::olsr::LinkTuple']) @@ -108,6 +107,7 @@ def register_methods(root_module): register_Ns3OlsrMprSelectorTuple_methods(root_module, root_module['ns3::olsr::MprSelectorTuple']) register_Ns3OlsrNeighborTuple_methods(root_module, root_module['ns3::olsr::NeighborTuple']) register_Ns3OlsrPacketHeader_methods(root_module, root_module['ns3::olsr::PacketHeader']) + register_Ns3OlsrRoutingProtocol_methods(root_module, root_module['ns3::olsr::RoutingProtocol']) register_Ns3OlsrRoutingTableEntry_methods(root_module, root_module['ns3::olsr::RoutingTableEntry']) register_Ns3OlsrTopologyTuple_methods(root_module, root_module['ns3::olsr::TopologyTuple']) register_Ns3OlsrTwoHopNeighborTuple_methods(root_module, root_module['ns3::olsr::TwoHopNeighborTuple']) @@ -306,45 +306,6 @@ def register_Ns3OlsrState_methods(root_module, cls): is_const=True) return -def register_Ns3OlsrAgentImpl_methods(root_module, cls): - ## olsr-agent-impl.h: ns3::olsr::AgentImpl::AgentImpl(ns3::olsr::AgentImpl const & arg0) [copy constructor] - cls.add_constructor([param('ns3::olsr::AgentImpl const &', 'arg0')]) - ## olsr-agent-impl.h: static ns3::TypeId ns3::olsr::AgentImpl::GetTypeId() [member function] - cls.add_method('GetTypeId', - 'ns3::TypeId', - [], - is_static=True) - ## olsr-agent-impl.h: ns3::olsr::AgentImpl::AgentImpl() [constructor] - cls.add_constructor([]) - ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::SetNode(ns3::Ptr node) [member function] - cls.add_method('SetNode', - 'void', - [param('ns3::Ptr< ns3::Node >', 'node')]) - ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::Start() [member function] - cls.add_method('Start', - 'void', - []) - ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::SetMainInterface(uint32_t interface) [member function] - cls.add_method('SetMainInterface', - 'void', - [param('uint32_t', 'interface')]) - ## olsr-agent-impl.h: bool ns3::olsr::AgentImpl::RequestRoute(uint32_t ifIndex, ns3::Ipv4Header const & ipHeader, ns3::Ptr packet, ns3::Callback,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> routeReply) [member function] - cls.add_method('RequestRoute', - 'bool', - [param('uint32_t', 'ifIndex'), param('ns3::Ipv4Header const &', 'ipHeader'), param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Callback< void, bool, ns3::Ipv4Route const &, ns3::Ptr< ns3::Packet >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'routeReply')], - visibility='private', is_virtual=True) - ## olsr-agent-impl.h: bool ns3::olsr::AgentImpl::RequestIfIndex(ns3::Ipv4Address destination, uint32_t & ifIndex) [member function] - cls.add_method('RequestIfIndex', - 'bool', - [param('ns3::Ipv4Address', 'destination'), param('uint32_t &', 'ifIndex')], - visibility='private', is_virtual=True) - ## olsr-agent-impl.h: void ns3::olsr::AgentImpl::DoDispose() [member function] - cls.add_method('DoDispose', - 'void', - [], - visibility='private', is_virtual=True) - return - def register_Ns3OlsrDuplicateTuple_methods(root_module, cls): cls.add_binary_comparison_operator('==') ## olsr-repositories.h: ns3::olsr::DuplicateTuple::DuplicateTuple() [constructor] @@ -757,18 +718,57 @@ def register_Ns3OlsrPacketHeader_methods(root_module, cls): [param('uint16_t', 'seqnum')]) return +def register_Ns3OlsrRoutingProtocol_methods(root_module, cls): + ## olsr-routing-protocol.h: ns3::olsr::RoutingProtocol::RoutingProtocol(ns3::olsr::RoutingProtocol const & arg0) [copy constructor] + cls.add_constructor([param('ns3::olsr::RoutingProtocol const &', 'arg0')]) + ## olsr-routing-protocol.h: static ns3::TypeId ns3::olsr::RoutingProtocol::GetTypeId() [member function] + cls.add_method('GetTypeId', + 'ns3::TypeId', + [], + is_static=True) + ## olsr-routing-protocol.h: ns3::olsr::RoutingProtocol::RoutingProtocol() [constructor] + cls.add_constructor([]) + ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::SetNode(ns3::Ptr node) [member function] + cls.add_method('SetNode', + 'void', + [param('ns3::Ptr< ns3::Node >', 'node')]) + ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::Start() [member function] + cls.add_method('Start', + 'void', + []) + ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::SetMainInterface(uint32_t interface) [member function] + cls.add_method('SetMainInterface', + 'void', + [param('uint32_t', 'interface')]) + ## olsr-routing-protocol.h: bool ns3::olsr::RoutingProtocol::RequestRoute(uint32_t ifIndex, ns3::Ipv4Header const & ipHeader, ns3::Ptr packet, ns3::Callback,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> routeReply) [member function] + cls.add_method('RequestRoute', + 'bool', + [param('uint32_t', 'ifIndex'), param('ns3::Ipv4Header const &', 'ipHeader'), param('ns3::Ptr< ns3::Packet >', 'packet'), param('ns3::Callback< void, bool, ns3::Ipv4Route const &, ns3::Ptr< ns3::Packet >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'routeReply')], + visibility='private', is_virtual=True) + ## olsr-routing-protocol.h: bool ns3::olsr::RoutingProtocol::RequestIfIndex(ns3::Ipv4Address destination, uint32_t & ifIndex) [member function] + cls.add_method('RequestIfIndex', + 'bool', + [param('ns3::Ipv4Address', 'destination'), param('uint32_t &', 'ifIndex')], + visibility='private', is_virtual=True) + ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::DoDispose() [member function] + cls.add_method('DoDispose', + 'void', + [], + visibility='private', is_virtual=True) + return + def register_Ns3OlsrRoutingTableEntry_methods(root_module, cls): - ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::destAddr [variable] + ## olsr-routing-protocol.h: ns3::olsr::RoutingTableEntry::destAddr [variable] cls.add_instance_attribute('destAddr', 'ns3::Ipv4Address', is_const=False) - ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::nextAddr [variable] + ## olsr-routing-protocol.h: ns3::olsr::RoutingTableEntry::nextAddr [variable] cls.add_instance_attribute('nextAddr', 'ns3::Ipv4Address', is_const=False) - ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::interface [variable] + ## olsr-routing-protocol.h: ns3::olsr::RoutingTableEntry::interface [variable] cls.add_instance_attribute('interface', 'uint32_t', is_const=False) - ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::distance [variable] + ## olsr-routing-protocol.h: ns3::olsr::RoutingTableEntry::distance [variable] cls.add_instance_attribute('distance', 'uint32_t', is_const=False) - ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry(ns3::olsr::RoutingTableEntry const & arg0) [copy constructor] + ## olsr-routing-protocol.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry(ns3::olsr::RoutingTableEntry const & arg0) [copy constructor] cls.add_constructor([param('ns3::olsr::RoutingTableEntry const &', 'arg0')]) - ## olsr-agent-impl.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry() [constructor] + ## olsr-routing-protocol.h: ns3::olsr::RoutingTableEntry::RoutingTableEntry() [constructor] cls.add_constructor([]) return diff --git a/src/helper/olsr-helper.cc b/src/helper/olsr-helper.cc index 98a735be5..58526d33a 100644 --- a/src/helper/olsr-helper.cc +++ b/src/helper/olsr-helper.cc @@ -18,7 +18,7 @@ * Author: Mathieu Lacage */ #include "olsr-helper.h" -#include "ns3/olsr-agent-impl.h" +#include "ns3/olsr-routing-protocol.h" #include "ns3/node-list.h" #include "ns3/names.h" @@ -26,7 +26,7 @@ namespace ns3 { OlsrHelper::OlsrHelper () { - m_agentFactory.SetTypeId ("ns3::olsr::AgentImpl"); + m_agentFactory.SetTypeId ("ns3::olsr::RoutingProtocol"); } void @@ -63,13 +63,13 @@ OlsrHelper::Install (NodeContainer container) void OlsrHelper::Install (Ptr node) { - if (node->GetObject () != 0) + if (node->GetObject () != 0) { NS_FATAL_ERROR ("OlsrHelper::Install(): Aggregating " - "an Olsr Agent to a node with an existing Olsr Agent"); + "an Olsr Agent to a node with an existing Olsr RoutingProtocol"); return; } - Ptr agent = m_agentFactory.Create (); + Ptr agent = m_agentFactory.Create (); node->AggregateObject (agent); Ptr ipv4 = node->GetObject (); ipv4->AddRoutingProtocol (agent, 10); diff --git a/src/routing/olsr/olsr-agent-impl.cc b/src/routing/olsr/olsr-routing-protocol.cc similarity index 93% rename from src/routing/olsr/olsr-agent-impl.cc rename to src/routing/olsr/olsr-routing-protocol.cc index 88a66d49d..72c734008 100644 --- a/src/routing/olsr/olsr-agent-impl.cc +++ b/src/routing/olsr/olsr-routing-protocol.cc @@ -33,7 +33,7 @@ if (GetObject ()) { std::clog << "[node " << GetObject ()->GetId () << "] "; } -#include "olsr-agent-impl.h" +#include "olsr-routing-protocol.h" #include "ns3/socket-factory.h" #include "ns3/udp-socket-factory.h" #include "ns3/simulator.h" @@ -143,63 +143,63 @@ NS_LOG_COMPONENT_DEFINE ("OlsrAgent"); /********** OLSR class **********/ -NS_OBJECT_ENSURE_REGISTERED (AgentImpl); +NS_OBJECT_ENSURE_REGISTERED (RoutingProtocol); TypeId -AgentImpl::GetTypeId (void) +RoutingProtocol::GetTypeId (void) { - static TypeId tid = TypeId ("ns3::olsr::AgentImpl") + static TypeId tid = TypeId ("ns3::olsr::RoutingProtocol") .SetParent () - .AddConstructor () + .AddConstructor () .AddAttribute ("HelloInterval", "HELLO messages emission interval.", TimeValue (Seconds (2)), - MakeTimeAccessor (&AgentImpl::m_helloInterval), + MakeTimeAccessor (&RoutingProtocol::m_helloInterval), MakeTimeChecker ()) .AddAttribute ("TcInterval", "TC messages emission interval.", TimeValue (Seconds (5)), - MakeTimeAccessor (&AgentImpl::m_tcInterval), + MakeTimeAccessor (&RoutingProtocol::m_tcInterval), MakeTimeChecker ()) .AddAttribute ("MidInterval", "MID messages emission interval. Normally it is equal to TcInterval.", TimeValue (Seconds (5)), - MakeTimeAccessor (&AgentImpl::m_midInterval), + MakeTimeAccessor (&RoutingProtocol::m_midInterval), MakeTimeChecker ()) .AddAttribute ("Willingness", "Willingness of a node to carry and forward traffic for other nodes.", EnumValue (OLSR_WILL_DEFAULT), - MakeEnumAccessor (&AgentImpl::m_willingness), + MakeEnumAccessor (&RoutingProtocol::m_willingness), MakeEnumChecker (OLSR_WILL_NEVER, "never", OLSR_WILL_LOW, "low", OLSR_WILL_DEFAULT, "default", OLSR_WILL_HIGH, "high", OLSR_WILL_ALWAYS, "always")) .AddTraceSource ("Rx", "Receive OLSR packet.", - MakeTraceSourceAccessor (&AgentImpl::m_rxPacketTrace)) + MakeTraceSourceAccessor (&RoutingProtocol::m_rxPacketTrace)) .AddTraceSource ("Tx", "Send OLSR packet.", - MakeTraceSourceAccessor (&AgentImpl::m_txPacketTrace)) + MakeTraceSourceAccessor (&RoutingProtocol::m_txPacketTrace)) .AddTraceSource ("RoutingTableChanged", "The OLSR routing table has changed.", - MakeTraceSourceAccessor (&AgentImpl::m_routingTableChanged)) + MakeTraceSourceAccessor (&RoutingProtocol::m_routingTableChanged)) ; return tid; } -AgentImpl::AgentImpl () +RoutingProtocol::RoutingProtocol () : m_helloTimer (Timer::CANCEL_ON_DESTROY), m_tcTimer (Timer::CANCEL_ON_DESTROY), m_midTimer (Timer::CANCEL_ON_DESTROY) {} -AgentImpl::~AgentImpl () +RoutingProtocol::~RoutingProtocol () {} void -AgentImpl::SetNode (Ptr node) +RoutingProtocol::SetNode (Ptr node) { - NS_LOG_DEBUG ("Created olsr::AgentImpl"); - m_helloTimer.SetFunction (&AgentImpl::HelloTimerExpire, this); - m_tcTimer.SetFunction (&AgentImpl::TcTimerExpire, this); - m_midTimer.SetFunction (&AgentImpl::MidTimerExpire, this); - m_queuedMessagesTimer.SetFunction (&AgentImpl::SendQueuedMessages, this); + NS_LOG_DEBUG ("Created olsr::RoutingProtocol"); + m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this); + m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this); + m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this); + m_queuedMessagesTimer.SetFunction (&RoutingProtocol::SendQueuedMessages, this); m_packetSequenceNumber = OLSR_MAX_SEQ_NUM; m_messageSequenceNumber = OLSR_MAX_SEQ_NUM; @@ -211,7 +211,7 @@ AgentImpl::SetNode (Ptr node) NS_ASSERT (m_ipv4); } -void AgentImpl::DoDispose () +void RoutingProtocol::DoDispose () { m_ipv4 = 0; @@ -225,7 +225,7 @@ void AgentImpl::DoDispose () Ipv4RoutingProtocol::DoDispose (); } -void AgentImpl::Start () +void RoutingProtocol::Start () { if (m_mainAddress == Ipv4Address ()) { @@ -267,7 +267,7 @@ void AgentImpl::Start () // Create a socket to listen only on this interface Ptr socket = Socket::CreateSocket (GetObject (), UdpSocketFactory::GetTypeId()); - socket->SetRecvCallback (MakeCallback (&AgentImpl::RecvOlsr, this)); + socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvOlsr, this)); if (socket->Bind (InetSocketAddress (addr, OLSR_PORT_NUMBER))) { NS_FATAL_ERROR ("Failed to bind() OLSR receive socket"); @@ -283,7 +283,7 @@ void AgentImpl::Start () NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started"); } -void AgentImpl::SetMainInterface (uint32_t interface) +void RoutingProtocol::SetMainInterface (uint32_t interface) { m_mainAddress = m_ipv4->GetAddress (interface); } @@ -292,7 +292,7 @@ void AgentImpl::SetMainInterface (uint32_t interface) // // \brief Processes an incoming %OLSR packet following RFC 3626 specification. void -AgentImpl::RecvOlsr (Ptr socket) +RoutingProtocol::RecvOlsr (Ptr socket) { Ptr receivedPacket; Address sourceAddress; @@ -441,7 +441,7 @@ AgentImpl::RecvOlsr (Ptr socket) /// \return the degree of the node. /// int -AgentImpl::Degree (NeighborTuple const &tuple) +RoutingProtocol::Degree (NeighborTuple const &tuple) { int degree = 0; for (TwoHopNeighborSet::const_iterator it = m_state.GetTwoHopNeighbors ().begin (); @@ -463,7 +463,7 @@ AgentImpl::Degree (NeighborTuple const &tuple) /// \brief Computates MPR set of a node following RFC 3626 hints. /// void -AgentImpl::MprComputation() +RoutingProtocol::MprComputation() { NS_LOG_FUNCTION (this); @@ -732,7 +732,7 @@ AgentImpl::MprComputation() /// \return the corresponding main address. /// Ipv4Address -AgentImpl::GetMainAddress (Ipv4Address iface_addr) const +RoutingProtocol::GetMainAddress (Ipv4Address iface_addr) const { const IfaceAssocTuple *tuple = m_state.FindIfaceAssocTuple (iface_addr); @@ -747,7 +747,7 @@ AgentImpl::GetMainAddress (Ipv4Address iface_addr) const /// \brief Creates the routing table of the node following RFC 3626 hints. /// void -AgentImpl::RoutingTableComputation () +RoutingProtocol::RoutingTableComputation () { NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " s: Node " << m_mainAddress << ": RoutingTableComputation begin..."); @@ -994,7 +994,7 @@ AgentImpl::RoutingTableComputation () /// \param sender_iface the address of the interface where the message was sent from. /// void -AgentImpl::ProcessHello (const olsr::MessageHeader &msg, +RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg, const Ipv4Address &receiverIface, const Ipv4Address &senderIface) { @@ -1055,7 +1055,7 @@ AgentImpl::ProcessHello (const olsr::MessageHeader &msg, /// \param sender_iface the address of the interface where the message was sent from. /// void -AgentImpl::ProcessTc (const olsr::MessageHeader &msg, +RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg, const Ipv4Address &senderIface) { const olsr::MessageHeader::Tc &tc = msg.GetTc (); @@ -1118,7 +1118,7 @@ AgentImpl::ProcessTc (const olsr::MessageHeader &msg, // Schedules topology tuple deletion m_events.Track (Simulator::Schedule (DELAY (topologyTuple.expirationTime), - &AgentImpl::TopologyTupleTimerExpire, + &RoutingProtocol::TopologyTupleTimerExpire, this, topologyTuple.destAddr, topologyTuple.lastAddr)); @@ -1150,7 +1150,7 @@ AgentImpl::ProcessTc (const olsr::MessageHeader &msg, /// \param sender_iface the address of the interface where the message was sent from. /// void -AgentImpl::ProcessMid (const olsr::MessageHeader &msg, +RoutingProtocol::ProcessMid (const olsr::MessageHeader &msg, const Ipv4Address &senderIface) { const olsr::MessageHeader::Mid &mid = msg.GetMid (); @@ -1196,7 +1196,7 @@ AgentImpl::ProcessMid (const olsr::MessageHeader &msg, NS_LOG_LOGIC ("New IfaceAssoc added: " << tuple); // Schedules iface association tuple deletion Simulator::Schedule (DELAY (tuple.time), - &AgentImpl::IfaceAssocTupleTimerExpire, this, tuple.ifaceAddr); + &RoutingProtocol::IfaceAssocTupleTimerExpire, this, tuple.ifaceAddr); } } @@ -1232,7 +1232,7 @@ AgentImpl::ProcessMid (const olsr::MessageHeader &msg, /// \param local_iface the address of the interface where the message was received from. /// void -AgentImpl::ForwardDefault (olsr::MessageHeader olsrMessage, +RoutingProtocol::ForwardDefault (olsr::MessageHeader olsrMessage, DuplicateTuple *duplicated, const Ipv4Address &localIface, const Ipv4Address &senderAddress) @@ -1292,7 +1292,7 @@ AgentImpl::ForwardDefault (olsr::MessageHeader olsrMessage, AddDuplicateTuple (newDup); // Schedule dup tuple deletion Simulator::Schedule (OLSR_DUP_HOLD_TIME, - &AgentImpl::DupTupleTimerExpire, this, + &RoutingProtocol::DupTupleTimerExpire, this, newDup.address, newDup.sequenceNumber); } } @@ -1307,7 +1307,7 @@ AgentImpl::ForwardDefault (olsr::MessageHeader olsrMessage, /// \param delay maximum delay the %OLSR message is going to be buffered. /// void -AgentImpl::QueueMessage (const olsr::MessageHeader &message, Time delay) +RoutingProtocol::QueueMessage (const olsr::MessageHeader &message, Time delay) { m_queuedMessages.push_back (message); if (not m_queuedMessagesTimer.IsRunning ()) @@ -1318,7 +1318,7 @@ AgentImpl::QueueMessage (const olsr::MessageHeader &message, Time delay) } void -AgentImpl::SendPacket (Ptr packet, +RoutingProtocol::SendPacket (Ptr packet, const MessageList &containedMessages) { NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet"); @@ -1344,7 +1344,7 @@ AgentImpl::SendPacket (Ptr packet, /// dictated by OLSR_MAX_MSGS constant. /// void -AgentImpl::SendQueuedMessages () +RoutingProtocol::SendQueuedMessages () { Ptr packet = Create (); int numMessages = 0; @@ -1383,7 +1383,7 @@ AgentImpl::SendQueuedMessages () /// \brief Creates a new %OLSR HELLO message which is buffered for being sent later on. /// void -AgentImpl::SendHello () +RoutingProtocol::SendHello () { NS_LOG_FUNCTION (this); @@ -1494,7 +1494,7 @@ AgentImpl::SendHello () /// \brief Creates a new %OLSR TC message which is buffered for being sent later on. /// void -AgentImpl::SendTc () +RoutingProtocol::SendTc () { NS_LOG_FUNCTION (this); @@ -1520,7 +1520,7 @@ AgentImpl::SendTc () /// \brief Creates a new %OLSR MID message which is buffered for being sent later on. /// void -AgentImpl::SendMid () +RoutingProtocol::SendMid () { olsr::MessageHeader msg; olsr::MessageHeader::Mid &mid = msg.GetMid (); @@ -1564,7 +1564,7 @@ AgentImpl::SendMid () /// \brief Updates Link Set according to a new received HELLO message (following RFC 3626 /// specification). Neighbor Set is also updated if needed. void -AgentImpl::LinkSensing (const olsr::MessageHeader &msg, +RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello, const Ipv4Address &receiverIface, const Ipv4Address &senderIface) @@ -1688,7 +1688,7 @@ AgentImpl::LinkSensing (const olsr::MessageHeader &msg, { LinkTupleAdded (*link_tuple, hello.willingness); m_events.Track (Simulator::Schedule (DELAY (std::min (link_tuple->time, link_tuple->symTime)), - &AgentImpl::LinkTupleTimerExpire, this, + &RoutingProtocol::LinkTupleTimerExpire, this, link_tuple->neighborIfaceAddr)); } NS_LOG_DEBUG ("@" << now.GetSeconds () << ": Olsr node " << m_mainAddress @@ -1699,7 +1699,7 @@ AgentImpl::LinkSensing (const olsr::MessageHeader &msg, /// \brief Updates the Neighbor Set according to the information contained in a new received /// HELLO message (following RFC 3626). void -AgentImpl::PopulateNeighborSet (const olsr::MessageHeader &msg, +RoutingProtocol::PopulateNeighborSet (const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello) { NeighborTuple *nb_tuple = m_state.FindNeighborTuple (msg.GetOriginatorAddress ()); @@ -1714,7 +1714,7 @@ AgentImpl::PopulateNeighborSet (const olsr::MessageHeader &msg, /// \brief Updates the 2-hop Neighbor Set according to the information contained in a new /// received HELLO message (following RFC 3626). void -AgentImpl::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg, +RoutingProtocol::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello) { Time now = Simulator::Now (); @@ -1789,7 +1789,7 @@ AgentImpl::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg, AddTwoHopNeighborTuple (new_nb2hop_tuple); // Schedules nb2hop tuple deletion m_events.Track (Simulator::Schedule (DELAY (new_nb2hop_tuple.expirationTime), - &AgentImpl::Nb2hopTupleTimerExpire, this, + &RoutingProtocol::Nb2hopTupleTimerExpire, this, new_nb2hop_tuple.neighborMainAddr, new_nb2hop_tuple.twoHopNeighborAddr)); } @@ -1826,7 +1826,7 @@ AgentImpl::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg, /// \brief Updates the MPR Selector Set according to the information contained in a new /// received HELLO message (following RFC 3626). void -AgentImpl::PopulateMprSelectorSet (const olsr::MessageHeader &msg, +RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg, const olsr::MessageHeader::Hello &hello) { NS_LOG_FUNCTION (this); @@ -1866,7 +1866,7 @@ AgentImpl::PopulateMprSelectorSet (const olsr::MessageHeader &msg, // Schedules mpr selector tuple deletion m_events.Track (Simulator::Schedule (DELAY (mprsel_tuple.expirationTime), - &AgentImpl::MprSelTupleTimerExpire, this, + &RoutingProtocol::MprSelTupleTimerExpire, this, mprsel_tuple.mainAddr)); } else @@ -1926,7 +1926,7 @@ OLSR::mac_failed(Ptr p) { /// \param tuple link tuple with the information of the link to the neighbor which has been lost. /// void -AgentImpl::NeighborLoss (const LinkTuple &tuple) +RoutingProtocol::NeighborLoss (const LinkTuple &tuple) { NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << "s: OLSR Node " << m_mainAddress @@ -1945,7 +1945,7 @@ AgentImpl::NeighborLoss (const LinkTuple &tuple) /// \param tuple the duplicate tuple to be added. /// void -AgentImpl::AddDuplicateTuple (const DuplicateTuple &tuple) +RoutingProtocol::AddDuplicateTuple (const DuplicateTuple &tuple) { /*debug("%f: Node %d adds dup tuple: addr = %d seq_num = %d\n", Simulator::Now (), @@ -1961,7 +1961,7 @@ AgentImpl::AddDuplicateTuple (const DuplicateTuple &tuple) /// \param tuple the duplicate tuple to be removed. /// void -AgentImpl::RemoveDuplicateTuple (const DuplicateTuple &tuple) +RoutingProtocol::RemoveDuplicateTuple (const DuplicateTuple &tuple) { /*debug("%f: Node %d removes dup tuple: addr = %d seq_num = %d\n", Simulator::Now (), @@ -1972,7 +1972,7 @@ AgentImpl::RemoveDuplicateTuple (const DuplicateTuple &tuple) } void -AgentImpl::LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness) +RoutingProtocol::LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness) { // Creates associated neighbor tuple NeighborTuple nb_tuple; @@ -1997,7 +1997,7 @@ AgentImpl::LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness) /// \param tuple the link tuple to be removed. /// void -AgentImpl::RemoveLinkTuple (const LinkTuple &tuple) +RoutingProtocol::RemoveLinkTuple (const LinkTuple &tuple) { NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << "s: OLSR Node " << m_mainAddress @@ -2015,7 +2015,7 @@ AgentImpl::RemoveLinkTuple (const LinkTuple &tuple) /// \param tuple the link tuple which has been updated. /// void -AgentImpl::LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness) +RoutingProtocol::LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness) { // Each time a link tuple changes, the associated neighbor tuple must be recomputed @@ -2062,7 +2062,7 @@ AgentImpl::LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness) /// \param tuple the neighbor tuple to be added. /// void -AgentImpl::AddNeighborTuple (const NeighborTuple &tuple) +RoutingProtocol::AddNeighborTuple (const NeighborTuple &tuple) { // debug("%f: Node %d adds neighbor tuple: nb_addr = %d status = %s\n", // Simulator::Now (), @@ -2080,7 +2080,7 @@ AgentImpl::AddNeighborTuple (const NeighborTuple &tuple) /// \param tuple the neighbor tuple to be removed. /// void -AgentImpl::RemoveNeighborTuple (const NeighborTuple &tuple) +RoutingProtocol::RemoveNeighborTuple (const NeighborTuple &tuple) { // debug("%f: Node %d removes neighbor tuple: nb_addr = %d status = %s\n", // Simulator::Now (), @@ -2098,7 +2098,7 @@ AgentImpl::RemoveNeighborTuple (const NeighborTuple &tuple) /// \param tuple the 2-hop neighbor tuple to be added. /// void -AgentImpl::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) +RoutingProtocol::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) { // debug("%f: Node %d adds 2-hop neighbor tuple: nb_addr = %d nb2hop_addr = %d\n", // Simulator::Now (), @@ -2115,7 +2115,7 @@ AgentImpl::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) /// \param tuple the 2-hop neighbor tuple to be removed. /// void -AgentImpl::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) +RoutingProtocol::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) { // debug("%f: Node %d removes 2-hop neighbor tuple: nb_addr = %d nb2hop_addr = %d\n", // Simulator::Now (), @@ -2127,7 +2127,7 @@ AgentImpl::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) } void -AgentImpl::IncrementAnsn () +RoutingProtocol::IncrementAnsn () { m_ansn = (m_ansn + 1) % (OLSR_MAX_SEQ_NUM + 1); } @@ -2140,7 +2140,7 @@ AgentImpl::IncrementAnsn () /// \param tuple the MPR selector tuple to be added. /// void -AgentImpl::AddMprSelectorTuple (const MprSelectorTuple &tuple) +RoutingProtocol::AddMprSelectorTuple (const MprSelectorTuple &tuple) { // debug("%f: Node %d adds MPR selector tuple: nb_addr = %d\n", // Simulator::Now (), @@ -2159,7 +2159,7 @@ AgentImpl::AddMprSelectorTuple (const MprSelectorTuple &tuple) /// \param tuple the MPR selector tuple to be removed. /// void -AgentImpl::RemoveMprSelectorTuple (const MprSelectorTuple &tuple) +RoutingProtocol::RemoveMprSelectorTuple (const MprSelectorTuple &tuple) { // debug("%f: Node %d removes MPR selector tuple: nb_addr = %d\n", // Simulator::Now (), @@ -2176,7 +2176,7 @@ AgentImpl::RemoveMprSelectorTuple (const MprSelectorTuple &tuple) /// \param tuple the topology tuple to be added. /// void -AgentImpl::AddTopologyTuple (const TopologyTuple &tuple) +RoutingProtocol::AddTopologyTuple (const TopologyTuple &tuple) { // debug("%f: Node %d adds topology tuple: dest_addr = %d last_addr = %d seq = %d\n", // Simulator::Now (), @@ -2194,7 +2194,7 @@ AgentImpl::AddTopologyTuple (const TopologyTuple &tuple) /// \param tuple the topology tuple to be removed. /// void -AgentImpl::RemoveTopologyTuple (const TopologyTuple &tuple) +RoutingProtocol::RemoveTopologyTuple (const TopologyTuple &tuple) { // debug("%f: Node %d removes topology tuple: dest_addr = %d last_addr = %d seq = %d\n", // Simulator::Now (), @@ -2212,7 +2212,7 @@ AgentImpl::RemoveTopologyTuple (const TopologyTuple &tuple) /// \param tuple the interface association tuple to be added. /// void -AgentImpl::AddIfaceAssocTuple (const IfaceAssocTuple &tuple) +RoutingProtocol::AddIfaceAssocTuple (const IfaceAssocTuple &tuple) { // debug("%f: Node %d adds iface association tuple: main_addr = %d iface_addr = %d\n", // Simulator::Now (), @@ -2229,7 +2229,7 @@ AgentImpl::AddIfaceAssocTuple (const IfaceAssocTuple &tuple) /// \param tuple the interface association tuple to be removed. /// void -AgentImpl::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple) +RoutingProtocol::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple) { // debug("%f: Node %d removes iface association tuple: main_addr = %d iface_addr = %d\n", // Simulator::Now (), @@ -2241,14 +2241,14 @@ AgentImpl::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple) } -uint16_t AgentImpl::GetPacketSequenceNumber () +uint16_t RoutingProtocol::GetPacketSequenceNumber () { m_packetSequenceNumber = (m_packetSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1); return m_packetSequenceNumber; } /// Increments message sequence number and returns the new value. -uint16_t AgentImpl::GetMessageSequenceNumber () +uint16_t RoutingProtocol::GetMessageSequenceNumber () { m_messageSequenceNumber = (m_messageSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1); return m_messageSequenceNumber; @@ -2260,7 +2260,7 @@ uint16_t AgentImpl::GetMessageSequenceNumber () /// \param e The event which has expired. /// void -AgentImpl::HelloTimerExpire () +RoutingProtocol::HelloTimerExpire () { SendHello (); m_helloTimer.Schedule (m_helloInterval); @@ -2271,7 +2271,7 @@ AgentImpl::HelloTimerExpire () /// \param e The event which has expired. /// void -AgentImpl::TcTimerExpire () +RoutingProtocol::TcTimerExpire () { if (m_state.GetMprSelectors ().size () > 0) { @@ -2290,7 +2290,7 @@ AgentImpl::TcTimerExpire () /// \param e The event which has expired. /// void -AgentImpl::MidTimerExpire () +RoutingProtocol::MidTimerExpire () { SendMid (); m_midTimer.Schedule (m_midInterval); @@ -2304,7 +2304,7 @@ AgentImpl::MidTimerExpire () /// \param tuple The tuple which has expired. /// void -AgentImpl::DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber) +RoutingProtocol::DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber) { DuplicateTuple *tuple = m_state.FindDuplicateTuple (address, sequenceNumber); @@ -2319,7 +2319,7 @@ AgentImpl::DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber) else { m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime), - &AgentImpl::DupTupleTimerExpire, this, + &RoutingProtocol::DupTupleTimerExpire, this, address, sequenceNumber)); } } @@ -2336,7 +2336,7 @@ AgentImpl::DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber) /// \param e The event which has expired. /// void -AgentImpl::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr) +RoutingProtocol::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr) { Time now = Simulator::Now (); @@ -2358,13 +2358,13 @@ AgentImpl::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr) NeighborLoss (*tuple); m_events.Track (Simulator::Schedule (DELAY (tuple->time), - &AgentImpl::LinkTupleTimerExpire, this, + &RoutingProtocol::LinkTupleTimerExpire, this, neighborIfaceAddr)); } else { m_events.Track (Simulator::Schedule (DELAY (std::min (tuple->time, tuple->symTime)), - &AgentImpl::LinkTupleTimerExpire, this, + &RoutingProtocol::LinkTupleTimerExpire, this, neighborIfaceAddr)); } } @@ -2377,7 +2377,7 @@ AgentImpl::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr) /// \param e The event which has expired. /// void -AgentImpl::Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr) +RoutingProtocol::Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr) { TwoHopNeighborTuple *tuple; tuple = m_state.FindTwoHopNeighborTuple (neighborMainAddr, twoHopNeighborAddr); @@ -2392,7 +2392,7 @@ AgentImpl::Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address two else { m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime), - &AgentImpl::Nb2hopTupleTimerExpire, + &RoutingProtocol::Nb2hopTupleTimerExpire, this, neighborMainAddr, twoHopNeighborAddr)); } } @@ -2405,7 +2405,7 @@ AgentImpl::Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address two /// \param e The event which has expired. /// void -AgentImpl::MprSelTupleTimerExpire (Ipv4Address mainAddr) +RoutingProtocol::MprSelTupleTimerExpire (Ipv4Address mainAddr) { MprSelectorTuple *tuple = m_state.FindMprSelectorTuple (mainAddr); if (tuple == NULL) @@ -2419,7 +2419,7 @@ AgentImpl::MprSelTupleTimerExpire (Ipv4Address mainAddr) else { m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime), - &AgentImpl::MprSelTupleTimerExpire, + &RoutingProtocol::MprSelTupleTimerExpire, this, mainAddr)); } } @@ -2432,7 +2432,7 @@ AgentImpl::MprSelTupleTimerExpire (Ipv4Address mainAddr) /// \param e The event which has expired. /// void -AgentImpl::TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr) +RoutingProtocol::TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr) { TopologyTuple *tuple = m_state.FindTopologyTuple (destAddr, lastAddr); if (tuple == NULL) @@ -2446,7 +2446,7 @@ AgentImpl::TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr) else { m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime), - &AgentImpl::TopologyTupleTimerExpire, + &RoutingProtocol::TopologyTupleTimerExpire, this, tuple->destAddr, tuple->lastAddr)); } } @@ -2457,7 +2457,7 @@ AgentImpl::TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr) /// \param e The event which has expired. /// void -AgentImpl::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr) +RoutingProtocol::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr) { IfaceAssocTuple *tuple = m_state.FindIfaceAssocTuple (ifaceAddr); if (tuple == NULL) @@ -2471,7 +2471,7 @@ AgentImpl::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr) else { m_events.Track (Simulator::Schedule (DELAY (tuple->time), - &AgentImpl::IfaceAssocTupleTimerExpire, + &RoutingProtocol::IfaceAssocTupleTimerExpire, this, ifaceAddr)); } } @@ -2480,7 +2480,7 @@ AgentImpl::IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr) /// \brief Clears the routing table and frees the memory assigned to each one of its entries. /// void -AgentImpl::Clear () +RoutingProtocol::Clear () { NS_LOG_FUNCTION_NOARGS (); m_table.clear (); @@ -2491,7 +2491,7 @@ AgentImpl::Clear () /// \param dest address of the destination node. /// void -AgentImpl::RemoveEntry (Ipv4Address const &dest) +RoutingProtocol::RemoveEntry (Ipv4Address const &dest) { m_table.erase (dest); } @@ -2503,7 +2503,7 @@ AgentImpl::RemoveEntry (Ipv4Address const &dest) /// \return true if found, false if not found /// bool -AgentImpl::Lookup (Ipv4Address const &dest, +RoutingProtocol::Lookup (Ipv4Address const &dest, RoutingTableEntry &outEntry) const { // Get the iterator at "dest" position @@ -2533,7 +2533,7 @@ AgentImpl::Lookup (Ipv4Address const &dest, /// if there is no such entry. /// bool -AgentImpl::FindSendEntry (RoutingTableEntry const &entry, +RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry, RoutingTableEntry &outEntry) const { outEntry = entry; @@ -2547,7 +2547,7 @@ AgentImpl::FindSendEntry (RoutingTableEntry const &entry, bool -AgentImpl::RequestRoute (uint32_t ifIndex, +RoutingProtocol::RequestRoute (uint32_t ifIndex, const Ipv4Header &ipHeader, Ptr packet, RouteReplyCallback routeReply) @@ -2590,7 +2590,7 @@ AgentImpl::RequestRoute (uint32_t ifIndex, } bool -AgentImpl::RequestIfIndex (Ipv4Address destination, +RoutingProtocol::RequestIfIndex (Ipv4Address destination, uint32_t& ifIndex) { RoutingTableEntry entry1, entry2; @@ -2620,7 +2620,7 @@ AgentImpl::RequestIfIndex (Ipv4Address destination, /// \param dist distance to the destination node. /// void -AgentImpl::AddEntry (Ipv4Address const &dest, +RoutingProtocol::AddEntry (Ipv4Address const &dest, Ipv4Address const &next, uint32_t interface, uint32_t distance) @@ -2639,7 +2639,7 @@ AgentImpl::AddEntry (Ipv4Address const &dest, } void -AgentImpl::AddEntry (Ipv4Address const &dest, +RoutingProtocol::AddEntry (Ipv4Address const &dest, Ipv4Address const &next, Ipv4Address const &interfaceAddress, uint32_t distance) @@ -2664,7 +2664,7 @@ AgentImpl::AddEntry (Ipv4Address const &dest, std::vector -AgentImpl::GetEntries () const +RoutingProtocol::GetEntries () const { std::vector retval; for (std::map::const_iterator iter = m_table.begin (); diff --git a/src/routing/olsr/olsr-agent-impl.h b/src/routing/olsr/olsr-routing-protocol.h similarity index 98% rename from src/routing/olsr/olsr-agent-impl.h rename to src/routing/olsr/olsr-routing-protocol.h index e4433625c..cf7a606d1 100644 --- a/src/routing/olsr/olsr-agent-impl.h +++ b/src/routing/olsr/olsr-routing-protocol.h @@ -59,13 +59,13 @@ struct RoutingTableEntry }; -class AgentImpl : public Ipv4RoutingProtocol +class RoutingProtocol : public Ipv4RoutingProtocol { public: static TypeId GetTypeId (void); - AgentImpl (); - virtual ~AgentImpl (); + RoutingProtocol (); + virtual ~RoutingProtocol (); void SetNode (Ptr node); diff --git a/src/routing/olsr/wscript b/src/routing/olsr/wscript index b46ffbb9e..7170e4478 100644 --- a/src/routing/olsr/wscript +++ b/src/routing/olsr/wscript @@ -6,13 +6,13 @@ def build(bld): module.source = [ 'olsr-header.cc', 'olsr-state.cc', - 'olsr-agent-impl.cc', + 'olsr-routing-protocol.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'olsr' headers.source = [ - 'olsr-agent-impl.h', + 'olsr-routing-protocol.h', 'olsr-header.h', 'olsr-state.h', 'olsr-repositories.h', diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index 12684629a..a1c5e468e 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -239,7 +239,7 @@ int main (int argc, char *argv[]) info.RecordAggregationInfo ("ns3::Node", "ns3::TcpSocketFactory"); info.RecordAggregationInfo ("ns3::Node", "ns3::UdpSocketFactory"); info.RecordAggregationInfo ("ns3::Node", "ns3::PacketSocketFactory"); - info.RecordAggregationInfo ("ns3::Node", "ns3::olsr::Agent"); + info.RecordAggregationInfo ("ns3::Node", "ns3::olsr::RoutingProtocol"); info.RecordAggregationInfo ("ns3::Node", "ns3::MobilityModel"); info.RecordAggregationInfo ("ns3::Node", "ns3::Ipv4L3Protocol"); info.RecordAggregationInfo ("ns3::Node", "ns3::ArpL3Protocol");