olsr: enforce correct code indentation

This commit is contained in:
Tommaso Pecorella
2016-03-11 21:21:36 +01:00
parent c7af99892b
commit 5d43515ff5
20 changed files with 458 additions and 350 deletions

View File

@@ -18,10 +18,10 @@
*
*/
//
//
// This script, adapted from examples/wireless/wifi-simple-adhoc illustrates
// the use of OLSR HNA.
//
//
// Network Topology:
//
// |------ OLSR ------| |---- non-OLSR ----|
@@ -74,14 +74,14 @@ void ReceivePacket (Ptr<Socket> socket)
NS_LOG_UNCOND ("Received one packet!");
}
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
uint32_t pktCount, Time pktInterval )
{
if (pktCount > 0)
{
socket->Send (Create<Packet> (pktSize));
Simulator::Schedule (pktInterval, &GenerateTraffic,
socket, pktSize,pktCount-1, pktInterval);
Simulator::Schedule (pktInterval, &GenerateTraffic,
socket, pktSize,pktCount - 1, pktInterval);
}
else
{
@@ -121,7 +121,7 @@ int main (int argc, char *argv[])
// turn off RTS/CTS for frames below 2200 bytes
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
// Fix non-unicast data rate to be the same as that of unicast
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
StringValue (phyMode));
NodeContainer olsrNodes;
@@ -141,7 +141,7 @@ int main (int argc, char *argv[])
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// This is one parameter that matters when using FixedRssLossModel
// set it to zero; otherwise, gain will be added
wifiPhy.Set ("RxGain", DoubleValue (0) );
wifiPhy.Set ("RxGain", DoubleValue (0) );
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
@@ -166,8 +166,8 @@ int main (int argc, char *argv[])
csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
NetDeviceContainer csmaDevices = csma.Install (NodeContainer (csmaNodes.Get (0), olsrNodes.Get (1)));
// Note that with FixedRssLossModel, the positions below are not
// used for received signal strength.
// Note that with FixedRssLossModel, the positions below are not
// used for received signal strength.
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
@@ -242,7 +242,7 @@ int main (int argc, char *argv[])
hnaEntries->AddNetworkRouteTo (Ipv4Address ("172.16.1.0"), Ipv4Mask ("255.255.255.0"), uint32_t (2), uint32_t (1));
olsrrp_Gw->SetRoutingTableAssociation (hnaEntries);
}
if (assocMethod2)
{
// Specify the required associations directly.
@@ -254,7 +254,7 @@ int main (int argc, char *argv[])
csma.EnablePcap ("olsr-hna", csmaDevices, false);
Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
Seconds (15.0), &GenerateTraffic,
Seconds (15.0), &GenerateTraffic,
source, packetSize, numPackets, interPacketInterval);
Simulator::Stop (Seconds (20.0));

View File

@@ -32,7 +32,7 @@
// - CBR/UDP flows from n0 to n4, and from n3 to n1
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
// (i.e., DataRate of 448,000 bps)
// - DropTail queues
// - DropTail queues
// - Tracing of queues and packet receptions to file "simple-point-to-point-olsr.tr"
#include <iostream>
@@ -53,16 +53,16 @@ using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("SimplePointToPointOlsrExample");
int
int
main (int argc, char *argv[])
{
// Users may find it convenient to turn on explicit debugging
// for selected modules; the below lines suggest how to do this
#if 0
#if 0
LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
#endif
// Set up some default values for the simulation. Use the
// Set up some default values for the simulation. Use the
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
@@ -130,7 +130,7 @@ main (int argc, char *argv[])
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
OnOffHelper onoff ("ns3::UdpSocketFactory",
OnOffHelper onoff ("ns3::UdpSocketFactory",
InetSocketAddress (i34.GetAddress (1), port));
onoff.SetConstantRate (DataRate ("448kb/s"));

View File

@@ -37,10 +37,10 @@ OlsrHelper::OlsrHelper (const OlsrHelper &o)
m_interfaceExclusions = o.m_interfaceExclusions;
}
OlsrHelper*
OlsrHelper::Copy (void) const
OlsrHelper*
OlsrHelper::Copy (void) const
{
return new OlsrHelper (*this);
return new OlsrHelper (*this);
}
void
@@ -48,7 +48,7 @@ OlsrHelper::ExcludeInterface (Ptr<Node> node, uint32_t interface)
{
std::map< Ptr<Node>, std::set<uint32_t> >::iterator it = m_interfaceExclusions.find (node);
if(it == m_interfaceExclusions.end ())
if (it == m_interfaceExclusions.end ())
{
std::set<uint32_t> interfaces;
interfaces.insert (interface);
@@ -61,14 +61,14 @@ OlsrHelper::ExcludeInterface (Ptr<Node> node, uint32_t interface)
}
}
Ptr<Ipv4RoutingProtocol>
Ptr<Ipv4RoutingProtocol>
OlsrHelper::Create (Ptr<Node> node) const
{
Ptr<olsr::RoutingProtocol> agent = m_agentFactory.Create<olsr::RoutingProtocol> ();
std::map<Ptr<Node>, std::set<uint32_t> >::const_iterator it = m_interfaceExclusions.find (node);
if(it != m_interfaceExclusions.end ())
if (it != m_interfaceExclusions.end ())
{
agent->SetInterfaceExclusions (it->second);
}
@@ -77,13 +77,13 @@ OlsrHelper::Create (Ptr<Node> node) const
return agent;
}
void
void
OlsrHelper::Set (std::string name, const AttributeValue &value)
{
m_agentFactory.Set (name, value);
}
int64_t
int64_t
OlsrHelper::AssignStreams (NodeContainer c, int64_t stream)
{
int64_t currentStream = stream;
@@ -108,7 +108,7 @@ OlsrHelper::AssignStreams (NodeContainer c, int64_t stream)
int16_t priority;
Ptr<Ipv4RoutingProtocol> listProto;
Ptr<olsr::RoutingProtocol> listOlsr;
for (uint32_t i = 0; i < list->GetNRoutingProtocols (); i++)
for (uint32_t i = 0; i < list->GetNRoutingProtocols (); i++)
{
listProto = list->GetRoutingProtocol (i, priority);
listOlsr = DynamicCast<olsr::RoutingProtocol> (listProto);

View File

@@ -34,7 +34,7 @@ namespace ns3 {
*
* \brief Helper class that adds OLSR routing to nodes.
*
* This class is expected to be used in conjunction with
* This class is expected to be used in conjunction with
* ns3::InternetStackHelper::SetRoutingHelper
*/
class OlsrHelper : public Ipv4RoutingHelper
@@ -53,8 +53,8 @@ public:
OlsrHelper (const OlsrHelper &);
/**
* \returns pointer to clone of this OlsrHelper
*
* \returns pointer to clone of this OlsrHelper
*
* This method is mainly for internal use by the other helpers;
* clients are expected to free the dynamic memory allocated by this method
*/
@@ -84,17 +84,17 @@ public:
*/
void Set (std::string name, const AttributeValue &value);
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned. The Install() method of the InternetStackHelper
* should have previously been called by the user.
*
* \param stream first stream index to use
* \param c NodeContainer of the set of nodes for which the OlsrRoutingProtocol
* should be modified to use a fixed stream
* \return the number of stream indices assigned by this helper
*/
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned. The Install() method of the InternetStackHelper
* should have previously been called by the user.
*
* \param stream first stream index to use
* \param c NodeContainer of the set of nodes for which the OlsrRoutingProtocol
* should be modified to use a fixed stream
* \return the number of stream indices assigned by this helper
*/
int64_t AssignStreams (NodeContainer c, int64_t stream);
private:

View File

@@ -30,7 +30,7 @@
#define OLSR_PKT_HEADER_SIZE 4
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("OlsrHeader");
namespace olsr {
@@ -51,17 +51,18 @@ SecondsToEmf (double seconds)
int a, b = 0;
// find the largest integer 'b' such that: T/C >= 2^b
for (b = 0; (seconds/OLSR_C) >= (1 << b); ++b)
;
NS_ASSERT ((seconds/OLSR_C) < (1 << b));
for (b = 0; (seconds / OLSR_C) >= (1 << b); ++b)
{
}
NS_ASSERT ((seconds / OLSR_C) < (1 << b));
b--;
NS_ASSERT ((seconds/OLSR_C) >= (1 << b));
NS_ASSERT ((seconds / OLSR_C) >= (1 << b));
// compute the expression 16*(T/(C*(2^b))-1), which may not be a integer
double tmp = 16*(seconds/(OLSR_C*(1<<b))-1);
double tmp = 16 * (seconds / (OLSR_C * (1 << b)) - 1);
// round it up. This results in the value for 'a'
a = (int) std::ceil (tmp-0.5);
a = (int) std::ceil (tmp - 0.5);
// if 'a' is equal to 16: increment 'b' by one, and set 'a' to 0
if (a == 16)
@@ -90,7 +91,7 @@ EmfToSeconds (uint8_t olsrFormat)
int a = (olsrFormat >> 4);
int b = (olsrFormat & 0xf);
// value = C*(1+a/16)*2^b [in seconds]
return OLSR_C * (1 + a/16.0) * (1 << b);
return OLSR_C * (1 + a / 16.0) * (1 << b);
}
@@ -123,13 +124,13 @@ PacketHeader::GetInstanceTypeId (void) const
return GetTypeId ();
}
uint32_t
uint32_t
PacketHeader::GetSerializedSize (void) const
{
return OLSR_PKT_HEADER_SIZE;
}
void
void
PacketHeader::Print (std::ostream &os) const
{
/// \todo
@@ -207,7 +208,7 @@ MessageHeader::GetSerializedSize (void) const
return size;
}
void
void
MessageHeader::Print (std::ostream &os) const
{
/// \todo
@@ -282,13 +283,13 @@ MessageHeader::Deserialize (Buffer::Iterator start)
// ---------------- OLSR MID Message -------------------------------
uint32_t
uint32_t
MessageHeader::Mid::GetSerializedSize (void) const
{
return this->interfaceAddresses.size () * IPV4_ADDRESS_SIZE;
}
void
void
MessageHeader::Mid::Print (std::ostream &os) const
{
/// \todo
@@ -318,7 +319,9 @@ MessageHeader::Mid::Deserialize (Buffer::Iterator start, uint32_t messageSize)
this->interfaceAddresses.erase (this->interfaceAddresses.begin (),
this->interfaceAddresses.end ());
for (int n = 0; n < numAddresses; ++n)
this->interfaceAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
{
this->interfaceAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
}
return GetSerializedSize ();
}
@@ -326,7 +329,7 @@ MessageHeader::Mid::Deserialize (Buffer::Iterator start, uint32_t messageSize)
// ---------------- OLSR HELLO Message -------------------------------
uint32_t
uint32_t
MessageHeader::Hello::GetSerializedSize (void) const
{
uint32_t size = 4;
@@ -340,7 +343,7 @@ MessageHeader::Hello::GetSerializedSize (void) const
return size;
}
void
void
MessageHeader::Hello::Print (std::ostream &os) const
{
/// \todo
@@ -417,13 +420,13 @@ MessageHeader::Hello::Deserialize (Buffer::Iterator start, uint32_t messageSize)
// ---------------- OLSR TC Message -------------------------------
uint32_t
uint32_t
MessageHeader::Tc::GetSerializedSize (void) const
{
return 4 + this->neighborAddresses.size () * IPV4_ADDRESS_SIZE;
}
void
void
MessageHeader::Tc::Print (std::ostream &os) const
{
/// \todo
@@ -459,7 +462,9 @@ MessageHeader::Tc::Deserialize (Buffer::Iterator start, uint32_t messageSize)
int numAddresses = (messageSize - 4) / IPV4_ADDRESS_SIZE;
this->neighborAddresses.clear ();
for (int n = 0; n < numAddresses; ++n)
this->neighborAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
{
this->neighborAddresses.push_back (Ipv4Address (i.ReadNtohU32 ()));
}
return messageSize;
}
@@ -467,13 +472,13 @@ MessageHeader::Tc::Deserialize (Buffer::Iterator start, uint32_t messageSize)
// ---------------- OLSR HNA Message -------------------------------
uint32_t
uint32_t
MessageHeader::Hna::GetSerializedSize (void) const
{
return 2*this->associations.size () * IPV4_ADDRESS_SIZE;
return 2 * this->associations.size () * IPV4_ADDRESS_SIZE;
}
void
void
MessageHeader::Hna::Print (std::ostream &os) const
{
/// \todo
@@ -496,7 +501,7 @@ MessageHeader::Hna::Deserialize (Buffer::Iterator start, uint32_t messageSize)
{
Buffer::Iterator i = start;
NS_ASSERT (messageSize % (IPV4_ADDRESS_SIZE*2) == 0);
NS_ASSERT (messageSize % (IPV4_ADDRESS_SIZE * 2) == 0);
int numAddresses = messageSize / IPV4_ADDRESS_SIZE / 2;
this->associations.clear ();
for (int n = 0; n < numAddresses; ++n)

View File

@@ -157,11 +157,11 @@ public:
class MessageHeader : public Header
{
public:
/**
* Message type
*/
enum MessageType {
enum MessageType
{
HELLO_MESSAGE = 1,
TC_MESSAGE = 2,
MID_MESSAGE = 3,
@@ -340,7 +340,7 @@ public:
* \param messageSize the message size.
* \returns the number of bytes read.
*/
uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
};
/**
@@ -373,12 +373,13 @@ public:
(etc.)
\endverbatim
*/
struct Hello
struct Hello
{
/**
* Link message item
*/
struct LinkMessage {
struct LinkMessage
{
uint8_t linkCode; //!< Link code
std::vector<Ipv4Address> neighborInterfaceAddresses; //!< Neighbor interface address container.
};
@@ -436,25 +437,25 @@ public:
uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
};
/**
* \ingroup olsr
* TC Message Format
*
\verbatim
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ANSN | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertised Neighbor Main Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertised Neighbor Main Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
struct Tc
/**
* \ingroup olsr
* TC Message Format
*
\verbatim
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ANSN | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertised Neighbor Main Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Advertised Neighbor Main Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
struct Tc
{
std::vector<Ipv4Address> neighborAddresses; //!< Neighbor address container.
uint16_t ansn; //!< Advertised Neighbor Sequence Number.
@@ -486,35 +487,35 @@ public:
* \param messageSize the message size.
* \returns the number of bytes read.
*/
uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
uint32_t Deserialize (Buffer::Iterator start, uint32_t messageSize);
};
/**
* \ingroup olsr
* HNA (Host Network Association) Message Format
*
\verbatim
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Netmask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Netmask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
/**
* \ingroup olsr
* HNA (Host Network Association) Message Format
*
\verbatim
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Netmask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Netmask |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\endverbatim
*/
struct Hna
{
/**
* Association item structure.
*/
/**
* Association item structure.
*/
struct Association
{
Ipv4Address address; //!< IPv4 Address.
@@ -554,7 +555,6 @@ public:
};
private:
/**
* Structure holding the message content.
*/
@@ -567,7 +567,6 @@ private:
} m_message; //!< The actual message being carried.
public:
/**
* Set the message type to MID and return the message content.
* \returns The MID message.
@@ -702,8 +701,10 @@ static inline std::ostream& operator<< (std::ostream& os, const MessageList & me
messageIter != messages.end (); messageIter++)
{
messageIter->Print (os);
if (messageIter+1 != messages.end ())
os << ", ";
if (messageIter + 1 != messages.end ())
{
os << ", ";
}
}
os << "]";
return os;

View File

@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2007 INESC Porto
*
* This program is free software; you can redistribute it and/or modify
@@ -33,7 +33,8 @@
#include "ns3/ipv4-address.h"
#include "ns3/nstime.h"
namespace ns3 { namespace olsr {
namespace ns3 {
namespace olsr {
/// \ingroup olsr
@@ -52,15 +53,15 @@ static inline bool
operator == (const IfaceAssocTuple &a, const IfaceAssocTuple &b)
{
return (a.ifaceAddr == b.ifaceAddr
&& a.mainAddr == b.mainAddr);
&& a.mainAddr == b.mainAddr);
}
static inline std::ostream&
operator << (std::ostream &os, const IfaceAssocTuple &tuple)
{
os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
<< ", mainAddr=" << tuple.mainAddr
<< ", time=" << tuple.time << ")";
<< ", mainAddr=" << tuple.mainAddr
<< ", time=" << tuple.time << ")";
return os;
}
@@ -84,18 +85,18 @@ static inline bool
operator == (const LinkTuple &a, const LinkTuple &b)
{
return (a.localIfaceAddr == b.localIfaceAddr
&& a.neighborIfaceAddr == b.neighborIfaceAddr);
&& a.neighborIfaceAddr == b.neighborIfaceAddr);
}
static inline std::ostream&
operator << (std::ostream &os, const LinkTuple &tuple)
{
os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
<< ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
<< ", symTime=" << tuple.symTime
<< ", asymTime=" << tuple.asymTime
<< ", expTime=" << tuple.time
<< ")";
<< ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
<< ", symTime=" << tuple.symTime
<< ", asymTime=" << tuple.asymTime
<< ", expTime=" << tuple.time
<< ")";
return os;
}
@@ -106,7 +107,8 @@ struct NeighborTuple
/// Main address of a neighbor node.
Ipv4Address neighborMainAddr;
/// Status of the link (Symmetric or not Symmetric).
enum Status {
enum Status
{
STATUS_NOT_SYM = 0, // "not symmetric"
STATUS_SYM = 1, // "symmetric"
} status; //!< Status of the link.
@@ -118,16 +120,16 @@ static inline bool
operator == (const NeighborTuple &a, const NeighborTuple &b)
{
return (a.neighborMainAddr == b.neighborMainAddr
&& a.status == b.status
&& a.willingness == b.willingness);
&& a.status == b.status
&& a.willingness == b.willingness);
}
static inline std::ostream&
operator << (std::ostream &os, const NeighborTuple &tuple)
{
os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
<< ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
<< ", willingness=" << (int) tuple.willingness << ")";
<< ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
<< ", willingness=" << (int) tuple.willingness << ")";
return os;
}
@@ -147,9 +149,9 @@ static inline std::ostream&
operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
{
os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
<< ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
<< ", expirationTime=" << tuple.expirationTime
<< ")";
<< ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
<< ", expirationTime=" << tuple.expirationTime
<< ")";
return os;
}
@@ -157,7 +159,7 @@ static inline bool
operator == (const TwoHopNeighborTuple &a, const TwoHopNeighborTuple &b)
{
return (a.neighborMainAddr == b.neighborMainAddr
&& a.twoHopNeighborAddr == b.twoHopNeighborAddr);
&& a.twoHopNeighborAddr == b.twoHopNeighborAddr);
}
/// \ingroup olsr
@@ -200,7 +202,7 @@ static inline bool
operator == (const DuplicateTuple &a, const DuplicateTuple &b)
{
return (a.address == b.address
&& a.sequenceNumber == b.sequenceNumber);
&& a.sequenceNumber == b.sequenceNumber);
}
/// \ingroup olsr
@@ -221,18 +223,18 @@ static inline bool
operator == (const TopologyTuple &a, const TopologyTuple &b)
{
return (a.destAddr == b.destAddr
&& a.lastAddr == b.lastAddr
&& a.sequenceNumber == b.sequenceNumber);
&& a.lastAddr == b.lastAddr
&& a.sequenceNumber == b.sequenceNumber);
}
static inline std::ostream&
operator << (std::ostream &os, const TopologyTuple &tuple)
{
os << "TopologyTuple(destAddr=" << tuple.destAddr
<< ", lastAddr=" << tuple.lastAddr
<< ", sequenceNumber=" << (int) tuple.sequenceNumber
<< ", expirationTime=" << tuple.expirationTime
<< ")";
<< ", lastAddr=" << tuple.lastAddr
<< ", sequenceNumber=" << (int) tuple.sequenceNumber
<< ", expirationTime=" << tuple.expirationTime
<< ")";
return os;
}
@@ -248,15 +250,15 @@ static inline bool
operator == (const Association &a, const Association &b)
{
return (a.networkAddr == b.networkAddr
&& a.netmask == b.netmask);
&& a.netmask == b.netmask);
}
static inline std::ostream&
operator << (std::ostream &os, const Association &tuple)
{
os << "Association(networkAddr=" << tuple.networkAddr
<< ", netmask=" << tuple.netmask
<< ")";
<< ", netmask=" << tuple.netmask
<< ")";
return os;
}
@@ -278,18 +280,18 @@ static inline bool
operator == (const AssociationTuple &a, const AssociationTuple &b)
{
return (a.gatewayAddr == b.gatewayAddr
&& a.networkAddr == b.networkAddr
&& a.netmask == b.netmask);
&& a.networkAddr == b.networkAddr
&& a.netmask == b.netmask);
}
static inline std::ostream&
operator << (std::ostream &os, const AssociationTuple &tuple)
{
os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
<< ", networkAddr=" << tuple.networkAddr
<< ", netmask=" << tuple.netmask
<< ", expirationTime=" << tuple.expirationTime
<< ")";
<< ", networkAddr=" << tuple.networkAddr
<< ", netmask=" << tuple.netmask
<< ", expirationTime=" << tuple.expirationTime
<< ")";
return os;
}
@@ -306,6 +308,7 @@ typedef std::vector<AssociationTuple> AssociationSet; //!< Association
typedef std::vector<Association> Associations; //!< Association Set type.
}} // namespace ns3, olsr
}
} // namespace ns3, olsr
#endif /* OLSR_REPOSITORIES_H */

View File

@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2007 INESC Porto
*
* This program is free software; you can redistribute it and/or modify
@@ -141,14 +141,14 @@
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("OlsrRoutingProtocol");
namespace olsr {
/********** OLSR class **********/
NS_OBJECT_ENSURE_REGISTERED (RoutingProtocol);
TypeId
TypeId
RoutingProtocol::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::olsr::RoutingProtocol")
@@ -195,12 +195,12 @@ RoutingProtocol::GetTypeId (void)
RoutingProtocol::RoutingProtocol ()
: m_routingTableAssociation (0),
m_ipv4 (0),
m_helloTimer (Timer::CANCEL_ON_DESTROY),
m_tcTimer (Timer::CANCEL_ON_DESTROY),
m_midTimer (Timer::CANCEL_ON_DESTROY),
m_hnaTimer (Timer::CANCEL_ON_DESTROY),
m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
m_ipv4 (0),
m_helloTimer (Timer::CANCEL_ON_DESTROY),
m_tcTimer (Timer::CANCEL_ON_DESTROY),
m_midTimer (Timer::CANCEL_ON_DESTROY),
m_hnaTimer (Timer::CANCEL_ON_DESTROY),
m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
{
m_uniformRandomVariable = CreateObject<UniformRandomVariable> ();
@@ -256,7 +256,7 @@ RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Time: " << Now ().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", OLSR Routing table" << std::endl;
@@ -319,7 +319,9 @@ void RoutingProtocol::DoInitialize ()
{
Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
if (addr == loopback)
continue;
{
continue;
}
if (addr != m_mainAddress)
{
@@ -333,11 +335,13 @@ void RoutingProtocol::DoInitialize ()
NS_ASSERT (GetMainAddress (addr) == m_mainAddress);
}
if(m_interfaceExclusions.find (i) != m_interfaceExclusions.end ())
continue;
if (m_interfaceExclusions.find (i) != m_interfaceExclusions.end ())
{
continue;
}
// Create a socket to listen only on this interface
Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (),
Ptr<Socket> socket = Socket::CreateSocket (GetObject<Node> (),
UdpSocketFactory::GetTypeId ());
socket->SetAllowBroadcast (true);
InetSocketAddress inetAddr (m_ipv4->GetAddress (i, 0).GetLocal (), OLSR_PORT_NUMBER);
@@ -352,7 +356,7 @@ void RoutingProtocol::DoInitialize ()
canRunOlsr = true;
}
if(canRunOlsr)
if (canRunOlsr)
{
HelloTimerExpire ();
TcTimerExpire ();
@@ -406,7 +410,9 @@ RoutingProtocol::RecvOlsr (Ptr<Socket> socket)
{
MessageHeader messageHeader;
if (packet->RemoveHeader (messageHeader) == 0)
NS_ASSERT (false);
{
NS_ASSERT (false);
}
sizeLeft -= messageHeader.GetSerializedSize ();
@@ -481,7 +487,7 @@ RoutingProtocol::RecvOlsr (Ptr<Socket> socket)
<< "s OLSR node " << m_mainAddress
<< " received HNA message of size " << messageHeader.GetSerializedSize ());
ProcessHna (messageHeader, senderIfaceAddr);
break;
break;
default:
NS_LOG_DEBUG ("OLSR message type " <<
@@ -542,7 +548,9 @@ RoutingProtocol::Degree (NeighborTuple const &tuple)
const NeighborTuple *nb_tuple =
m_state.FindNeighborTuple (nb2hop_tuple.neighborMainAddr);
if (nb_tuple == NULL)
degree++;
{
degree++;
}
}
}
return degree;
@@ -556,7 +564,7 @@ namespace {
/// \param neighborMainAddr Neighbor main address.
/// \param N2 Reference to the 2-hop neighbor set.
///
void
void
CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2)
{
// first gather all 2-hop neighbors to be removed
@@ -676,7 +684,9 @@ RoutingProtocol::MprComputation ()
next++;
os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
if (next != N2.end ())
os << ", ";
{
os << ", ";
}
}
os << "]";
NS_LOG_DEBUG ("N2: " << os.str ());
@@ -741,7 +751,7 @@ RoutingProtocol::MprComputation ()
{
if (coveredTwoHopNeighbors.find (twoHopNeigh->twoHopNeighborAddr) != coveredTwoHopNeighbors.end ())
{
// This works correctly only because it is known that twoHopNeigh is reachable by exactly one neighbor,
// This works correctly only because it is known that twoHopNeigh is reachable by exactly one neighbor,
// so only one record in N2 exists for each of them. This record is erased here.
NS_LOG_LOGIC ("2-hop neigh. " << twoHopNeigh->twoHopNeighborAddr << " is already covered by an MPR.");
twoHopNeigh = N2.erase (twoHopNeigh);
@@ -768,7 +778,9 @@ RoutingProtocol::MprComputation ()
next++;
os << iter->neighborMainAddr << "->" << iter->twoHopNeighborAddr;
if (next != N2.end ())
os << ", ";
{
os << ", ";
}
}
os << "]";
NS_LOG_DEBUG ("Step 4 iteration: N2=" << os.str ());
@@ -790,7 +802,9 @@ RoutingProtocol::MprComputation ()
{
TwoHopNeighborTuple const &nb2hop_tuple = *it2;
if (nb_tuple.neighborMainAddr == nb2hop_tuple.neighborMainAddr)
r++;
{
r++;
}
}
rs.insert (r);
reachability[r].push_back (&nb_tuple);
@@ -860,7 +874,9 @@ RoutingProtocol::MprComputation ()
next++;
os << *iter;
if (next != mprSet.end ())
os << ", ";
{
os << ", ";
}
}
os << "]";
NS_LOG_DEBUG ("Computed MPR set for node " << m_mainAddress << ": " << os.str ());
@@ -877,9 +893,13 @@ RoutingProtocol::GetMainAddress (Ipv4Address iface_addr) const
m_state.FindIfaceAssocTuple (iface_addr);
if (tuple != NULL)
return tuple->mainAddr;
{
return tuple->mainAddr;
}
else
return iface_addr;
{
return iface_addr;
}
}
void
@@ -1083,7 +1103,9 @@ RoutingProtocol::RoutingTableComputation ()
}
if (!added)
break;
{
break;
}
}
// 4. For each entry in the multiple interface association base
@@ -1164,8 +1186,8 @@ RoutingProtocol::RoutingTableComputation ()
for (routeIndex = 0; routeIndex < m_hnaRoutingTable->GetNRoutes (); routeIndex++)
{
Ipv4RoutingTableEntry route = m_hnaRoutingTable->GetRoute (routeIndex);
if (route.GetDestNetwork () == tuple.networkAddr &&
route.GetDestNetworkMask () == tuple.netmask)
if (route.GetDestNetwork () == tuple.networkAddr
&& route.GetDestNetworkMask () == tuple.netmask)
{
break;
}
@@ -1175,13 +1197,13 @@ RoutingProtocol::RoutingTableComputation ()
{
addRoute = true;
}
else if(gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance)
else if (gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance)
{
m_hnaRoutingTable->RemoveRoute (routeIndex);
addRoute = true;
}
if(addRoute && gatewayEntryExists)
if (addRoute && gatewayEntryExists)
{
m_hnaRoutingTable->AddNetworkRouteTo (tuple.networkAddr,
tuple.netmask,
@@ -1262,7 +1284,9 @@ RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg,
// 1-hop neighborhood of this node, the message MUST be discarded.
const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
if (link_tuple == NULL)
return;
{
return;
}
// 2. If there exist some tuple in the topology set where:
// T_last_addr == originator address AND
@@ -1272,7 +1296,9 @@ RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg,
const TopologyTuple *topologyTuple =
m_state.FindNewerTopologyTuple (msg.GetOriginatorAddress (), tc.ansn);
if (topologyTuple != NULL)
return;
{
return;
}
// 3. All tuples in the topology set where:
// T_last_addr == originator address AND
@@ -1306,7 +1332,7 @@ RoutingProtocol::ProcessTc (const olsr::MessageHeader &msg,
// T_last_addr = originator address,
// T_seq = ANSN,
// T_time = current time + validity time.
TopologyTuple topologyTuple;;
TopologyTuple topologyTuple;
topologyTuple.destAddr = addr;
topologyTuple.lastAddr = msg.GetOriginatorAddress ();
topologyTuple.sequenceNumber = tc.ansn;
@@ -1419,7 +1445,9 @@ RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg,
// 1-hop neighborhood of this node, the message MUST be discarded.
const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
if (link_tuple == NULL)
return;
{
return;
}
// 2. Otherwise, for each (network address, netmask) pair in the
// message:
@@ -1435,7 +1463,7 @@ RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg,
// A_netmask == netmask
// then the holding time for that tuple MUST be set to:
// A_time = current time + validity time
if(tuple != NULL)
if (tuple != NULL)
{
tuple->expirationTime = now + msg.GetVTime ();
}
@@ -1476,7 +1504,9 @@ RoutingProtocol::ForwardDefault (olsr::MessageHeader olsrMessage,
// 1-hop neighborhood the message must not be forwarded
const LinkTuple *linkTuple = m_state.FindSymLinkTuple (senderAddress, now);
if (linkTuple == NULL)
return;
{
return;
}
// If the message has already been considered for forwarding,
// it must not be retransmitted again
@@ -1542,7 +1572,7 @@ RoutingProtocol::QueueMessage (const olsr::MessageHeader &message, Time delay)
}
void
RoutingProtocol::SendPacket (Ptr<Packet> packet,
RoutingProtocol::SendPacket (Ptr<Packet> packet,
const MessageList &containedMessages)
{
NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet");
@@ -1760,10 +1790,14 @@ RoutingProtocol::SendMid ()
{
Ipv4Address addr = m_ipv4->GetAddress (i, 0).GetLocal ();
if (addr != m_mainAddress && addr != loopback && m_interfaceExclusions.find (i) == m_interfaceExclusions.end ())
mid.interfaceAddresses.push_back (addr);
{
mid.interfaceAddresses.push_back (addr);
}
}
if (mid.interfaceAddresses.size () == 0)
return;
{
return;
}
msg.SetVTime (OLSR_MID_HOLD_TIME);
msg.SetOriginatorAddress (m_mainAddress);
@@ -1935,10 +1969,18 @@ RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg,
const char *linkTypeName;
switch (lt)
{
case OLSR_UNSPEC_LINK: linkTypeName = "UNSPEC_LINK"; break;
case OLSR_ASYM_LINK: linkTypeName = "ASYM_LINK"; break;
case OLSR_SYM_LINK: linkTypeName = "SYM_LINK"; break;
case OLSR_LOST_LINK: linkTypeName = "LOST_LINK"; break;
case OLSR_UNSPEC_LINK:
linkTypeName = "UNSPEC_LINK";
break;
case OLSR_ASYM_LINK:
linkTypeName = "ASYM_LINK";
break;
case OLSR_SYM_LINK:
linkTypeName = "SYM_LINK";
break;
case OLSR_LOST_LINK:
linkTypeName = "LOST_LINK";
break;
/* no default, since lt must be in 0..3, covered above
default: linkTypeName = "(invalid value!)";
*/
@@ -1947,10 +1989,17 @@ RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg,
const char *neighborTypeName;
switch (nt)
{
case OLSR_NOT_NEIGH: neighborTypeName = "NOT_NEIGH"; break;
case OLSR_SYM_NEIGH: neighborTypeName = "SYM_NEIGH"; break;
case OLSR_MPR_NEIGH: neighborTypeName = "MPR_NEIGH"; break;
default: neighborTypeName = "(invalid value!)";
case OLSR_NOT_NEIGH:
neighborTypeName = "NOT_NEIGH";
break;
case OLSR_SYM_NEIGH:
neighborTypeName = "SYM_NEIGH";
break;
case OLSR_MPR_NEIGH:
neighborTypeName = "MPR_NEIGH";
break;
default:
neighborTypeName = "(invalid value!)";
}
NS_LOG_DEBUG ("Looking at HELLO link messages with Link Type "
@@ -1960,9 +2009,9 @@ RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg,
#endif // NS3_LOG_ENABLE
// We must not process invalid advertised links
if ((lt == OLSR_SYM_LINK && nt == OLSR_NOT_NEIGH) ||
(nt != OLSR_SYM_NEIGH && nt != OLSR_MPR_NEIGH
&& nt != OLSR_NOT_NEIGH))
if ((lt == OLSR_SYM_LINK && nt == OLSR_NOT_NEIGH)
|| (nt != OLSR_SYM_NEIGH && nt != OLSR_MPR_NEIGH
&& nt != OLSR_NOT_NEIGH))
{
NS_LOG_LOGIC ("HELLO link code is invalid => IGNORING");
continue;
@@ -2206,7 +2255,8 @@ RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg,
/// \param p the packet which couldn't be delivered by the MAC layer.
///
void
OLSR::mac_failed (Ptr<Packet> p) {
OLSR::mac_failed (Ptr<Packet> p)
{
double now = Simulator::Now ();
struct hdr_ip* ih = HDR_IP (p);
struct hdr_cmn* ch = HDR_CMN (p);
@@ -2216,13 +2266,15 @@ OLSR::mac_failed (Ptr<Packet> p) {
OLSR::node_id (ra_addr ()),
OLSR::node_id (ch->next_hop ()));
if ((u_int32_t)ih->daddr () == IP_BROADCAST) {
if ((u_int32_t)ih->daddr () == IP_BROADCAST)
{
drop (p, DROP_RTR_MAC_CALLBACK);
return;
}
OLSR_link_tuple* link_tuple = state_.find_link_tuple (ch->next_hop ());
if (link_tuple != NULL) {
if (link_tuple != NULL)
{
link_tuple->lost_time () = now + OLSR_NEIGHB_HOLD_TIME;
link_tuple->time () = now + OLSR_NEIGHB_HOLD_TIME;
nb_loss (link_tuple);
@@ -2592,9 +2644,13 @@ RoutingProtocol::LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr)
else if (tuple->symTime < now)
{
if (m_linkTupleTimerFirstTime)
m_linkTupleTimerFirstTime = false;
{
m_linkTupleTimerFirstTime = false;
}
else
NeighborLoss (*tuple);
{
NeighborLoss (*tuple);
}
m_events.Track (Simulator::Schedule (DELAY (tuple->time),
&RoutingProtocol::LinkTupleTimerExpire, this,
@@ -2731,7 +2787,9 @@ RoutingProtocol::Lookup (Ipv4Address const &dest,
m_table.find (dest);
// If there is no route to "dest", return NULL
if (it == m_table.end ())
return false;
{
return false;
}
outEntry = it->second;
return true;
}
@@ -2744,7 +2802,9 @@ RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry,
while (outEntry.destAddr != outEntry.nextAddr)
{
if (not Lookup (outEntry.nextAddr, outEntry))
return false;
{
return false;
}
}
return true;
}
@@ -2768,9 +2828,9 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDe
if (oif && m_ipv4->GetInterfaceForDevice (oif) != static_cast<int> (interfaceIdx))
{
// We do not attempt to perform a constrained routing search
// if the caller specifies the oif; we just enforce that
// that the found route matches the requested outbound interface
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
// if the caller specifies the oif; we just enforce that
// that the found route matches the requested outbound interface
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
<< ": RouteOutput for dest=" << header.GetDestination ()
<< " Route interface " << interfaceIdx
<< " does not match requested output interface "
@@ -2781,15 +2841,18 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDe
rtentry = Create<Ipv4Route> ();
rtentry->SetDestination (header.GetDestination ());
// the source address is the interface address that matches
// the destination address (when multiple are present on the
// the destination address (when multiple are present on the
// outgoing interface, one is selected via scoping rules)
NS_ASSERT (m_ipv4);
uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
NS_ASSERT (numOifAddresses > 0);
Ipv4InterfaceAddress ifAddr;
if (numOifAddresses == 1) {
if (numOifAddresses == 1)
{
ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
} else {
}
else
{
/// \todo Implment IP aliasing and OLSR
NS_FATAL_ERROR ("XXX Not implemented yet: IP aliasing and OLSR");
}
@@ -2797,7 +2860,7 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDe
rtentry->SetGateway (entry2.nextAddr);
rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
sockerr = Socket::ERROR_NOTERROR;
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
<< ": RouteOutput for dest=" << header.GetDestination ()
<< " --> nextHop=" << entry2.nextAddr
<< " interface=" << entry2.interface);
@@ -2805,7 +2868,7 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDe
found = true;
}
else
{
{
rtentry = m_hnaRoutingTable->RouteOutput (p, header, oif, sockerr);
if (rtentry)
@@ -2817,7 +2880,7 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDe
if (!found)
{
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
<< ": RouteOutput for dest=" << header.GetDestination ()
<< " No route to host");
sockerr = Socket::ERROR_NOROUTETOHOST;
@@ -2825,7 +2888,7 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDe
return rtentry;
}
bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
const Ipv4Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb)
@@ -2838,7 +2901,7 @@ bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
// Consume self-originated packets
if (IsMyOwnAddress (origin) == true)
{
return true;
return true;
}
// Local delivery
@@ -2855,7 +2918,7 @@ bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
else
{
// The local delivery callback is null. This may be a multicast
// or broadcast packet, so return false so that another
// or broadcast packet, so return false so that another
// multicast routing protocol can handle it. It should be possible
// to extend this to explicitly check whether it is a unicast
// packet, and invoke the error callback if so
@@ -2865,12 +2928,14 @@ bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
// Forwarding
Ptr<Ipv4Route> rtentry;
RoutingTableEntry entry1, entry2;
RoutingTableEntry entry1, entry2;
if (Lookup (header.GetDestination (), entry1))
{
{
bool foundSendEntry = FindSendEntry (entry1, entry2);
if (!foundSendEntry)
NS_FATAL_ERROR ("FindSendEntry failure");
{
NS_FATAL_ERROR ("FindSendEntry failure");
}
rtentry = Create<Ipv4Route> ();
rtentry->SetDestination (header.GetDestination ());
uint32_t interfaceIdx = entry2.interface;
@@ -2881,9 +2946,12 @@ bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
uint32_t numOifAddresses = m_ipv4->GetNAddresses (interfaceIdx);
NS_ASSERT (numOifAddresses > 0);
Ipv4InterfaceAddress ifAddr;
if (numOifAddresses == 1) {
if (numOifAddresses == 1)
{
ifAddr = m_ipv4->GetAddress (interfaceIdx, 0);
} else {
}
else
{
/// \todo Implment IP aliasing and OLSR
NS_FATAL_ERROR ("XXX Not implemented yet: IP aliasing and OLSR");
}
@@ -2901,7 +2969,7 @@ bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
}
else
{
if(m_hnaRoutingTable->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
if (m_hnaRoutingTable->RouteInput (p, header, idev, ucb, mcb, lcb, ecb))
{
return true;
}
@@ -2909,7 +2977,7 @@ bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
{
#ifdef NS3_LOG_ENABLE
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
<< ": RouteInput for dest=" << header.GetDestination ()
<< " --> NOT FOUND; ** Dumping routing table...");
@@ -2927,18 +2995,22 @@ bool RoutingProtocol::RouteInput (Ptr<const Packet> p,
}
}
}
void
void
RoutingProtocol::NotifyInterfaceUp (uint32_t i)
{}
void
{
}
void
RoutingProtocol::NotifyInterfaceDown (uint32_t i)
{}
void
{
}
void
RoutingProtocol::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
{}
void
{
}
void
RoutingProtocol::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
{}
{
}
void
@@ -3040,7 +3112,7 @@ RoutingProtocol::Dump (void)
iter != m_state.GetTwoHopNeighbors ().end (); iter++)
{
if (now < iter->expirationTime)
{
{
NS_LOG_DEBUG (" " << *iter);
}
}

View File

@@ -51,7 +51,7 @@ namespace olsr {
///
/// \defgroup olsr OLSR Routing
/// This section documents the API of the ns-3 OLSR module. For a generic
/// This section documents the API of the ns-3 OLSR module. For a generic
/// functional description, please refer to the ns-3 manual.
/// \ingroup olsr
@@ -64,8 +64,10 @@ struct RoutingTableEntry
uint32_t distance; //!< Distance in hops to the destination.
RoutingTableEntry () : // default values
destAddr (), nextAddr (),
interface (0), distance (0) {};
destAddr (), nextAddr (),
interface (0), distance (0)
{
}
};
class RoutingProtocol;
@@ -108,14 +110,14 @@ public:
*/
std::vector<RoutingTableEntry> GetRoutingTableEntries () const;
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
* \return the number of stream indices assigned by this model
*/
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
* \return the number of stream indices assigned by this model
*/
int64_t AssignStreams (int64_t stream);
/**
@@ -124,8 +126,7 @@ public:
* \param [in] header
* \param [in] messages
*/
typedef void (* PacketTxRxTracedCallback)
(const PacketHeader & header, const MessageList & messages);
typedef void (* PacketTxRxTracedCallback)(const PacketHeader & header, const MessageList & messages);
/**
* TracedCallback signature for routing table computation.
@@ -200,7 +201,7 @@ private:
Ptr<Ipv4StaticRouting> m_hnaRoutingTable; //!< Routing table for HNA routes
EventGarbageCollector m_events; //!< Running events.
uint16_t m_packetSequenceNumber; //!< Packets sequence number counter.
uint16_t m_messageSequenceNumber; //!< Messages sequence number counter.
uint16_t m_ansn; //!< Advertised Neighbor Set sequence number.
@@ -223,7 +224,10 @@ private:
* Returns the routing table size.
* \return The routing table size.
*/
uint32_t GetSize () const { return m_table.size (); }
uint32_t GetSize () const
{
return m_table.size ();
}
/**
* \brief Deletes the entry whose destination address is given.
@@ -500,7 +504,7 @@ private:
/**
* \brief Creates a new %OLSR HELLO message which is buffered for being sent later on.
*/
void SendHello ();
void SendHello ();
/**
* \brief Creates a new %OLSR TC message which is buffered for being sent later on.
@@ -763,7 +767,7 @@ private:
TracedCallback <uint32_t> m_routingTableChanged;
/// Provides uniform random variables.
Ptr<UniformRandomVariable> m_uniformRandomVariable;
Ptr<UniformRandomVariable> m_uniformRandomVariable;
};

View File

@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2007 INESC Porto
*
* This program is free software; you can redistribute it and/or modify
@@ -41,7 +41,9 @@ OlsrState::FindMprSelectorTuple (Ipv4Address const &mainAddr)
it != m_mprSelectorSet.end (); it++)
{
if (it->mainAddr == mainAddr)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -64,7 +66,7 @@ void
OlsrState::EraseMprSelectorTuples (const Ipv4Address &mainAddr)
{
for (MprSelectorSet::iterator it = m_mprSelectorSet.begin ();
it != m_mprSelectorSet.end ();)
it != m_mprSelectorSet.end (); )
{
if (it->mainAddr == mainAddr)
{
@@ -95,7 +97,9 @@ OlsrState::PrintMprSelectorSet () const
next++;
os << iter->mainAddr;
if (next != m_mprSelectorSet.end ())
os << ", ";
{
os << ", ";
}
}
os << "]";
return os.str ();
@@ -111,7 +115,9 @@ OlsrState::FindNeighborTuple (Ipv4Address const &mainAddr)
it != m_neighborSet.end (); it++)
{
if (it->neighborMainAddr == mainAddr)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -123,7 +129,9 @@ OlsrState::FindSymNeighborTuple (Ipv4Address const &mainAddr) const
it != m_neighborSet.end (); it++)
{
if (it->neighborMainAddr == mainAddr && it->status == NeighborTuple::STATUS_SYM)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -135,7 +143,9 @@ OlsrState::FindNeighborTuple (Ipv4Address const &mainAddr, uint8_t willingness)
it != m_neighborSet.end (); it++)
{
if (it->neighborMainAddr == mainAddr && it->willingness == willingness)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -221,7 +231,7 @@ OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr,
const Ipv4Address &twoHopNeighborAddr)
{
for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin ();
it != m_twoHopNeighborSet.end ();)
it != m_twoHopNeighborSet.end (); )
{
if (it->neighborMainAddr == neighborMainAddr
&& it->twoHopNeighborAddr == twoHopNeighborAddr)
@@ -239,7 +249,7 @@ void
OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr)
{
for (TwoHopNeighborSet::iterator it = m_twoHopNeighborSet.begin ();
it != m_twoHopNeighborSet.end ();)
it != m_twoHopNeighborSet.end (); )
{
if (it->neighborMainAddr == neighborMainAddr)
{
@@ -287,7 +297,9 @@ OlsrState::FindDuplicateTuple (Ipv4Address const &addr, uint16_t sequenceNumber)
it != m_duplicateSet.end (); it++)
{
if (it->address == addr && it->sequenceNumber == sequenceNumber)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -321,7 +333,9 @@ OlsrState::FindLinkTuple (Ipv4Address const & ifaceAddr)
it != m_linkSet.end (); it++)
{
if (it->neighborIfaceAddr == ifaceAddr)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -335,9 +349,13 @@ OlsrState::FindSymLinkTuple (Ipv4Address const &ifaceAddr, Time now)
if (it->neighborIfaceAddr == ifaceAddr)
{
if (it->symTime > now)
return &(*it);
{
return &(*it);
}
else
break;
{
break;
}
}
}
return NULL;
@@ -374,7 +392,9 @@ OlsrState::FindTopologyTuple (Ipv4Address const &destAddr,
it != m_topologySet.end (); it++)
{
if (it->destAddr == destAddr && it->lastAddr == lastAddr)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -386,7 +406,9 @@ OlsrState::FindNewerTopologyTuple (Ipv4Address const & lastAddr, uint16_t ansn)
it != m_topologySet.end (); it++)
{
if (it->lastAddr == lastAddr && it->sequenceNumber > ansn)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -409,7 +431,7 @@ void
OlsrState::EraseOlderTopologyTuples (const Ipv4Address &lastAddr, uint16_t ansn)
{
for (TopologySet::iterator it = m_topologySet.begin ();
it != m_topologySet.end ();)
it != m_topologySet.end (); )
{
if (it->lastAddr == lastAddr && it->sequenceNumber < ansn)
{
@@ -437,7 +459,9 @@ OlsrState::FindIfaceAssocTuple (Ipv4Address const &ifaceAddr)
it != m_ifaceAssocSet.end (); it++)
{
if (it->ifaceAddr == ifaceAddr)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -449,7 +473,9 @@ OlsrState::FindIfaceAssocTuple (Ipv4Address const &ifaceAddr) const
it != m_ifaceAssocSet.end (); it++)
{
if (it->ifaceAddr == ifaceAddr)
return &(*it);
{
return &(*it);
}
}
return NULL;
}
@@ -482,7 +508,9 @@ OlsrState::FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const
it != m_ifaceAssocSet.end (); it++)
{
if (it->mainAddr == neighborMainAddr)
retval.push_back (it->ifaceAddr);
{
retval.push_back (it->ifaceAddr);
}
}
return retval;
}
@@ -543,4 +571,5 @@ OlsrState::InsertAssociation (const Association &tuple)
m_associations.push_back (tuple);
}
}} // namespace olsr, ns3
}
} // namespace olsr, ns3

View File

@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2007 INESC Porto
*
* This program is free software; you can redistribute it and/or modify
@@ -49,9 +49,9 @@ protected:
Associations m_associations; //!< The node's local Host Network Associations that will be advertised using HNA messages.
public:
OlsrState ()
{}
{
}
// MPR selector
@@ -430,6 +430,7 @@ public:
};
}} // namespace olsr,ns3
}
} // namespace olsr,ns3
#endif /* OLSR_STATE_H */

View File

@@ -17,7 +17,7 @@
// OLSR was observed to not converge in simple 3-nodes varying topology.
// https://www.nsnam.org/bugzilla/show_bug.cgi?id=780
// tcpdump -r bug780-0-0.pcap -nn -tt icmp | wc
// tcpdump -r bug780-0-0.pcap -nn -tt icmp | wc
// should show about 395 packets; there is a ping outage from time
// 123-127 due to the mobility.
@@ -40,18 +40,16 @@
#include "ns3/icmpv4.h"
#include "bug780-test.h"
namespace ns3
{
namespace olsr
{
namespace ns3 {
namespace olsr {
Bug780Test::Bug780Test() :
Bug780Test::Bug780Test () :
TestCase ("Test OLSR bug 780"),
m_time (Seconds (200.0)), m_seq (0), m_recvCount (0)
{
}
Bug780Test::~Bug780Test()
Bug780Test::~Bug780Test ()
{
}
@@ -162,7 +160,7 @@ Bug780Test::Receive (Ptr<Socket> socket)
p->RemoveHeader (icmp);
if (icmp.GetType () == Icmpv4Header::ECHO_REPLY)
{
m_recvCount ++;
m_recvCount++;
}
}
}

View File

@@ -23,15 +23,13 @@
#include "ns3/nstime.h"
#include "ns3/node-container.h"
namespace ns3
{
namespace olsr
{
/** See \bugid{780} */
namespace ns3 {
namespace olsr {
/** See \bugid{780} */
class Bug780Test : public TestCase
{
public:
Bug780Test ();
Bug780Test ();
~Bug780Test ();
private:
/// Total simulation time

View File

@@ -37,18 +37,16 @@
#include "ns3/udp-header.h"
#include "ns3/olsr-header.h"
namespace ns3
{
namespace olsr
{
namespace ns3 {
namespace olsr {
HelloRegressionTest::HelloRegressionTest() :
HelloRegressionTest::HelloRegressionTest () :
TestCase ("Test OLSR Hello messages generation"),
m_time (Seconds (5)), m_countA (0), m_countB (0)
{
}
HelloRegressionTest::~HelloRegressionTest()
HelloRegressionTest::~HelloRegressionTest ()
{
}
@@ -133,7 +131,7 @@ HelloRegressionTest::ReceivePktProbeA (Ptr<Socket> socket)
}
std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter ++)
for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter++)
{
if (m_countA == 1)
{
@@ -148,7 +146,7 @@ HelloRegressionTest::ReceivePktProbeA (Ptr<Socket> socket)
NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), "Only one neighbor.");
}
m_countA ++;
m_countA++;
}
void
@@ -181,7 +179,7 @@ HelloRegressionTest::ReceivePktProbeB (Ptr<Socket> socket)
}
std::vector<olsr::MessageHeader::Hello::LinkMessage>::const_iterator iter;
for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter ++)
for (iter = hello.linkMessages.begin (); iter != hello.linkMessages.end (); iter++)
{
if (m_countA == 1)
{
@@ -196,7 +194,7 @@ HelloRegressionTest::ReceivePktProbeB (Ptr<Socket> socket)
NS_TEST_EXPECT_MSG_EQ (iter->neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), "Only one neighbor.");
}
m_countB ++;
m_countB++;
}
}

View File

@@ -27,17 +27,15 @@
#include "ns3/ipv4-raw-socket-impl.h"
#include "ns3/node-container.h"
namespace ns3
{
namespace olsr
{
namespace ns3 {
namespace olsr {
/**
* \ingroup olsr
* \brief Trivial (still useful) test of OLSR operation
*
* This test creates 2 stations with point-to-point link and runs OLSR without any extra traffic.
*
* This test creates 2 stations with point-to-point link and runs OLSR without any extra traffic.
* It is expected that only HELLO messages will be sent.
*
*
* Expected trace (5 seconds):
\verbatim
1 2
@@ -47,12 +45,12 @@ namespace olsr
|<------| HELLO (Link type: Asymmetric link, Neighbor address: 10.1.1.1) src = 10.1.1.2
|------>| HELLO (Link type: Symmetric link, Neighbor address: 10.1.1.2) src = 10.1.1.1
|<------| HELLO (Link type: Symmetric link, Neighbor address: 10.1.1.1) src = 10.1.1.2
\endverbatim
\endverbatim
*/
class HelloRegressionTest : public TestCase
{
public:
HelloRegressionTest ();
HelloRegressionTest ();
~HelloRegressionTest ();
private:
/// Total simulation time

View File

@@ -24,7 +24,8 @@
using namespace ns3;
class OlsrEmfTestCase : public TestCase {
class OlsrEmfTestCase : public TestCase
{
public:
OlsrEmfTestCase ();
virtual void DoRun (void);
@@ -47,7 +48,8 @@ OlsrEmfTestCase::DoRun (void)
}
class OlsrMidTestCase : public TestCase {
class OlsrMidTestCase : public TestCase
{
public:
OlsrMidTestCase ();
virtual void DoRun (void);
@@ -153,7 +155,8 @@ OlsrMidTestCase::DoRun (void)
}
class OlsrHelloTestCase : public TestCase {
class OlsrHelloTestCase : public TestCase
{
public:
OlsrHelloTestCase ();
virtual void DoRun (void);
@@ -213,7 +216,8 @@ OlsrHelloTestCase::DoRun (void)
}
class OlsrTcTestCase : public TestCase {
class OlsrTcTestCase : public TestCase
{
public:
OlsrTcTestCase ();
virtual void DoRun (void);
@@ -251,7 +255,8 @@ OlsrTcTestCase::DoRun (void)
}
class OlsrHnaTestCase : public TestCase {
class OlsrHnaTestCase : public TestCase
{
public:
OlsrHnaTestCase ();
virtual void DoRun (void);
@@ -302,7 +307,7 @@ public:
OlsrTestSuite ();
} g_olsrTestSuite;
OlsrTestSuite::OlsrTestSuite()
OlsrTestSuite::OlsrTestSuite ()
: TestSuite ("routing-olsr-header", UNIT)
{
AddTestCase (new OlsrHnaTestCase (), TestCase::QUICK);

View File

@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2004 Francisco J. Ros
* Copyright (c) 2007 INESC Porto
*
* This program is free software; you can redistribute it and/or modify
@@ -41,13 +41,13 @@ using namespace ns3;
using namespace olsr;
/// Testcase for MPR computation mechanism
class OlsrMprTestCase : public TestCase {
class OlsrMprTestCase : public TestCase
{
public:
OlsrMprTestCase ();
~OlsrMprTestCase ();
/// \brief Run test case
virtual void DoRun (void);
;
};
@@ -63,10 +63,10 @@ OlsrMprTestCase::DoRun ()
{
Ptr<RoutingProtocol> protocol = CreateObject<RoutingProtocol> ();
protocol->m_mainAddress = Ipv4Address ("10.0.0.1");
OlsrState & state = protocol->m_state;
OlsrState & state = protocol->m_state;
/*
* 1 -- 2
* 1 -- 2
* | |
* 3 -- 4
*
@@ -78,7 +78,7 @@ OlsrMprTestCase::DoRun ()
neigbor.neighborMainAddr = Ipv4Address ("10.0.0.2");
protocol->m_state.InsertNeighborTuple (neigbor);
neigbor.neighborMainAddr = Ipv4Address ("10.0.0.3");
protocol->m_state.InsertNeighborTuple (neigbor);
protocol->m_state.InsertNeighborTuple (neigbor);
TwoHopNeighborTuple tuple;
tuple.expirationTime = Seconds (3600);
tuple.neighborMainAddr = Ipv4Address ("10.0.0.2");
@@ -91,7 +91,7 @@ OlsrMprTestCase::DoRun ()
protocol->MprComputation ();
NS_TEST_EXPECT_MSG_EQ (state.GetMprSet ().size (), 1, "An only address must be chosen.");
/*
* 1 -- 2 -- 5
* 1 -- 2 -- 5
* | |
* 3 -- 4
*
@@ -106,7 +106,7 @@ OlsrMprTestCase::DoRun ()
NS_TEST_EXPECT_MSG_EQ (mpr.size (), 1, "An only address must be chosen.");
NS_TEST_EXPECT_MSG_EQ ((mpr.find ("10.0.0.2") != mpr.end ()), true, "Node 1 must select node 2 as MPR");
/*
* 1 -- 2 -- 5
* 1 -- 2 -- 5
* | |
* 3 -- 4
* |
@@ -126,7 +126,7 @@ OlsrMprTestCase::DoRun ()
/*
* 7 (OLSR_WILL_ALWAYS)
* |
* 1 -- 2 -- 5
* 1 -- 2 -- 5
* | |
* 3 -- 4
* |
@@ -145,7 +145,7 @@ OlsrMprTestCase::DoRun ()
/*
* 7 <- WILL_ALWAYS
* |
* 9 -- 8 -- 1 -- 2 -- 5
* 9 -- 8 -- 1 -- 2 -- 5
* | |
* ^ 3 -- 4
* | |
@@ -173,7 +173,7 @@ public:
OlsrProtocolTestSuite ();
} g_olsrProtocolTestSuite;
OlsrProtocolTestSuite::OlsrProtocolTestSuite()
OlsrProtocolTestSuite::OlsrProtocolTestSuite ()
: TestSuite ("routing-olsr", UNIT)
{
AddTestCase (new OlsrMprTestCase (), TestCase::QUICK);

View File

@@ -28,7 +28,7 @@ using namespace olsr;
class RegressionTestSuite : public TestSuite
{
public:
RegressionTestSuite () : TestSuite ("routing-olsr-regression", SYSTEM)
RegressionTestSuite () : TestSuite ("routing-olsr-regression", SYSTEM)
{
SetDataDir (NS_TEST_SOURCEDIR);
AddTestCase (new HelloRegressionTest, TestCase::QUICK);

View File

@@ -38,19 +38,17 @@
#include "ns3/simple-net-device-helper.h"
#include "ns3/simple-net-device.h"
namespace ns3
{
namespace olsr
{
namespace ns3 {
namespace olsr {
TcRegressionTest::TcRegressionTest() :
TcRegressionTest::TcRegressionTest () :
TestCase ("Test OLSR Topology Control message generation"),
m_time (Seconds (20)),
m_countA (0), m_countB (0), m_countC (0)
{
}
TcRegressionTest::~TcRegressionTest()
TcRegressionTest::~TcRegressionTest ()
{
}
@@ -185,7 +183,7 @@ TcRegressionTest::ReceivePktProbeA (Ptr<Socket> socket)
NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countA) << " - Neighbor.");
}
}
m_countA ++;
m_countA++;
}
void
@@ -207,8 +205,8 @@ TcRegressionTest::ReceivePktProbeB (Ptr<Socket> socket)
receivedPacketProbe->RemoveHeader (msgHdr);
const olsr::MessageHeader::Hello &hello = msgHdr.GetHello ();
if (m_countB == 0 || m_countB == 2 || m_countB == 5 || m_countB == 6 || m_countB == 8 ||
m_countB == 10 || m_countB == 13 || m_countB == 15 || m_countB == 17 || m_countB == 19)
if (m_countB == 0 || m_countB == 2 || m_countB == 5 || m_countB == 6 || m_countB == 8
|| m_countB == 10 || m_countB == 13 || m_countB == 15 || m_countB == 17 || m_countB == 19)
{
NS_TEST_EXPECT_MSG_EQ (msgHdr.GetOriginatorAddress (), Ipv4Address ("10.1.1.3"), "Originator address.");
}
@@ -240,7 +238,7 @@ TcRegressionTest::ReceivePktProbeB (Ptr<Socket> socket)
NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[0].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.2"), int(m_countC) << " - Neighbor.");
}
m_countB ++;
m_countB++;
}
// Note: this is identical to ReceivePktProbeA, but the packet counter needs to be different.
@@ -308,7 +306,7 @@ TcRegressionTest::ReceivePktProbeC (Ptr<Socket> socket)
NS_TEST_EXPECT_MSG_EQ (hello.linkMessages[1].neighborInterfaceAddresses[0], Ipv4Address ("10.1.1.1"), int(m_countC) << " - Neighbor.");
}
}
m_countC ++;
m_countC++;
}
}

View File

@@ -27,17 +27,15 @@
#include "ns3/ipv4-raw-socket-impl.h"
#include "ns3/node-container.h"
namespace ns3
{
namespace olsr
{
namespace ns3 {
namespace olsr {
/**
* \ingroup olsr
* \brief Less trivial test of OLSR Topology Control message generation
*
*
* This test simulates 3 Wi-Fi stations with chain topology and runs OLSR without any extra traffic.
* It is expected that only second station will send TC messages.
*
*
* Expected trace (20 seconds, note random b-cast jitter):
\verbatim
1 2 3
@@ -72,13 +70,13 @@ namespace olsr
<------|------>| | HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src = 10.1.1.1
| |<------|------> HELLO (Link Type: MPR Link, Neighbor: 10.1.1.2) src = 10.1.1.3
|<------|------>| HELLO (Link Type: Symmetric, Neighbor: 10.1.1.3; Link Type: Symmetric, Neighbor: 10.1.1.1) src = 10.1.1.2
\endverbatim
\endverbatim
*/
class TcRegressionTest : public TestCase
{
public:
TcRegressionTest();
~TcRegressionTest();
TcRegressionTest ();
~TcRegressionTest ();
private:
/// Total simulation time
const Time m_time;