--- a/doc/doxygen.conf Mon Oct 29 16:34:26 2007 +0100
+++ b/doc/doxygen.conf Tue Oct 30 10:31:20 2007 +0100
@@ -1080,7 +1080,6 @@
# instead of the = operator.
PREDEFINED = RUN_SELF_TESTS \
- NS3_DEBUG_ENABLE \
NS3_ASSERT_ENABLE \
NS3_LOG_ENABLE
--- a/samples/main-debug-other.cc Mon Oct 29 16:34:26 2007 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-#include "ns3/debug.h"
-
-NS_DEBUG_COMPONENT_DEFINE ("MyComponentB");
-
-namespace foo {
-
-void OneFunction (void)
-{
- NS_DEBUG ("OneFunction debug");
-}
-
-}; // namespace foo
--- a/samples/main-debug.cc Mon Oct 29 16:34:26 2007 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-#include "ns3/debug.h"
-#include "ns3/assert.h"
-
-NS_DEBUG_COMPONENT_DEFINE ("MyComponentA");
-
-// declare other function
-namespace foo {
-void OneFunction (void);
-}
-
-int main (int argc, int argv)
-{
- NS_DEBUG ("nargc="<<argc);
-
- foo::OneFunction ();
-
- NS_DEBUG ("other debug output");
-
- int a;
- a = 0;
-
- NS_ASSERT (a == 0);
- NS_ASSERT_MSG (a == 0, "my msg");
- NS_ASSERT (a != 0);
- NS_ASSERT_MSG (a != 0, "my 2 msg");
-}
--- a/samples/wscript Mon Oct 29 16:34:26 2007 +0100
+++ b/samples/wscript Tue Oct 30 10:31:20 2007 +0100
@@ -1,9 +1,6 @@
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def build(bld):
- obj = bld.create_ns3_program('main-debug')
- obj.source = ['main-debug.cc', 'main-debug-other.cc']
-
obj = bld.create_ns3_program('main-callback')
obj.source = 'main-callback.cc'
--- a/src/core/command-line.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/core/command-line.cc Tue Oct 30 10:31:20 2007 +0100
@@ -20,7 +20,6 @@
*/
#include "command-line.h"
-#include "ns3/debug.h"
#include <unistd.h>
namespace ns3 {
--- a/src/core/debug.cc Mon Oct 29 16:34:26 2007 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include <list>
-#include <utility>
-#include <iostream>
-#include "debug.h"
-#include "assert.h"
-#include "ns3/core-config.h"
-#include "fatal-error.h"
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-namespace ns3 {
-
-typedef std::list<std::pair <std::string, DebugComponent *> > ComponentList;
-typedef std::list<std::pair <std::string, DebugComponent *> >::iterator ComponentListI;
-
-static
-ComponentList *GetComponentList (void)
-{
- static ComponentList components;
- return &components;
-}
-
-
-static bool g_firstDebug = true;
-
-void
-DebugComponentEnableEnvVar (void)
-{
-#ifdef HAVE_GETENV
- char *envVar = getenv("NS_DEBUG");
- if (envVar == 0)
- {
- return;
- }
- bool allFound = true;
- std::string env = envVar;
- std::string::size_type cur = 0;
- std::string::size_type next = 0;
- while (true)
- {
- next = env.find_first_of (";", cur);
- std::string tmp = std::string (env, cur, next);
- {
- /* The following code is a workaround for a bug in the g++
- * c++ string library. Its goal is to remove any trailing ';'
- * from the string even though there should not be any in
- * it. This code should be safe even if the bug is not there.
- */
- std::string::size_type trailing = tmp.find_first_of (";");
- tmp = tmp.substr (0, trailing);
- }
- if (tmp.size () == 0)
- {
- break;
- }
- bool found = false;
- ComponentList *components = GetComponentList ();
- for (ComponentListI i = components->begin ();
- i != components->end ();
- i++)
- {
- if (i->first.compare (tmp) == 0)
- {
- found = true;
- i->second->Enable ();
- break;
- }
- }
- if (!found)
- {
- allFound = false;
- }
- if (next == std::string::npos)
- {
- break;
- }
- cur = next + 1;
- if (cur >= env.size ())
- {
- break;
- }
- }
- if (allFound)
- {
- g_firstDebug = true;
- }
-
-#endif
-}
-
-
-DebugComponent::DebugComponent (char const * name)
- : m_isEnabled (false)
-{
- ComponentList *components = GetComponentList ();
- for (ComponentListI i = components->begin ();
- i != components->end ();
- i++)
- {
- NS_ASSERT (i->first != name);
- }
- components->push_back (std::make_pair (name, this));
-}
-bool
-DebugComponent::IsEnabled (void)
-{
- if (g_firstDebug)
- {
- DebugComponentEnableEnvVar ();
- }
- return m_isEnabled;
-}
-void
-DebugComponent::Enable (void)
-{
- m_isEnabled = true;
-}
-void
-DebugComponent::Disable (void)
-{
- m_isEnabled = false;
-}
-
-void
-DebugComponentEnable (char const *name)
-{
- ComponentList *components = GetComponentList ();
- for (ComponentListI i = components->begin ();
- i != components->end ();
- i++)
- {
- if (i->first.compare (name) == 0)
- {
- i->second->Enable ();
- break;
- }
- }
-}
-void
-DebugComponentDisable (char const *name)
-{
- ComponentList *components = GetComponentList ();
- for (ComponentListI i = components->begin ();
- i != components->end ();
- i++)
- {
- if (i->first.compare (name) == 0)
- {
- i->second->Disable ();
- break;
- }
- }
-}
-
-
-void
-DebugComponentPrintList (void)
-{
- ComponentList *components = GetComponentList ();
- for (ComponentListI i = components->begin ();
- i != components->end ();
- i++)
- {
- std::cout << i->first << "=" << (i->second->IsEnabled ()?"enabled":"disabled") << std::endl;
- }
-}
-
-}; // namespace ns3
-
-
--- a/src/core/debug.h Mon Oct 29 16:34:26 2007 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2006 INRIA
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef DEBUG_H
-#define DEBUG_H
-
-/**
- * \defgroup debugging Debugging
- * \brief Debugging functions and macros
- *
- * - DEBUG functionality: macros which allow developers to
- * send information out on screen only in debugging builds.
- * All debug messages are disabled by default. To enable
- * selected debug messages, use the ns3::DebugComponentEnable
- * function. Alternatively, you can use the NS_DEBUG
- * environment variable to define a ';'-separated list of
- * messages to enable. For example, NS_DEBUG=a;b;c;DAFD;GH
- * would enable the components 'a', 'b', 'c', 'DAFD', and, 'GH'.
- */
-
-namespace ns3 {
-
-/**
- * \param name a debug component name
- * \ingroup debugging
- *
- * Enable the debugging output associated with that debug component.
- * The debugging output can be later disabled with a call
- * to ns3::DebugComponentDisable.
- */
-void DebugComponentEnable (char const *name);
-/**
- * \param name a debug component name
- * \ingroup debugging
- *
- * Disable the debugging output associated with that debug component.
- * The debugging output can be later re-enabled with a call
- * to ns3::DebugComponentEnable.
- */
-void DebugComponentDisable (char const *name);
-/**
- * \ingroup debugging
- * Print the list of debugging messages available.
- */
-void DebugComponentPrintList (void);
-
-class DebugComponent {
-public:
- DebugComponent (char const *name);
- bool IsEnabled (void);
- void Enable (void);
- void Disable (void);
-private:
- bool m_isEnabled;
-};
-
-}; // namespace ns3
-
-
-#ifdef NS3_DEBUG_ENABLE
-
-#include <string>
-#include <iostream>
-
-
-/**
- * \ingroup debugging
- * \param name a string
- *
- * Define a Debug component with a specific name. This macro
- * should be used at the top of every file in which you want
- * to use the NS_DEBUG macro. This macro defines a new
- * "debug component" which can be later selectively enabled
- * or disabled with the ns3::DebugComponentEnable and
- * ns3::DebugComponentDisable functions or with the NS_DEBUG
- * environment variable.
- */
-#define NS_DEBUG_COMPONENT_DEFINE(name) \
- static ns3::DebugComponent g_debug = ns3::DebugComponent (name)
-
-/**
- * \ingroup debugging
- * \param msg message to output
- *
- * Generate debugging output in the "debug component" of the
- * current file. i.e., every call to NS_DEBUG from within
- * a file implicitely generates out within the component
- * defined with the NS_DEBUG_COMPONENT_DEFINE macro in the
- * same file.
- */
-#define NS_DEBUG(msg) \
- do \
- { \
- if (g_debug.IsEnabled ()) \
- { \
- std::cerr << msg << std::endl; \
- } \
- } \
- while (false)
-
-/**
- * \ingroup debugging
- * \param msg message to output
- *
- * Generate debugging output unconditionally in all
- * debug builds.
- */
-#define NS_DEBUG_UNCOND(msg) \
- do \
- { \
- std::cerr << msg << std::endl; \
- } \
- while (false)
-
-#else /* NS3_DEBUG_ENABLE */
-
-#define NS_DEBUG_COMPONENT_DEFINE(name)
-#define NS_DEBUG(x)
-#define NS_DEBUG_UNCOND(msg)
-
-#endif /* NS3_DEBUG_ENABLE */
-
-#endif /* DEBUG_H */
--- a/src/core/wscript Mon Oct 29 16:34:26 2007 +0100
+++ b/src/core/wscript Tue Oct 30 10:31:20 2007 +0100
@@ -29,7 +29,6 @@
core = bld.create_ns3_module('core')
core.source = [
'callback-test.cc',
- 'debug.cc',
'log.cc',
'breakpoint.cc',
'ptr.cc',
@@ -70,7 +69,6 @@
'callback.h',
'ptr.h',
'object.h',
- 'debug.h',
'log.h',
'assert.h',
'breakpoint.h',
--- a/src/mobility/ns2-mobility-file-topology.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/mobility/ns2-mobility-file-topology.cc Tue Oct 30 10:31:20 2007 +0100
@@ -20,14 +20,14 @@
*/
#include <fstream>
#include <sstream>
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/simulator.h"
#include "ns3/node-list.h"
#include "ns3/node.h"
#include "ns2-mobility-file-topology.h"
#include "static-speed-mobility-model.h"
-NS_DEBUG_COMPONENT_DEFINE ("Ns2MobilityFileTopology");
+NS_LOG_COMPONENT_DEFINE ("Ns2MobilityFileTopology");
namespace ns3 {
@@ -101,17 +101,17 @@
if (coordinate == "X")
{
position.x = value;
- NS_DEBUG ("X=" << value);
+ NS_LOG_DEBUG ("X=" << value);
}
else if (coordinate == "Y")
{
position.y = value;
- NS_DEBUG ("Y=" << value);
+ NS_LOG_DEBUG ("Y=" << value);
}
else if (coordinate == "Z")
{
position.z = value;
- NS_DEBUG ("Z=" << value);
+ NS_LOG_DEBUG ("Z=" << value);
}
else
{
@@ -127,7 +127,7 @@
double xSpeed = ReadDouble (line.substr (endNodeId + 10, xSpeedEnd - endNodeId - 10));
double ySpeed = ReadDouble (line.substr (xSpeedEnd + 1, ySpeedEnd - xSpeedEnd - 1));
double zSpeed = ReadDouble (line.substr (ySpeedEnd + 1, std::string::npos));
- NS_DEBUG ("at=" << at << "xSpeed=" << xSpeed << ", ySpeed=" << ySpeed << ", zSpeed=" << zSpeed);
+ NS_LOG_DEBUG ("at=" << at << "xSpeed=" << xSpeed << ", ySpeed=" << ySpeed << ", zSpeed=" << zSpeed);
Simulator::Schedule (Seconds (at), &StaticSpeedMobilityModel::SetSpeed, model,
Speed (xSpeed, ySpeed, zSpeed));
}
--- a/src/mobility/random-walk-2d-mobility-model.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/mobility/random-walk-2d-mobility-model.cc Tue Oct 30 10:31:20 2007 +0100
@@ -24,10 +24,10 @@
#include "ns3/rectangle-default-value.h"
#include "ns3/random-variable-default-value.h"
#include "ns3/simulator.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include <cmath>
-NS_DEBUG_COMPONENT_DEFINE ("RandomWalk2d");
+NS_LOG_COMPONENT_DEFINE ("RandomWalk2d");
namespace ns3 {
--- a/src/routing/olsr/olsr-agent-impl.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-agent-impl.cc Tue Oct 30 10:31:20 2007 +0100
@@ -34,10 +34,10 @@
#include "ns3/udp.h"
#include "ns3/internet-node.h"
#include "ns3/simulator.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
#include "ns3/random-variable.h"
#include "ns3/inet-socket-address.h"
-
+#include "ns3/composite-trace-resolver.h"
/********** Useful macros **********/
@@ -141,27 +141,28 @@
namespace ns3 {
+namespace olsr {
-NS_DEBUG_COMPONENT_DEFINE ("OlsrAgent");
+NS_LOG_COMPONENT_DEFINE ("OlsrAgent");
/********** OLSR class **********/
-OlsrAgentImpl::OlsrAgentImpl (Ptr<Node> node)
+AgentImpl::AgentImpl (Ptr<Node> node)
:
m_useL2Notifications (false),
m_helloTimer (Timer::CANCEL_ON_DESTROY),
m_tcTimer (Timer::CANCEL_ON_DESTROY),
m_midTimer (Timer::CANCEL_ON_DESTROY)
{
- m_helloTimer.SetFunction (&OlsrAgentImpl::HelloTimerExpire, this);
- m_tcTimer.SetFunction (&OlsrAgentImpl::TcTimerExpire, this);
- m_midTimer.SetFunction (&OlsrAgentImpl::MidTimerExpire, this);
- m_queuedMessagesTimer.SetFunction (&OlsrAgentImpl::SendQueuedMessages, this);
+ m_helloTimer.SetFunction (&AgentImpl::HelloTimerExpire, this);
+ m_tcTimer.SetFunction (&AgentImpl::TcTimerExpire, this);
+ m_midTimer.SetFunction (&AgentImpl::MidTimerExpire, this);
+ m_queuedMessagesTimer.SetFunction (&AgentImpl::SendQueuedMessages, this);
- SetInterfaceId (OlsrAgentImpl::iid);
+ SetInterfaceId (AgentImpl::iid);
// Aggregate with the Node, so that OLSR dies when the node is destroyed.
node->AddInterface (this);
@@ -191,7 +192,7 @@
}
-void OlsrAgentImpl::DoDispose ()
+void AgentImpl::DoDispose ()
{
m_ipv4 = 0;
if (m_receiveSocket)
@@ -213,7 +214,7 @@
Object::DoDispose ();
}
-void OlsrAgentImpl::Start ()
+void AgentImpl::Start ()
{
if (m_mainAddress == Ipv4Address ())
{
@@ -231,7 +232,7 @@
NS_ASSERT (m_mainAddress != Ipv4Address ());
}
- NS_DEBUG ("Starting OLSR on node " << m_mainAddress);
+ NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress);
m_routingTable = Create<RoutingTable> (m_ipv4, m_mainAddress);
// Add OLSR as routing protocol, with slightly lower priority than
@@ -240,29 +241,50 @@
if (m_sendSocket->Bind (InetSocketAddress (m_mainAddress, OLSR_PORT_NUMBER)))
NS_ASSERT_MSG (false, "Failed to bind() OLSR send socket");
- m_receiveSocket->SetRecvCallback (MakeCallback (&OlsrAgentImpl::RecvOlsr, this));
+ m_receiveSocket->SetRecvCallback (MakeCallback (&AgentImpl::RecvOlsr, this));
HelloTimerExpire ();
TcTimerExpire ();
MidTimerExpire ();
- NS_DEBUG ("OLSR on node " << m_mainAddress << " started");
+ NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
+}
+
+void AgentImpl::SetMainInterface (uint32_t interface)
+{
+ m_mainAddress = m_ipv4->GetAddress (interface);
}
-void OlsrAgentImpl::SetMainInterface (uint32_t interface)
+
+Ptr<TraceResolver>
+AgentImpl::GetTraceResolver (void) const
{
- m_mainAddress = m_ipv4->GetAddress (interface);
+ Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
+ resolver->AddSource ("rx",
+ TraceDoc ("receive OLSR packet",
+ "const olsr::PacketHeader &", "header of OLSR packet received",
+ "const olsr::MessageList &", "list of OLSR messages contained in the packet"
+ ),
+ m_rxPacketTrace);
+ resolver->AddSource ("tx",
+ TraceDoc ("send OLSR packet",
+ "const olsr::PacketHeader &", "header of OLSR packet sent",
+ "const olsr::MessageList &", "list of OLSR messages contained in the packet"
+ ),
+ m_txPacketTrace);
+ resolver->SetParentResolver (Object::GetTraceResolver ());
+ return resolver;
}
//
// \brief Processes an incoming %OLSR packet following RFC 3626 specification.
void
-OlsrAgentImpl::RecvOlsr (Ptr<Socket> socket,
+AgentImpl::RecvOlsr (Ptr<Socket> socket,
const Packet &receivedPacket,
const Address &sourceAddress)
{
- NS_DEBUG ("OLSR node " << m_mainAddress << " received a OLSR packet");
+ NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " received a OLSR packet");
InetSocketAddress inetSourceAddr = InetSocketAddress::ConvertFrom (sourceAddress);
// All routing messages are sent from and to port RT_PORT,
@@ -271,24 +293,34 @@
Packet packet = receivedPacket;
- OlsrPacketHeader olsrPacketHeader;
+ olsr::PacketHeader olsrPacketHeader;
packet.RemoveHeader (olsrPacketHeader);
NS_ASSERT (olsrPacketHeader.GetPacketLength () >= olsrPacketHeader.GetSerializedSize ());
uint32_t sizeLeft = olsrPacketHeader.GetPacketLength () - olsrPacketHeader.GetSerializedSize ();
+
+ MessageList messages;
while (sizeLeft)
{
- OlsrMessageHeader messageHeader;
+ MessageHeader messageHeader;
if (packet.RemoveHeader (messageHeader) == 0)
NS_ASSERT (false);
sizeLeft -= messageHeader.GetSerializedSize ();
- NS_DEBUG ("Olsr Msg received with type "
+ NS_LOG_DEBUG ("Olsr Msg received with type "
<< std::dec << int (messageHeader.GetMessageType ())
<< " TTL=" << int (messageHeader.GetTimeToLive ())
<< " origAddr=" << messageHeader.GetOriginatorAddress ());
+ messages.push_back (messageHeader);
+ }
+ m_rxPacketTrace (olsrPacketHeader, messages);
+
+ for (MessageList::const_iterator messageIter = messages.begin ();
+ messageIter != messages.end (); messageIter++)
+ {
+ const MessageHeader &messageHeader = *messageIter;
// If ttl is less than or equal to zero, or
// the receiver is the same as the originator,
// the message must be silently dropped
@@ -310,30 +342,30 @@
{
switch (messageHeader.GetMessageType ())
{
- case OlsrMessageHeader::HELLO_MESSAGE:
- NS_DEBUG ("OLSR node received HELLO message of size " << messageHeader.GetSerializedSize ());
+ case olsr::MessageHeader::HELLO_MESSAGE:
+ NS_LOG_DEBUG ("OLSR node received HELLO message of size " << messageHeader.GetSerializedSize ());
ProcessHello (messageHeader, m_mainAddress, inetSourceAddr.GetIpv4 ());
break;
- case OlsrMessageHeader::TC_MESSAGE:
- NS_DEBUG ("OLSR node received TC message of size " << messageHeader.GetSerializedSize ());
+ case olsr::MessageHeader::TC_MESSAGE:
+ NS_LOG_DEBUG ("OLSR node received TC message of size " << messageHeader.GetSerializedSize ());
ProcessTc (messageHeader, inetSourceAddr.GetIpv4 ());
break;
- case OlsrMessageHeader::MID_MESSAGE:
- NS_DEBUG ("OLSR node received MID message of size " << messageHeader.GetSerializedSize ());
+ case olsr::MessageHeader::MID_MESSAGE:
+ NS_LOG_DEBUG ("OLSR node received MID message of size " << messageHeader.GetSerializedSize ());
ProcessMid (messageHeader, inetSourceAddr.GetIpv4 ());
break;
default:
- NS_DEBUG ("OLSR message type " <<
+ NS_LOG_DEBUG ("OLSR message type " <<
int (messageHeader.GetMessageType ()) <<
" not implemented");
}
}
else
{
- NS_DEBUG ("OLSR message is duplicated, not reading it.");
+ NS_LOG_DEBUG ("OLSR message is duplicated, not reading it.");
// If the message has been considered for forwarding, it should
// not be retransmitted again
@@ -353,7 +385,7 @@
// HELLO messages are never forwarded.
// TC and MID messages are forwarded using the default algorithm.
// Remaining messages are also forwarded using the default algorithm.
- if (messageHeader.GetMessageType () != OlsrMessageHeader::HELLO_MESSAGE)
+ if (messageHeader.GetMessageType () != olsr::MessageHeader::HELLO_MESSAGE)
ForwardDefault (messageHeader, duplicated,
m_mainAddress, inetSourceAddr.GetIpv4 ());
}
@@ -371,7 +403,7 @@
/// \return the degree of the node.
///
int
-OlsrAgentImpl::Degree (NeighborTuple const &tuple)
+AgentImpl::Degree (NeighborTuple const &tuple)
{
int degree = 0;
for (TwoHopNeighborSet::const_iterator it = m_state.GetTwoHopNeighbors ().begin ();
@@ -393,7 +425,7 @@
/// \brief Computates MPR set of a node following RFC 3626 hints.
///
void
-OlsrAgentImpl::MprComputation()
+AgentImpl::MprComputation()
{
// MPR computation should be done for each interface. See section 8.3.1
// (RFC 3626) for details.
@@ -422,7 +454,7 @@
{
TwoHopNeighborTuple const &twoHopNeigh = *it;
bool ok = true;
- NeighborTuple *nb_tuple = m_state.FindSymNeighborTuple (twoHopNeigh.neighborMainAddr);
+ const NeighborTuple *nb_tuple = m_state.FindSymNeighborTuple (twoHopNeigh.neighborMainAddr);
if (nb_tuple == NULL)
{
ok = false;
@@ -643,9 +675,9 @@
/// \return the corresponding main address.
///
Ipv4Address
-OlsrAgentImpl::GetMainAddress (Ipv4Address iface_addr)
+AgentImpl::GetMainAddress (Ipv4Address iface_addr) const
{
- IfaceAssocTuple *tuple =
+ const IfaceAssocTuple *tuple =
m_state.FindIfaceAssocTuple (iface_addr);
if (tuple != NULL)
@@ -658,7 +690,7 @@
/// \brief Creates the routing table of the node following RFC 3626 hints.
///
void
-OlsrAgentImpl::RoutingTableComputation ()
+AgentImpl::RoutingTableComputation ()
{
// 1. All the entries from the routing table are removed.
m_routingTable->Clear ();
@@ -711,7 +743,7 @@
{
TwoHopNeighborTuple const &nb2hop_tuple = *it;
bool ok = true;
- NeighborTuple *nb_tuple = m_state.FindSymNeighborTuple
+ const NeighborTuple *nb_tuple = m_state.FindSymNeighborTuple
(nb2hop_tuple.neighborMainAddr);
if (nb_tuple == NULL)
ok = false;
@@ -814,11 +846,11 @@
/// \param sender_iface the address of the interface where the message was sent from.
///
void
-OlsrAgentImpl::ProcessHello (const OlsrMessageHeader &msg,
+AgentImpl::ProcessHello (const olsr::MessageHeader &msg,
const Ipv4Address &receiverIface,
const Ipv4Address &senderIface)
{
- const OlsrMessageHeader::Hello &hello = msg.GetHello ();
+ const olsr::MessageHeader::Hello &hello = msg.GetHello ();
LinkSensing (msg, hello, receiverIface, senderIface);
PopulateNeighborSet (msg, hello);
PopulateTwoHopNeighborSet (msg, hello);
@@ -836,10 +868,10 @@
/// \param sender_iface the address of the interface where the message was sent from.
///
void
-OlsrAgentImpl::ProcessTc (const OlsrMessageHeader &msg,
+AgentImpl::ProcessTc (const olsr::MessageHeader &msg,
const Ipv4Address &senderIface)
{
- const OlsrMessageHeader::Tc &tc = msg.GetTc ();
+ const olsr::MessageHeader::Tc &tc = msg.GetTc ();
Time now = Simulator::Now ();
// 1. If the sender interface of this message is not in the symmetric
@@ -899,7 +931,7 @@
// Schedules topology tuple deletion
m_events.Track (Simulator::Schedule (DELAY (topologyTuple.expirationTime),
- &OlsrAgentImpl::TopologyTupleTimerExpire,
+ &AgentImpl::TopologyTupleTimerExpire,
this, topologyTuple));
}
}
@@ -915,10 +947,10 @@
/// \param sender_iface the address of the interface where the message was sent from.
///
void
-OlsrAgentImpl::ProcessMid (const OlsrMessageHeader &msg,
+AgentImpl::ProcessMid (const olsr::MessageHeader &msg,
const Ipv4Address &senderIface)
{
- const OlsrMessageHeader::Mid &mid = msg.GetMid ();
+ const olsr::MessageHeader::Mid &mid = msg.GetMid ();
Time now = Simulator::Now ();
// 1. If the sender interface of this message is not in the symmetric
@@ -952,7 +984,7 @@
AddIfaceAssocTuple (tuple);
// Schedules iface association tuple deletion
Simulator::Schedule (DELAY (tuple.time),
- &OlsrAgentImpl::IfaceAssocTupleTimerExpire, this, tuple);
+ &AgentImpl::IfaceAssocTupleTimerExpire, this, tuple);
}
}
}
@@ -970,7 +1002,7 @@
/// \param local_iface the address of the interface where the message was received from.
///
void
-OlsrAgentImpl::ForwardDefault (OlsrMessageHeader olsrMessage,
+AgentImpl::ForwardDefault (olsr::MessageHeader olsrMessage,
DuplicateTuple *duplicated,
const Ipv4Address &localIface,
const Ipv4Address &senderAddress)
@@ -1033,7 +1065,7 @@
AddDuplicateTuple (newDup);
// Schedule dup tuple deletion
Simulator::Schedule (OLSR_DUP_HOLD_TIME,
- &OlsrAgentImpl::DupTupleTimerExpire, this, newDup);
+ &AgentImpl::DupTupleTimerExpire, this, newDup);
}
}
@@ -1047,7 +1079,7 @@
/// \param delay maximum delay the %OLSR message is going to be buffered.
///
void
-OlsrAgentImpl::QueueMessage (const OlsrMessageHeader &message, Time delay)
+AgentImpl::QueueMessage (const olsr::MessageHeader &message, Time delay)
{
m_queuedMessages.push_back (message);
if (not m_queuedMessagesTimer.IsRunning ())
@@ -1058,14 +1090,19 @@
}
void
-OlsrAgentImpl::SendPacket (Packet packet)
+AgentImpl::SendPacket (Packet packet, const MessageList &containedMessages)
{
- NS_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet");
+ NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet");
+
// Add a header
- OlsrPacketHeader header;
+ olsr::PacketHeader header;
header.SetPacketLength (header.GetSerializedSize () + packet.GetSize ());
header.SetPacketSequenceNumber (GetPacketSequenceNumber ());
packet.AddHeader (header);
+
+ // Trace it
+ m_txPacketTrace (header, containedMessages);
+
// Send it
m_sendSocket->Send (packet);
}
@@ -1078,23 +1115,27 @@
/// dictated by OLSR_MAX_MSGS constant.
///
void
-OlsrAgentImpl::SendQueuedMessages ()
+AgentImpl::SendQueuedMessages ()
{
Packet packet;
int numMessages = 0;
- NS_DEBUG ("Olsr node " << m_mainAddress << ": SendQueuedMessages");
+ NS_LOG_DEBUG ("Olsr node " << m_mainAddress << ": SendQueuedMessages");
- for (std::vector<OlsrMessageHeader>::const_iterator message = m_queuedMessages.begin ();
+ MessageList msglist;
+
+ for (std::vector<olsr::MessageHeader>::const_iterator message = m_queuedMessages.begin ();
message != m_queuedMessages.end ();
message++)
{
Packet p;
p.AddHeader (*message);
packet.AddAtEnd (p);
+ msglist.push_back (*message);
if (++numMessages == OLSR_MAX_MSGS)
{
- SendPacket (packet);
+ SendPacket (packet, msglist);
+ msglist.clear ();
// Reset variables for next packet
numMessages = 0;
packet = Packet ();
@@ -1103,7 +1144,7 @@
if (packet.GetSize ())
{
- SendPacket (packet);
+ SendPacket (packet, msglist);
}
m_queuedMessages.clear ();
@@ -1113,9 +1154,9 @@
/// \brief Creates a new %OLSR HELLO message which is buffered for being sent later on.
///
void
-OlsrAgentImpl::SendHello ()
+AgentImpl::SendHello ()
{
- OlsrMessageHeader msg;
+ olsr::MessageHeader msg;
Time now = Simulator::Now ();
msg.SetVTime (OLSR_NEIGHB_HOLD_TIME);
@@ -1123,12 +1164,12 @@
msg.SetTimeToLive (1);
msg.SetHopCount (0);
msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
- OlsrMessageHeader::Hello &hello = msg.GetHello ();
+ olsr::MessageHeader::Hello &hello = msg.GetHello ();
hello.SetHTime (m_helloInterval);
hello.willingness = m_willingness;
- std::vector<OlsrMessageHeader::Hello::LinkMessage>
+ std::vector<olsr::MessageHeader::Hello::LinkMessage>
&linkMessages = hello.linkMessages;
for (LinkSet::const_iterator link_tuple = m_state.GetLinks ().begin ();
@@ -1193,7 +1234,7 @@
}
}
- OlsrMessageHeader::Hello::LinkMessage linkMessage;
+ olsr::MessageHeader::Hello::LinkMessage linkMessage;
linkMessage.linkCode = (link_type & 0x03) | ((nb_type << 2) & 0x0f);
linkMessage.neighborInterfaceAddresses.push_back
(link_tuple->neighborIfaceAddr);
@@ -1207,8 +1248,8 @@
linkMessages.push_back (linkMessage);
}
- NS_DEBUG ("OLSR HELLO message size: " << int (msg.GetSerializedSize ())
- << " (with " << int (linkMessages.size ()) << " link messages)");
+ NS_LOG_DEBUG ("OLSR HELLO message size: " << int (msg.GetSerializedSize ())
+ << " (with " << int (linkMessages.size ()) << " link messages)");
QueueMessage (msg, JITTER);
}
@@ -1216,9 +1257,9 @@
/// \brief Creates a new %OLSR TC message which is buffered for being sent later on.
///
void
-OlsrAgentImpl::SendTc ()
+AgentImpl::SendTc ()
{
- OlsrMessageHeader msg;
+ olsr::MessageHeader msg;
msg.SetVTime (OLSR_TOP_HOLD_TIME);
msg.SetOriginatorAddress (m_mainAddress);
@@ -1226,7 +1267,7 @@
msg.SetHopCount (0);
msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
- OlsrMessageHeader::Tc &tc = msg.GetTc ();
+ olsr::MessageHeader::Tc &tc = msg.GetTc ();
tc.ansn = m_ansn;
for (MprSelectorSet::const_iterator mprsel_tuple = m_state.GetMprSelectors ().begin();
mprsel_tuple != m_state.GetMprSelectors ().end(); mprsel_tuple++)
@@ -1240,10 +1281,10 @@
/// \brief Creates a new %OLSR MID message which is buffered for being sent later on.
///
void
-OlsrAgentImpl::SendMid ()
+AgentImpl::SendMid ()
{
- OlsrMessageHeader msg;
- OlsrMessageHeader::Mid &mid = msg.GetMid ();
+ olsr::MessageHeader msg;
+ olsr::MessageHeader::Mid &mid = msg.GetMid ();
// A node which has only a single interface address participating in
// the MANET (i.e., running OLSR), MUST NOT generate any MID
@@ -1284,8 +1325,8 @@
/// \brief Updates Link Set according to a new received HELLO message (following RFC 3626
/// specification). Neighbor Set is also updated if needed.
void
-OlsrAgentImpl::LinkSensing (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello,
+AgentImpl::LinkSensing (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello,
const Ipv4Address &receiverIface,
const Ipv4Address &senderIface)
{
@@ -1310,7 +1351,7 @@
updated = true;
link_tuple->asymTime = now + msg.GetVTime ();
- for (std::vector<OlsrMessageHeader::Hello::LinkMessage>::const_iterator linkMessage =
+ for (std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator linkMessage =
hello.linkMessages.begin ();
linkMessage != hello.linkMessages.end ();
linkMessage++)
@@ -1358,7 +1399,7 @@
if (created && link_tuple != NULL)
{
m_events.Track (Simulator::Schedule (DELAY (std::min (link_tuple->time, link_tuple->symTime)),
- &OlsrAgentImpl::LinkTupleTimerExpire, this, *link_tuple));
+ &AgentImpl::LinkTupleTimerExpire, this, *link_tuple));
}
}
@@ -1366,8 +1407,8 @@
/// \brief Updates the Neighbor Set according to the information contained in a new received
/// HELLO message (following RFC 3626).
void
-OlsrAgentImpl::PopulateNeighborSet (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello)
+AgentImpl::PopulateNeighborSet (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello)
{
NeighborTuple *nb_tuple = m_state.FindNeighborTuple (msg.GetOriginatorAddress ());
if (nb_tuple != NULL)
@@ -1379,8 +1420,8 @@
/// \brief Updates the 2-hop Neighbor Set according to the information contained in a new
/// received HELLO message (following RFC 3626).
void
-OlsrAgentImpl::PopulateTwoHopNeighborSet (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello)
+AgentImpl::PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello)
{
Time now = Simulator::Now ();
@@ -1391,7 +1432,7 @@
{
if (link_tuple->symTime >= now)
{
- typedef std::vector<OlsrMessageHeader::Hello::LinkMessage> LinkMessageVec;
+ typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
for (LinkMessageVec::const_iterator linkMessage =
hello.linkMessages.begin ();
linkMessage != hello.linkMessages.end ();
@@ -1427,7 +1468,7 @@
// Schedules nb2hop tuple
// deletion
m_events.Track (Simulator::Schedule (DELAY (new_nb2hop_tuple.expirationTime),
- &OlsrAgentImpl::Nb2hopTupleTimerExpire, this,
+ &AgentImpl::Nb2hopTupleTimerExpire, this,
new_nb2hop_tuple));
}
else
@@ -1462,12 +1503,12 @@
/// \brief Updates the MPR Selector Set according to the information contained in a new
/// received HELLO message (following RFC 3626).
void
-OlsrAgentImpl::PopulateMprSelectorSet (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello)
+AgentImpl::PopulateMprSelectorSet (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello)
{
Time now = Simulator::Now ();
- typedef std::vector<OlsrMessageHeader::Hello::LinkMessage> LinkMessageVec;
+ typedef std::vector<olsr::MessageHeader::Hello::LinkMessage> LinkMessageVec;
for (LinkMessageVec::const_iterator linkMessage = hello.linkMessages.begin ();
linkMessage != hello.linkMessages.end ();
linkMessage++)
@@ -1496,7 +1537,7 @@
// Schedules mpr selector tuple deletion
m_events.Track (Simulator::Schedule
(DELAY (mprsel_tuple.expirationTime),
- &OlsrAgentImpl::MprSelTupleTimerExpire, this,
+ &AgentImpl::MprSelTupleTimerExpire, this,
mprsel_tuple));
}
else
@@ -1555,7 +1596,7 @@
/// \param tuple link tuple with the information of the link to the neighbor which has been lost.
///
void
-OlsrAgentImpl::NeighborLoss (const LinkTuple &tuple)
+AgentImpl::NeighborLoss (const LinkTuple &tuple)
{
// debug("%f: Node %d detects neighbor %d loss\n",
// Simulator::Now (),
@@ -1576,7 +1617,7 @@
/// \param tuple the duplicate tuple to be added.
///
void
-OlsrAgentImpl::AddDuplicateTuple (const DuplicateTuple &tuple)
+AgentImpl::AddDuplicateTuple (const DuplicateTuple &tuple)
{
/*debug("%f: Node %d adds dup tuple: addr = %d seq_num = %d\n",
Simulator::Now (),
@@ -1592,7 +1633,7 @@
/// \param tuple the duplicate tuple to be removed.
///
void
-OlsrAgentImpl::RemoveDuplicateTuple (const DuplicateTuple &tuple)
+AgentImpl::RemoveDuplicateTuple (const DuplicateTuple &tuple)
{
/*debug("%f: Node %d removes dup tuple: addr = %d seq_num = %d\n",
Simulator::Now (),
@@ -1609,7 +1650,7 @@
/// \param willingness willingness of the node which is going to be inserted in the Neighbor Set.
///
LinkTuple&
-OlsrAgentImpl::AddLinkTuple (const LinkTuple &tuple, uint8_t willingness)
+AgentImpl::AddLinkTuple (const LinkTuple &tuple, uint8_t willingness)
{
// debug("%f: Node %d adds link tuple: nb_addr = %d\n",
// now,
@@ -1636,7 +1677,7 @@
/// \param tuple the link tuple to be removed.
///
void
-OlsrAgentImpl::RemoveLinkTuple (const LinkTuple &tuple)
+AgentImpl::RemoveLinkTuple (const LinkTuple &tuple)
{
// nsaddr_t nb_addr = get_main_addr(tuple->neighborIfaceAddr);
// double now = Simulator::Now ();
@@ -1662,7 +1703,7 @@
/// \param tuple the link tuple which has been updated.
///
void
-OlsrAgentImpl::LinkTupleUpdated (const LinkTuple &tuple)
+AgentImpl::LinkTupleUpdated (const LinkTuple &tuple)
{
// Each time a link tuple changes, the associated neighbor tuple must be recomputed
NeighborTuple *nb_tuple =
@@ -1697,7 +1738,7 @@
/// \param tuple the neighbor tuple to be added.
///
void
-OlsrAgentImpl::AddNeighborTuple (const NeighborTuple &tuple)
+AgentImpl::AddNeighborTuple (const NeighborTuple &tuple)
{
// debug("%f: Node %d adds neighbor tuple: nb_addr = %d status = %s\n",
// Simulator::Now (),
@@ -1714,7 +1755,7 @@
/// \param tuple the neighbor tuple to be removed.
///
void
-OlsrAgentImpl::RemoveNeighborTuple (const NeighborTuple &tuple)
+AgentImpl::RemoveNeighborTuple (const NeighborTuple &tuple)
{
// debug("%f: Node %d removes neighbor tuple: nb_addr = %d status = %s\n",
// Simulator::Now (),
@@ -1731,7 +1772,7 @@
/// \param tuple the 2-hop neighbor tuple to be added.
///
void
-OlsrAgentImpl::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
+AgentImpl::AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
{
// debug("%f: Node %d adds 2-hop neighbor tuple: nb_addr = %d nb2hop_addr = %d\n",
// Simulator::Now (),
@@ -1748,7 +1789,7 @@
/// \param tuple the 2-hop neighbor tuple to be removed.
///
void
-OlsrAgentImpl::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
+AgentImpl::RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
{
// debug("%f: Node %d removes 2-hop neighbor tuple: nb_addr = %d nb2hop_addr = %d\n",
// Simulator::Now (),
@@ -1767,7 +1808,7 @@
/// \param tuple the MPR selector tuple to be added.
///
void
-OlsrAgentImpl::AddMprSelectorTuple (const MprSelectorTuple &tuple)
+AgentImpl::AddMprSelectorTuple (const MprSelectorTuple &tuple)
{
// debug("%f: Node %d adds MPR selector tuple: nb_addr = %d\n",
// Simulator::Now (),
@@ -1786,7 +1827,7 @@
/// \param tuple the MPR selector tuple to be removed.
///
void
-OlsrAgentImpl::RemoveMprSelectorTuple (const MprSelectorTuple &tuple)
+AgentImpl::RemoveMprSelectorTuple (const MprSelectorTuple &tuple)
{
// debug("%f: Node %d removes MPR selector tuple: nb_addr = %d\n",
// Simulator::Now (),
@@ -1803,7 +1844,7 @@
/// \param tuple the topology tuple to be added.
///
void
-OlsrAgentImpl::AddTopologyTuple (const TopologyTuple &tuple)
+AgentImpl::AddTopologyTuple (const TopologyTuple &tuple)
{
// debug("%f: Node %d adds topology tuple: dest_addr = %d last_addr = %d seq = %d\n",
// Simulator::Now (),
@@ -1821,7 +1862,7 @@
/// \param tuple the topology tuple to be removed.
///
void
-OlsrAgentImpl::RemoveTopologyTuple (const TopologyTuple &tuple)
+AgentImpl::RemoveTopologyTuple (const TopologyTuple &tuple)
{
// debug("%f: Node %d removes topology tuple: dest_addr = %d last_addr = %d seq = %d\n",
// Simulator::Now (),
@@ -1839,7 +1880,7 @@
/// \param tuple the interface association tuple to be added.
///
void
-OlsrAgentImpl::AddIfaceAssocTuple (const IfaceAssocTuple &tuple)
+AgentImpl::AddIfaceAssocTuple (const IfaceAssocTuple &tuple)
{
// debug("%f: Node %d adds iface association tuple: main_addr = %d iface_addr = %d\n",
// Simulator::Now (),
@@ -1856,7 +1897,7 @@
/// \param tuple the interface association tuple to be removed.
///
void
-OlsrAgentImpl::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple)
+AgentImpl::RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple)
{
// debug("%f: Node %d removes iface association tuple: main_addr = %d iface_addr = %d\n",
// Simulator::Now (),
@@ -1868,14 +1909,14 @@
}
-uint16_t OlsrAgentImpl::GetPacketSequenceNumber ()
+uint16_t AgentImpl::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 OlsrAgentImpl::GetMessageSequenceNumber ()
+uint16_t AgentImpl::GetMessageSequenceNumber ()
{
m_messageSequenceNumber = (m_messageSequenceNumber + 1) % (OLSR_MAX_SEQ_NUM + 1);
return m_messageSequenceNumber;
@@ -1887,7 +1928,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::HelloTimerExpire ()
+AgentImpl::HelloTimerExpire ()
{
SendHello ();
m_helloTimer.Schedule (m_helloInterval);
@@ -1898,7 +1939,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::TcTimerExpire ()
+AgentImpl::TcTimerExpire ()
{
if (m_state.GetMprSelectors ().size () > 0)
{
@@ -1913,7 +1954,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::MidTimerExpire ()
+AgentImpl::MidTimerExpire ()
{
SendMid ();
m_midTimer.Schedule (m_midInterval);
@@ -1927,7 +1968,7 @@
/// \param tuple The tuple which has expired.
///
void
-OlsrAgentImpl::DupTupleTimerExpire (DuplicateTuple tuple)
+AgentImpl::DupTupleTimerExpire (DuplicateTuple tuple)
{
if (tuple.expirationTime < Simulator::Now ())
{
@@ -1936,7 +1977,7 @@
else
{
m_events.Track (Simulator::Schedule (DELAY (tuple.expirationTime),
- &OlsrAgentImpl::DupTupleTimerExpire, this,
+ &AgentImpl::DupTupleTimerExpire, this,
tuple));
}
}
@@ -1953,7 +1994,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::LinkTupleTimerExpire (LinkTuple tuple)
+AgentImpl::LinkTupleTimerExpire (LinkTuple tuple)
{
Time now = Simulator::Now ();
@@ -1969,13 +2010,13 @@
NeighborLoss (tuple);
m_events.Track (Simulator::Schedule (DELAY (tuple.time),
- &OlsrAgentImpl::LinkTupleTimerExpire, this,
+ &AgentImpl::LinkTupleTimerExpire, this,
tuple));
}
else
{
m_events.Track (Simulator::Schedule (DELAY (std::min (tuple.time, tuple.symTime)),
- &OlsrAgentImpl::LinkTupleTimerExpire, this,
+ &AgentImpl::LinkTupleTimerExpire, this,
tuple));
}
}
@@ -1988,7 +2029,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::Nb2hopTupleTimerExpire (TwoHopNeighborTuple tuple)
+AgentImpl::Nb2hopTupleTimerExpire (TwoHopNeighborTuple tuple)
{
if (tuple.expirationTime < Simulator::Now ())
{
@@ -1997,7 +2038,7 @@
else
{
m_events.Track (Simulator::Schedule (DELAY (tuple.expirationTime),
- &OlsrAgentImpl::Nb2hopTupleTimerExpire,
+ &AgentImpl::Nb2hopTupleTimerExpire,
this, tuple));
}
}
@@ -2010,7 +2051,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::MprSelTupleTimerExpire (MprSelectorTuple tuple)
+AgentImpl::MprSelTupleTimerExpire (MprSelectorTuple tuple)
{
if (tuple.expirationTime < Simulator::Now ())
{
@@ -2019,7 +2060,7 @@
else
{
m_events.Track (Simulator::Schedule (DELAY (tuple.expirationTime),
- &OlsrAgentImpl::MprSelTupleTimerExpire,
+ &AgentImpl::MprSelTupleTimerExpire,
this, tuple));
}
}
@@ -2032,7 +2073,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::TopologyTupleTimerExpire (TopologyTuple tuple)
+AgentImpl::TopologyTupleTimerExpire (TopologyTuple tuple)
{
if (tuple.expirationTime < Simulator::Now ())
{
@@ -2041,7 +2082,7 @@
else
{
m_events.Track (Simulator::Schedule (DELAY (tuple.expirationTime),
- &OlsrAgentImpl::TopologyTupleTimerExpire,
+ &AgentImpl::TopologyTupleTimerExpire,
this, tuple));
}
}
@@ -2052,7 +2093,7 @@
/// \param e The event which has expired.
///
void
-OlsrAgentImpl::IfaceAssocTupleTimerExpire (IfaceAssocTuple tuple)
+AgentImpl::IfaceAssocTupleTimerExpire (IfaceAssocTuple tuple)
{
if (tuple.time < Simulator::Now ())
{
@@ -2061,14 +2102,14 @@
else
{
m_events.Track (Simulator::Schedule (DELAY (tuple.time),
- &OlsrAgentImpl::IfaceAssocTupleTimerExpire,
+ &AgentImpl::IfaceAssocTupleTimerExpire,
this, tuple));
}
}
-} // namespace ns3
+}} // namespace olsr, ns3
--- a/src/routing/olsr/olsr-agent-impl.h Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-agent-impl.h Tue Oct 30 10:31:20 2007 +0100
@@ -39,19 +39,19 @@
#include "ns3/socket.h"
#include "event-garbage-collector.h"
#include "ns3/timer.h"
+#include "ns3/callback-trace-source.h"
namespace ns3 {
-
-using namespace olsr;
+namespace olsr {
-class OlsrAgentImpl : public OlsrAgent
+class AgentImpl : public Agent
{
friend class OlsrTest;
public:
- OlsrAgentImpl (Ptr<Node> node);
+ AgentImpl (Ptr<Node> node);
virtual void Start ();
virtual void SetMainInterface (uint32_t interface);
@@ -89,7 +89,9 @@
protected:
void DoDispose ();
- void SendPacket (Packet packet);
+ Ptr<TraceResolver> GetTraceResolver (void) const;
+
+ void SendPacket (Packet packet, const MessageList &containedMessages);
/// Increments packet sequence number and returns the new value.
inline uint16_t GetPacketSequenceNumber ();
@@ -102,7 +104,7 @@
void MprComputation ();
void RoutingTableComputation ();
- Ipv4Address GetMainAddress (Ipv4Address iface_addr);
+ Ipv4Address GetMainAddress (Ipv4Address iface_addr) const;
// Timer handlers
Timer m_helloTimer;
@@ -123,14 +125,14 @@
void IfaceAssocTupleTimerExpire (IfaceAssocTuple tuple);
/// A list of pending messages which are buffered awaiting for being sent.
- std::vector<OlsrMessageHeader> m_queuedMessages;
+ olsr::MessageList m_queuedMessages;
Timer m_queuedMessagesTimer; // timer for throttling outgoing messages
- void ForwardDefault (OlsrMessageHeader olsrMessage,
+ void ForwardDefault (olsr::MessageHeader olsrMessage,
DuplicateTuple *duplicated,
const Ipv4Address &localIface,
const Ipv4Address &senderAddress);
- void QueueMessage (const OlsrMessageHeader &message, Time delay);
+ void QueueMessage (const olsr::MessageHeader &message, Time delay);
void SendQueuedMessages ();
void SendHello ();
void SendTc ();
@@ -153,32 +155,38 @@
void AddIfaceAssocTuple (const IfaceAssocTuple &tuple);
void RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple);
- void ProcessHello (const OlsrMessageHeader &msg,
+ void ProcessHello (const olsr::MessageHeader &msg,
const Ipv4Address &receiverIface,
const Ipv4Address &senderIface);
- void ProcessTc (const OlsrMessageHeader &msg,
+ void ProcessTc (const olsr::MessageHeader &msg,
const Ipv4Address &senderIface);
- void ProcessMid (const OlsrMessageHeader &msg,
+ void ProcessMid (const olsr::MessageHeader &msg,
const Ipv4Address &senderIface);
- void LinkSensing (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello,
+ void LinkSensing (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello,
const Ipv4Address &receiverIface,
const Ipv4Address &sender_iface);
- void PopulateNeighborSet (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello);
- void PopulateTwoHopNeighborSet (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello);
- void PopulateMprSelectorSet (const OlsrMessageHeader &msg,
- const OlsrMessageHeader::Hello &hello);
+ void PopulateNeighborSet (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello);
+ void PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello);
+ void PopulateMprSelectorSet (const olsr::MessageHeader &msg,
+ const olsr::MessageHeader::Hello &hello);
int Degree (NeighborTuple const &tuple);
Ipv4Address m_mainAddress;
Ptr<Socket> m_receiveSocket; // UDP socket for receving OSLR packets
Ptr<Socket> m_sendSocket; // UDP socket for sending OSLR packets
+
+ CallbackTraceSource <const PacketHeader &,
+ const MessageList &> m_rxPacketTrace;
+ CallbackTraceSource <const PacketHeader &,
+ const MessageList &> m_txPacketTrace;
+
};
-} // namespace ns3
+}} // namespace ns3
#endif
--- a/src/routing/olsr/olsr-agent.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-agent.cc Tue Oct 30 10:31:20 2007 +0100
@@ -22,8 +22,9 @@
#include "olsr-agent-impl.h"
namespace ns3 {
+namespace olsr {
-const InterfaceId OlsrAgent::iid = MakeInterfaceId ("OlsrAgent", Object::iid);
-const ClassId OlsrAgent::cid = MakeClassId< OlsrAgentImpl, Ptr<Node> > ("OlsrAgent", OlsrAgent::iid);
+const InterfaceId Agent::iid = MakeInterfaceId ("OlsrAgent", Object::iid);
+const ClassId Agent::cid = MakeClassId< AgentImpl, Ptr<Node> > ("OlsrAgent", Agent::iid);
-}
+}}
--- a/src/routing/olsr/olsr-agent.h Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-agent.h Tue Oct 30 10:31:20 2007 +0100
@@ -25,7 +25,7 @@
#include "ns3/component-manager.h"
namespace ns3 {
-
+namespace olsr {
/**
* \brief Class implementing the OLSR state machine
@@ -38,12 +38,12 @@
* Example:
*
* \code
- * Ptr<OlsrAgent> olsr = ComponentManager::Create<OlsrAgent, Ptr<Node> > (OlsrAgent::cid, OlsrAgent::iid, node);
+ * Ptr<olsr::Agent> olsr = ComponentManager::Create<olsr::Agent, Ptr<Node> > (olsr::Agent::cid, olsr::Agent::iid, node);
* agent->SetMainInterface (2);
* agent->Start ();
* \endcode
*/
-class OlsrAgent : public Object
+class Agent : public Object
{
public:
static const InterfaceId iid;
@@ -75,7 +75,7 @@
};
-}; // namespace ns3
+}} // namespace olsr, ns3
#endif /* OLSR_AGENT_H */
--- a/src/routing/olsr/olsr-header.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-header.cc Tue Oct 30 10:31:20 2007 +0100
@@ -27,6 +27,7 @@
#define OLSR_PKT_HEADER_SIZE 4
namespace ns3 {
+namespace olsr {
/// Scaling factor used in RFC 3626.
#define OLSR_C 0.0625
@@ -38,7 +39,7 @@
/// \return the number of seconds in mantissa/exponent format.
///
uint8_t
-OlsrSecondsToEmf (double seconds)
+SecondsToEmf (double seconds)
{
int a, b = 0;
@@ -77,7 +78,7 @@
/// \return the decimal number of seconds.
///
double
-OlsrEmfToSeconds (uint8_t olsrFormat)
+EmfToSeconds (uint8_t olsrFormat)
{
int a = (olsrFormat >> 4);
int b = (olsrFormat & 0xf);
@@ -89,34 +90,34 @@
// ---------------- OLSR Packet -------------------------------
-OlsrPacketHeader::OlsrPacketHeader ()
+PacketHeader::PacketHeader ()
{}
-OlsrPacketHeader::~OlsrPacketHeader ()
+PacketHeader::~PacketHeader ()
{}
uint32_t
-OlsrPacketHeader::GetUid (void)
+PacketHeader::GetUid (void)
{
- static uint32_t uid = AllocateUid<OlsrPacketHeader>
- ("OlsrPacketHeader.nsnam.org");
+ static uint32_t uid = AllocateUid<PacketHeader>
+ ("PacketHeader.nsnam.org");
return uid;
}
uint32_t
-OlsrPacketHeader::GetSerializedSize (void) const
+PacketHeader::GetSerializedSize (void) const
{
return OLSR_PKT_HEADER_SIZE;
}
void
-OlsrPacketHeader::Print (std::ostream &os) const
+PacketHeader::Print (std::ostream &os) const
{
// TODO
}
void
-OlsrPacketHeader::Serialize (Buffer::Iterator start) const
+PacketHeader::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
i.WriteHtonU16 (m_packetLength);
@@ -124,7 +125,7 @@
}
uint32_t
-OlsrPacketHeader::Deserialize (Buffer::Iterator start)
+PacketHeader::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
m_packetLength = i.ReadNtohU16 ();
@@ -135,23 +136,23 @@
// ---------------- OLSR Message -------------------------------
-OlsrMessageHeader::OlsrMessageHeader ()
- : m_messageType (OlsrMessageHeader::MessageType (0))
+MessageHeader::MessageHeader ()
+ : m_messageType (MessageHeader::MessageType (0))
{}
-OlsrMessageHeader::~OlsrMessageHeader ()
+MessageHeader::~MessageHeader ()
{}
uint32_t
-OlsrMessageHeader::GetUid (void)
+MessageHeader::GetUid (void)
{
- static uint32_t uid = AllocateUid<OlsrMessageHeader>
- ("OlsrMessageHeader.nsnam.org");
+ static uint32_t uid = AllocateUid<MessageHeader>
+ ("MessageHeader.nsnam.org");
return uid;
}
uint32_t
-OlsrMessageHeader::GetSerializedSize (void) const
+MessageHeader::GetSerializedSize (void) const
{
uint32_t size = OLSR_MSG_HEADER_SIZE;
switch (m_messageType)
@@ -175,13 +176,13 @@
}
void
-OlsrMessageHeader::Print (std::ostream &os) const
+MessageHeader::Print (std::ostream &os) const
{
// TODO
}
void
-OlsrMessageHeader::Serialize (Buffer::Iterator start) const
+MessageHeader::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
i.WriteU8 (m_messageType);
@@ -213,7 +214,7 @@
}
uint32_t
-OlsrMessageHeader::Deserialize (Buffer::Iterator start)
+MessageHeader::Deserialize (Buffer::Iterator start)
{
uint32_t size;
Buffer::Iterator i = start;
@@ -250,19 +251,19 @@
// ---------------- OLSR MID Message -------------------------------
uint32_t
-OlsrMessageHeader::Mid::GetSerializedSize (void) const
+MessageHeader::Mid::GetSerializedSize (void) const
{
return this->interfaceAddresses.size () * IPV4_ADDRESS_SIZE;
}
void
-OlsrMessageHeader::Mid::Print (std::ostream &os) const
+MessageHeader::Mid::Print (std::ostream &os) const
{
// TODO
}
void
-OlsrMessageHeader::Mid::Serialize (Buffer::Iterator start) const
+MessageHeader::Mid::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
@@ -274,7 +275,7 @@
}
uint32_t
-OlsrMessageHeader::Mid::Deserialize (Buffer::Iterator start, uint32_t messageSize)
+MessageHeader::Mid::Deserialize (Buffer::Iterator start, uint32_t messageSize)
{
Buffer::Iterator i = start;
@@ -295,7 +296,7 @@
// ---------------- OLSR HELLO Message -------------------------------
uint32_t
-OlsrMessageHeader::Hello::GetSerializedSize (void) const
+MessageHeader::Hello::GetSerializedSize (void) const
{
uint32_t size = 4;
for (std::vector<LinkMessage>::const_iterator iter = this->linkMessages.begin ();
@@ -309,13 +310,13 @@
}
void
-OlsrMessageHeader::Hello::Print (std::ostream &os) const
+MessageHeader::Hello::Print (std::ostream &os) const
{
// TODO
}
void
-OlsrMessageHeader::Hello::Serialize (Buffer::Iterator start) const
+MessageHeader::Hello::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
@@ -346,7 +347,7 @@
}
uint32_t
-OlsrMessageHeader::Hello::Deserialize (Buffer::Iterator start, uint32_t messageSize)
+MessageHeader::Hello::Deserialize (Buffer::Iterator start, uint32_t messageSize)
{
Buffer::Iterator i = start;
@@ -386,19 +387,19 @@
// ---------------- OLSR TC Message -------------------------------
uint32_t
-OlsrMessageHeader::Tc::GetSerializedSize (void) const
+MessageHeader::Tc::GetSerializedSize (void) const
{
return 4 + this->neighborAddresses.size () * IPV4_ADDRESS_SIZE;
}
void
-OlsrMessageHeader::Tc::Print (std::ostream &os) const
+MessageHeader::Tc::Print (std::ostream &os) const
{
// TODO
}
void
-OlsrMessageHeader::Tc::Serialize (Buffer::Iterator start) const
+MessageHeader::Tc::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
@@ -413,7 +414,7 @@
}
uint32_t
-OlsrMessageHeader::Tc::Deserialize (Buffer::Iterator start, uint32_t messageSize)
+MessageHeader::Tc::Deserialize (Buffer::Iterator start, uint32_t messageSize)
{
Buffer::Iterator i = start;
@@ -436,19 +437,19 @@
// ---------------- OLSR HNA Message -------------------------------
uint32_t
-OlsrMessageHeader::Hna::GetSerializedSize (void) const
+MessageHeader::Hna::GetSerializedSize (void) const
{
return 2*this->associations.size () * IPV4_ADDRESS_SIZE;
}
void
-OlsrMessageHeader::Hna::Print (std::ostream &os) const
+MessageHeader::Hna::Print (std::ostream &os) const
{
// TODO
}
void
-OlsrMessageHeader::Hna::Serialize (Buffer::Iterator start) const
+MessageHeader::Hna::Serialize (Buffer::Iterator start) const
{
Buffer::Iterator i = start;
@@ -460,7 +461,7 @@
}
uint32_t
-OlsrMessageHeader::Hna::Deserialize (Buffer::Iterator start, uint32_t messageSize)
+MessageHeader::Hna::Deserialize (Buffer::Iterator start, uint32_t messageSize)
{
Buffer::Iterator i = start;
@@ -478,7 +479,7 @@
-}; // namespace ns3
+}} // namespace olsr, ns3
#ifdef RUN_SELF_TESTS
@@ -515,11 +516,11 @@
Packet packet;
{
- OlsrPacketHeader hdr;
- OlsrMessageHeader msg1;
- OlsrMessageHeader::Mid &mid1 = msg1.GetMid ();
- OlsrMessageHeader msg2;
- OlsrMessageHeader::Mid &mid2 = msg2.GetMid ();
+ olsr::PacketHeader hdr;
+ olsr::MessageHeader msg1;
+ olsr::MessageHeader::Mid &mid1 = msg1.GetMid ();
+ olsr::MessageHeader msg2;
+ olsr::MessageHeader::Mid &mid2 = msg2.GetMid ();
// MID message #1
{
@@ -545,7 +546,7 @@
msg2.SetTimeToLive (254);
msg2.SetOriginatorAddress (Ipv4Address ("12.22.33.44"));
msg2.SetVTime (Seconds (10));
- msg2.SetMessageType (OlsrMessageHeader::MID_MESSAGE);
+ msg2.SetMessageType (olsr::MessageHeader::MID_MESSAGE);
msg2.SetMessageSequenceNumber (7);
// Build an OLSR packet header
@@ -560,22 +561,22 @@
}
{
- OlsrPacketHeader hdr;
+ olsr::PacketHeader hdr;
packet.RemoveHeader (hdr);
NS_TEST_ASSERT_EQUAL (hdr.GetPacketSequenceNumber (), 123);
uint32_t sizeLeft = hdr.GetPacketLength () - hdr.GetSerializedSize ();
{
- OlsrMessageHeader msg1;
+ olsr::MessageHeader msg1;
packet.RemoveHeader (msg1);
NS_TEST_ASSERT_EQUAL (msg1.GetTimeToLive (), 255);
NS_TEST_ASSERT_EQUAL (msg1.GetOriginatorAddress (), Ipv4Address ("11.22.33.44"));
NS_TEST_ASSERT_EQUAL (msg1.GetVTime (), Seconds (9));
- NS_TEST_ASSERT_EQUAL (msg1.GetMessageType (), OlsrMessageHeader::MID_MESSAGE);
+ NS_TEST_ASSERT_EQUAL (msg1.GetMessageType (), olsr::MessageHeader::MID_MESSAGE);
NS_TEST_ASSERT_EQUAL (msg1.GetMessageSequenceNumber (), 7);
- OlsrMessageHeader::Mid &mid1 = msg1.GetMid ();
+ olsr::MessageHeader::Mid &mid1 = msg1.GetMid ();
NS_TEST_ASSERT_EQUAL (mid1.interfaceAddresses.size (), 2);
NS_TEST_ASSERT_EQUAL (*mid1.interfaceAddresses.begin (), Ipv4Address ("1.2.3.4"));
@@ -584,17 +585,17 @@
}
{
// now read the second message
- OlsrMessageHeader msg2;
+ olsr::MessageHeader msg2;
packet.RemoveHeader (msg2);
NS_TEST_ASSERT_EQUAL (msg2.GetTimeToLive (), 254);
NS_TEST_ASSERT_EQUAL (msg2.GetOriginatorAddress (), Ipv4Address ("12.22.33.44"));
NS_TEST_ASSERT_EQUAL (msg2.GetVTime (), Seconds (10));
- NS_TEST_ASSERT_EQUAL (msg2.GetMessageType (), OlsrMessageHeader::MID_MESSAGE);
+ NS_TEST_ASSERT_EQUAL (msg2.GetMessageType (), olsr::MessageHeader::MID_MESSAGE);
NS_TEST_ASSERT_EQUAL (msg2.GetMessageSequenceNumber (), 7);
- OlsrMessageHeader::Mid mid2 = msg2.GetMid ();
+ olsr::MessageHeader::Mid mid2 = msg2.GetMid ();
NS_TEST_ASSERT_EQUAL (mid2.interfaceAddresses.size (), 2);
NS_TEST_ASSERT_EQUAL (*mid2.interfaceAddresses.begin (), Ipv4Address ("2.2.3.4"));
@@ -607,20 +608,20 @@
// Test the HELLO message
{
Packet packet;
- OlsrMessageHeader msgIn;
- OlsrMessageHeader::Hello &helloIn = msgIn.GetHello ();
+ olsr::MessageHeader msgIn;
+ olsr::MessageHeader::Hello &helloIn = msgIn.GetHello ();
helloIn.SetHTime (Seconds (7));
helloIn.willingness = 66;
{
- OlsrMessageHeader::Hello::LinkMessage lm1;
+ olsr::MessageHeader::Hello::LinkMessage lm1;
lm1.linkCode = 2;
lm1.neighborInterfaceAddresses.push_back (Ipv4Address ("1.2.3.4"));
lm1.neighborInterfaceAddresses.push_back (Ipv4Address ("1.2.3.5"));
helloIn.linkMessages.push_back (lm1);
- OlsrMessageHeader::Hello::LinkMessage lm2;
+ olsr::MessageHeader::Hello::LinkMessage lm2;
lm2.linkCode = 3;
lm2.neighborInterfaceAddresses.push_back (Ipv4Address ("2.2.3.4"));
lm2.neighborInterfaceAddresses.push_back (Ipv4Address ("2.2.3.5"));
@@ -629,9 +630,9 @@
packet.AddHeader (msgIn);
- OlsrMessageHeader msgOut;
+ olsr::MessageHeader msgOut;
packet.RemoveHeader (msgOut);
- OlsrMessageHeader::Hello &helloOut = msgOut.GetHello ();
+ olsr::MessageHeader::Hello &helloOut = msgOut.GetHello ();
NS_TEST_ASSERT_EQUAL (helloOut.GetHTime (), Seconds (7));
NS_TEST_ASSERT_EQUAL (helloOut.willingness, 66);
@@ -656,17 +657,17 @@
// Test the TC message
{
Packet packet;
- OlsrMessageHeader msgIn;
- OlsrMessageHeader::Tc &tcIn = msgIn.GetTc ();
+ olsr::MessageHeader msgIn;
+ olsr::MessageHeader::Tc &tcIn = msgIn.GetTc ();
tcIn.ansn = 0x1234;
tcIn.neighborAddresses.push_back (Ipv4Address ("1.2.3.4"));
tcIn.neighborAddresses.push_back (Ipv4Address ("1.2.3.5"));
packet.AddHeader (msgIn);
- OlsrMessageHeader msgOut;
+ olsr::MessageHeader msgOut;
packet.RemoveHeader (msgOut);
- OlsrMessageHeader::Tc &tcOut = msgOut.GetTc ();
+ olsr::MessageHeader::Tc &tcOut = msgOut.GetTc ();
NS_TEST_ASSERT_EQUAL (tcOut.ansn, 0x1234);
NS_TEST_ASSERT_EQUAL (tcOut.neighborAddresses.size (), 2);
@@ -683,18 +684,18 @@
// Test the HNA message
{
Packet packet;
- OlsrMessageHeader msgIn;
- OlsrMessageHeader::Hna &hnaIn = msgIn.GetHna ();
+ olsr::MessageHeader msgIn;
+ olsr::MessageHeader::Hna &hnaIn = msgIn.GetHna ();
- hnaIn.associations.push_back ((OlsrMessageHeader::Hna::Association)
+ hnaIn.associations.push_back ((olsr::MessageHeader::Hna::Association)
{ Ipv4Address ("1.2.3.4"), Ipv4Mask ("255.255.255.0")});
- hnaIn.associations.push_back ((OlsrMessageHeader::Hna::Association)
+ hnaIn.associations.push_back ((olsr::MessageHeader::Hna::Association)
{Ipv4Address ("1.2.3.5"), Ipv4Mask ("255.255.0.0")});
packet.AddHeader (msgIn);
- OlsrMessageHeader msgOut;
+ olsr::MessageHeader msgOut;
packet.RemoveHeader (msgOut);
- OlsrMessageHeader::Hna &hnaOut = msgOut.GetHna ();
+ olsr::MessageHeader::Hna &hnaOut = msgOut.GetHna ();
NS_TEST_ASSERT_EQUAL (hnaOut.associations.size (), 2);
@@ -714,8 +715,8 @@
for (int time = 1; time <= 30; time++)
{
- uint8_t emf = OlsrSecondsToEmf (time);
- double seconds = OlsrEmfToSeconds (emf);
+ uint8_t emf = olsr::SecondsToEmf (time);
+ double seconds = olsr::EmfToSeconds (emf);
if (seconds < 0 || fabs (seconds - time) > 0.1)
{
result = false;
--- a/src/routing/olsr/olsr-header.h Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-header.h Tue Oct 30 10:31:20 2007 +0100
@@ -29,10 +29,10 @@
namespace ns3 {
-
+namespace olsr {
-double OlsrEmfToSeconds (uint8_t emf);
-uint8_t OlsrSecondsToEmf (double seconds);
+double EmfToSeconds (uint8_t emf);
+uint8_t SecondsToEmf (double seconds);
// 3.3. Packet Format
//
@@ -66,11 +66,11 @@
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// : :
// (etc.)
-class OlsrPacketHeader : public Header
+class PacketHeader : public Header
{
public:
- OlsrPacketHeader ();
- virtual ~OlsrPacketHeader ();
+ PacketHeader ();
+ virtual ~PacketHeader ();
void SetPacketLength (uint16_t length)
{
@@ -113,7 +113,7 @@
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Time To Live | Hop Count | Message Sequence Number |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-class OlsrMessageHeader : public Header
+class MessageHeader : public Header
{
public:
@@ -124,8 +124,8 @@
HNA_MESSAGE = 4,
};
- OlsrMessageHeader ();
- virtual ~OlsrMessageHeader ();
+ MessageHeader ();
+ virtual ~MessageHeader ();
void SetMessageType (MessageType messageType)
{
@@ -138,11 +138,11 @@
void SetVTime (Time time)
{
- m_vTime = OlsrSecondsToEmf (time.GetSeconds ());
+ m_vTime = SecondsToEmf (time.GetSeconds ());
}
Time GetVTime () const
{
- return Seconds (OlsrEmfToSeconds (m_vTime));
+ return Seconds (EmfToSeconds (m_vTime));
}
void SetOriginatorAddress (Ipv4Address originatorAddress)
@@ -265,11 +265,11 @@
uint8_t hTime;
void SetHTime (Time time)
{
- this->hTime = OlsrSecondsToEmf (time.GetSeconds ());
+ this->hTime = SecondsToEmf (time.GetSeconds ());
}
Time GetHTime () const
{
- return Seconds (OlsrEmfToSeconds (this->hTime));
+ return Seconds (EmfToSeconds (this->hTime));
}
uint8_t willingness;
@@ -434,7 +434,37 @@
};
-}; // namespace ns3
+
+static inline std::ostream& operator<< (std::ostream& os, const PacketHeader & packet)
+{
+ packet.Print (os);
+ return os;
+}
+
+static inline std::ostream& operator<< (std::ostream& os, const MessageHeader & message)
+{
+ message.Print (os);
+ return os;
+}
+
+typedef std::vector<MessageHeader> MessageList;
+
+static inline std::ostream& operator<< (std::ostream& os, const MessageList & messages)
+{
+ os << "[";
+ for (std::vector<MessageHeader>::const_iterator messageIter = messages.begin ();
+ messageIter != messages.end (); messageIter++)
+ {
+ messageIter->Print (os);
+ if (messageIter+1 != messages.end ())
+ os << ", ";
+ }
+ os << "]";
+ return os;
+}
+
+
+}} // namespace olsr, ns3
#endif /* OLSR_HEADER_H */
--- a/src/routing/olsr/olsr-state.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-state.cc Tue Oct 30 10:31:20 2007 +0100
@@ -94,10 +94,10 @@
return NULL;
}
-NeighborTuple*
-OlsrState::FindSymNeighborTuple (Ipv4Address const &mainAddr)
+const NeighborTuple*
+OlsrState::FindSymNeighborTuple (Ipv4Address const &mainAddr) const
{
- for (NeighborSet::iterator it = m_neighborSet.begin ();
+ for (NeighborSet::const_iterator it = m_neighborSet.begin ();
it != m_neighborSet.end (); it++)
{
if (it->neighborMainAddr == mainAddr && it->status == NeighborTuple::STATUS_SYM)
@@ -400,6 +400,18 @@
return NULL;
}
+const IfaceAssocTuple*
+OlsrState::FindIfaceAssocTuple (Ipv4Address const &ifaceAddr) const
+{
+ for (IfaceAssocSet::const_iterator it = m_ifaceAssocSet.begin ();
+ it != m_ifaceAssocSet.end (); it++)
+ {
+ if (it->ifaceAddr == ifaceAddr)
+ return &(*it);
+ }
+ return NULL;
+}
+
void
OlsrState::EraseIfaceAssocTuple (const IfaceAssocTuple &tuple)
{
--- a/src/routing/olsr/olsr-state.h Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr-state.h Tue Oct 30 10:31:20 2007 +0100
@@ -64,7 +64,7 @@
return m_neighborSet;
}
NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
- NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr);
+ const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
uint8_t willingness);
void EraseNeighborTuple (const NeighborTuple &neighborTuple);
@@ -129,6 +129,7 @@
return m_ifaceAssocSet;
}
IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
+ const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
--- a/src/routing/olsr/olsr.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/olsr.cc Tue Oct 30 10:31:20 2007 +0100
@@ -33,8 +33,8 @@
void
EnableNode (Ptr<Node> node)
{
- ComponentManager::Create<OlsrAgent, Ptr<Node> >
- (OlsrAgent::cid, OlsrAgent::iid, node)->Start ();
+ ComponentManager::Create<olsr::Agent, Ptr<Node> >
+ (olsr::Agent::cid, olsr::Agent::iid, node)->Start ();
}
--- a/src/routing/olsr/routing-table.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/routing-table.cc Tue Oct 30 10:31:20 2007 +0100
@@ -28,11 +28,11 @@
#include "routing-table.h"
#include "ns3/packet.h"
#include "ns3/ipv4-header.h"
-#include "ns3/debug.h"
+#include "ns3/log.h"
namespace ns3 { namespace olsr {
-NS_DEBUG_COMPONENT_DEFINE ("OlsrRoutingTable");
+NS_LOG_COMPONENT_DEFINE ("OlsrRoutingTable");
///
/// \brief Clears the routing table and frees the memory assigned to each one of its entries.
@@ -119,19 +119,19 @@
Ipv4Route route = Ipv4Route::CreateHostRouteTo
(ipHeader.GetDestination (), entry2.nextAddr, entry2.interface);
- NS_DEBUG ("Olsr node" << m_mainAddress
- << ": RouteRequest for dest=" << ipHeader.GetDestination ()
- << " --> destHop=" << entry2.nextAddr
- << " interface=" << entry2.interface);
+ NS_LOG_DEBUG ("Olsr node" << m_mainAddress
+ << ": RouteRequest for dest=" << ipHeader.GetDestination ()
+ << " --> destHop=" << entry2.nextAddr
+ << " interface=" << entry2.interface);
routeReply (true, route, packet, ipHeader);
return true;
}
else
{
- NS_DEBUG ("Olsr node" << m_mainAddress
- << ": RouteRequest for dest=" << ipHeader.GetDestination ()
- << " --> NOT FOUND");
+ NS_LOG_DEBUG ("Olsr node" << m_mainAddress
+ << ": RouteRequest for dest=" << ipHeader.GetDestination ()
+ << " --> NOT FOUND");
return false;
}
}
--- a/src/routing/olsr/wscript Mon Oct 29 16:34:26 2007 +0100
+++ b/src/routing/olsr/wscript Tue Oct 30 10:31:20 2007 +0100
@@ -17,5 +17,6 @@
headers.source = [
'olsr-agent.h',
'olsr.h',
+ 'olsr-header.h',
]
--- a/tutorial/hello-simulator.cc Mon Oct 29 16:34:26 2007 +0100
+++ b/tutorial/hello-simulator.cc Tue Oct 30 10:31:20 2007 +0100
@@ -15,7 +15,6 @@
*/
#include "ns3/log.h"
-#include "ns3/debug.h"
NS_LOG_COMPONENT_DEFINE ("HelloSimulator");
@@ -24,8 +23,6 @@
int
main (int argc, char *argv[])
{
- DebugComponentEnable ("Log");
-
// LogComponentEnable ("HelloSimulator",
// LogLevel (LOG_LEVEL_INFO | LOG_PREFIX_ALL));
--- a/wscript Mon Oct 29 16:34:26 2007 +0100
+++ b/wscript Tue Oct 30 10:31:20 2007 +0100
@@ -118,7 +118,6 @@
variant_env.append_value('CXXFLAGS', ['-Werror'])
if 'debug' in Params.g_options.debug_level.lower():
- variant_env.append_value('CXXDEFINES', 'NS3_DEBUG_ENABLE')
variant_env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE')
variant_env.append_value('CXXDEFINES', 'NS3_LOG_ENABLE')