31 #define NS_LOG_APPEND_CONTEXT \
32 if (GetObject<Node>()) \
34 std::clog << "[node " << GetObject<Node>()->GetId() << "] "; \
42 #include "ns3/assert.h"
43 #include "ns3/fatal-error.h"
44 #include "ns3/icmpv4-l4-protocol.h"
45 #include "ns3/ip-l4-protocol.h"
46 #include "ns3/ipv4-address.h"
47 #include "ns3/ipv4-header.h"
48 #include "ns3/ipv4-interface.h"
49 #include "ns3/ipv4-l3-protocol.h"
50 #include "ns3/ipv4-route.h"
52 #include "ns3/node-list.h"
54 #include "ns3/object-vector.h"
55 #include "ns3/pointer.h"
57 #include "ns3/trace-source-accessor.h"
58 #include "ns3/udp-header.h"
59 #include "ns3/uinteger.h"
81 .AddAttribute(
"OptionNumber",
82 "The Dsr option number.",
85 MakeUintegerChecker<uint8_t>())
86 .AddTraceSource(
"Drop",
89 "ns3::Packet::TracedCallback")
91 "Receive DSR packet.",
93 "ns3::dsr::DsrOptionSRHeader::TracedCallback");
124 std::vector<Ipv4Address>& nodeList)
127 std::vector<Ipv4Address>::iterator it = find(nodeList.begin(), nodeList.end(), destAddress);
129 for (std::vector<Ipv4Address>::iterator i = it; i != nodeList.end(); ++i)
131 if ((ipv4Address == (*i)) && ((*i) != nodeList.back()))
139 std::vector<Ipv4Address>
143 std::vector<Ipv4Address>::iterator it = find(nodeList.begin(), nodeList.end(), ipv4Address);
144 std::vector<Ipv4Address> cutRoute;
145 for (std::vector<Ipv4Address>::iterator i = it; i != nodeList.end(); ++i)
147 cutRoute.push_back(*i);
167 std::vector<Ipv4Address> vec2(vec);
169 for (std::vector<Ipv4Address>::reverse_iterator ri = vec2.rbegin(); ri != vec2.rend(); ++ri)
174 if ((vec.size() == vec2.size()) && (vec.front() == vec2.back()))
195 if (ipv4Address == vec.back())
197 NS_LOG_DEBUG(
"We have reached to the final destination " << ipv4Address <<
" "
201 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
203 if (ipv4Address == (*i))
210 NS_LOG_DEBUG(
"next hop address not found, route corrupted");
228 for (std::vector<Ipv4Address>::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri)
230 if (ipv4Address == (*ri))
237 NS_LOG_DEBUG(
"next hop address not found, route corrupted");
249 for (std::vector<Ipv4Address>::reverse_iterator ri = vec.rbegin(); ri != vec.rend(); ++ri)
251 if (ipv4Address == (*ri))
253 nextTwoHop = *(ri + 2);
276 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
287 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
289 for (std::vector<Ipv4Address>::const_iterator j = vec2.begin(); j != vec2.end(); ++j)
308 for (std::vector<Ipv4Address>::const_iterator i = vec.begin(); i != vec.end(); ++i)
310 if ((*i) == ipv4Address)
328 std::vector<Ipv4Address> vec2(vec);
331 for (std::vector<Ipv4Address>::const_iterator i = vec2.begin(); i != vec2.end(); ++i)
340 for (std::vector<Ipv4Address>::iterator j = vec.begin(); j != vec.end(); ++j)
344 if ((j + 1) != vec.end())
346 vec.erase(j + 1, vec.end());
354 else if (j == (vec.end() - 1))
373 for (int32_t i = 0; i < nNodes; ++i)
377 if (ipv4->GetAddress(1, 0).GetLocal() ==
address)
390 for (int32_t i = 0; i < nNodes; ++i)
394 int32_t ifIndex = ipv4->GetInterfaceForAddress(ipv4Address);
443 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Header
444 << (uint32_t)protocol << isPromisc);
493 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Header
494 << (uint32_t)protocol << isPromisc);
551 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Header
552 << (uint32_t)protocol << isPromisc);
559 if (source == ipv4Address)
561 NS_LOG_DEBUG(
"Discard the packet since it was originated from same source address");
580 uint8_t numberAddress = (buf[1] - 6) / 4;
581 NS_LOG_DEBUG(
"The number of Ip addresses " << (uint32_t)numberAddress);
582 if (numberAddress >= 255)
584 NS_LOG_DEBUG(
"Discard the packet, malformed header since two many ip addresses in route");
598 p->RemoveHeader(rreq);
608 uint16_t requestId = rreq.
GetId();
613 std::vector<Ipv4Address> nodeList(mainVector);
632 uint8_t ttl = ipv4Header.
GetTtl();
633 bool dupRequest =
false;
638 dupRequest = dsr->FindSourceEntry(sourceAddress, targetAddress, requestId);
661 NS_LOG_DEBUG(
"Our node address is already seen in the route, drop the request");
668 bool isRouteInCache = dsr->LookupRoute(targetAddress, toPrev);
672 std::vector<Ipv4Address> saveRoute(nodeList);
687 NS_LOG_DEBUG(
"The target address over here " << targetAddress <<
" and the ip address "
688 << ipv4Address <<
" and the source address "
690 if (targetAddress == ipv4Address)
693 if (nodeList.size() == 1)
701 nextHop = srcAddress;
705 std::vector<Ipv4Address> changeRoute(nodeList);
706 changeRoute.push_back(ipv4Address);
708 for (std::vector<Ipv4Address>::iterator i = changeRoute.begin();
709 i != changeRoute.end();
739 dsr->ScheduleInitialReply(newPacket, ipv4Address, nextHop,
m_ipv4Route);
749 bool addRoute =
false;
750 if (numberAddress > 0)
755 if (dsr->IsLinkCache())
757 addRoute = dsr->AddRoute_Link(
m_finalRoute, ipv4Address);
761 addRoute = dsr->AddRoute(toSource);
793 if (nextHop ==
"0.0.0.0")
795 dsr->PacketNewRoute(dsrP, ipv4Address, dst, protocol);
802 dsr->SendPacketFromBuffer(sourceRoute, nextHop, protocol);
804 dsr->CancelRreqTimer(dst,
true);
828 else if (isRouteInCache && !areThereDuplicates)
834 for (std::vector<Ipv4Address>::iterator i = saveRoute.begin(); i != saveRoute.end();
843 for (std::vector<Ipv4Address>::iterator j = ip.begin(); j != ip.end(); ++j)
851 bool addRoute =
false;
856 saveRoute.push_back(ipv4Address);
865 NS_ASSERT(saveRoute.front() == ipv4Address);
867 if (dsr->IsLinkCache())
869 addRoute = dsr->AddRoute_Link(saveRoute, ipv4Address);
873 addRoute = dsr->AddRoute(toSource);
878 NS_LOG_LOGIC(
"We have added the route and search send buffer for packet with "
899 if (nextHop ==
"0.0.0.0")
901 dsr->PacketNewRoute(dsrP, ipv4Address, dst, protocol);
908 dsr->SendPacketFromBuffer(sourceRoute, nextHop, protocol);
910 dsr->CancelRreqTimer(dst,
true);
941 NS_LOG_DEBUG(
"This is the full route from " << realSource <<
" to "
958 dsr->ScheduleCachedReply(newPacket, ipv4Address, nextHop,
m_ipv4Route, hops);
967 mainVector.push_back(ipv4Address);
978 p->RemoveHeader(rerr);
983 if ((errorSrc == srcAddress) && (unreachNode == ipv4Address))
993 dsr->DeleteAllRoutesIncludeLink(errorSrc, unreachNode, ipv4Address);
1003 NS_LOG_DEBUG(
"The RREQ and newUnreach header length " << length);
1017 uint8_t ttl = ipv4Header.
GetTtl();
1030 dsr->ScheduleInterRequest(interP);
1046 .SetGroupName(
"Dsr")
1085 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Header
1086 << (uint32_t)protocol << isPromisc);
1093 uint8_t numberAddress = (buf[1] - 2) / 4;
1103 NS_LOG_DEBUG(
"The next header value " << (uint32_t)protocol);
1111 if (targetAddress == ipv4Address)
1115 if (nodeList.empty())
1133 NS_ASSERT(nodeList.front() == ipv4Address);
1134 bool addRoute =
false;
1135 if (dsr->IsLinkCache())
1137 addRoute = dsr->AddRoute_Link(nodeList, ipv4Address);
1141 addRoute = dsr->AddRoute(toDestination);
1147 "We have added the route and search send buffer for packet with destination "
1159 if (nextHop ==
"0.0.0.0")
1161 dsr->PacketNewRoute(dsrP, ipv4Address, dst, protocol);
1167 dsr->CancelRreqTimer(dst,
true);
1171 dsr->SendPacketFromBuffer(sourceRoute, nextHop, protocol);
1183 NS_LOG_DEBUG(
"The length of rrep option " << (uint32_t)length);
1185 if (length % 2 != 0)
1196 std::vector<Ipv4Address> routeCopy = nodeList;
1197 std::vector<Ipv4Address> cutRoute =
CutRoute(ipv4Address, nodeList);
1199 if (cutRoute.size() >= 2)
1202 NS_LOG_DEBUG(
"The route destination after cut " << dst);
1206 NS_ASSERT(cutRoute.front() == ipv4Address);
1207 bool addRoute =
false;
1208 if (dsr->IsLinkCache())
1210 addRoute = dsr->AddRoute_Link(nodeList, ipv4Address);
1214 addRoute = dsr->AddRoute(toDestination);
1218 dsr->CancelRreqTimer(dst,
true);
1235 NS_LOG_DEBUG(
"The nextHop address " << nextHop <<
" and the source in the route reply "
1248 NS_LOG_DEBUG(
"The reply header length " << (uint32_t)length);
1256 dsr->SendReply(newPacket, ipv4Address, nextHop,
m_ipv4Route);
1269 .SetGroupName(
"Dsr")
1307 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Address << ipv4Header
1308 << (uint32_t)protocol << isPromisc);
1313 uint8_t numberAddress = (buf[1] - 2) / 4;
1342 NS_LOG_LOGIC(
"We process promiscuous receipt data packet");
1346 dsr->SendGratuitousReply(source, srcAddress, nodeList, protocol);
1352 if (destAddress != destination)
1354 NS_LOG_DEBUG(
"Process the promiscuously received packet");
1355 bool findPassive =
false;
1357 for (int32_t i = 0; i < nNodes; ++i)
1365 findPassive = dsrNode->PassiveEntryCheck(packet,
1380 NS_LOG_DEBUG(
"We find one previously received passive entry");
1390 dsrSrc->CancelPassiveTimer(packet, source, destination, segsLeft);
1395 dsr->PassiveEntryCheck(packet,
1412 uint8_t length = sourceRoute.
GetLength();
1413 uint8_t nextAddressIndex;
1418 uint8_t*
data =
new uint8_t[size];
1420 uint8_t optionType = 0;
1421 optionType = *(
data);
1424 if (optionType == 160)
1426 NS_LOG_LOGIC(
"Remove the ack request header and add ack header to the packet");
1430 uint16_t ackId = ackReq.
GetAckId();
1437 if (!nodeList.empty())
1439 if (segsLeft > numberAddress)
1447 if (numberAddress - segsLeft < 2)
1453 ackAddress = nodeList[numberAddress - segsLeft - 2];
1456 NS_LOG_DEBUG(
"Send back ACK to the earlier hop " << ackAddress <<
" from us "
1458 dsr->SendAck(ackId, ackAddress, source, destination, protocol,
m_ipv4Route);
1471 if (length % 2 != 0)
1478 if (segsLeft > numberAddress)
1490 nextAddressIndex = numberAddress - segsLeft;
1492 NS_LOG_DEBUG(
"The next address of source route option "
1493 << nextAddress <<
" and the nextAddressIndex: " << (uint32_t)nextAddressIndex
1494 <<
" and the segments left : " << (uint32_t)segsLeft);
1506 if (nextHop ==
"0.0.0.0")
1509 dsr->PacketNewRoute(dsrP, realSource, targetAddress, protocol);
1513 if (ipv4Address == nextHop)
1526 SetRoute(nextAddress, ipv4Address);
1528 dsr->ForwardPacket(dsrP,
1547 .SetGroupName(
"Dsr")
1585 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Header
1586 << (uint32_t)protocol << isPromisc);
1589 uint8_t*
data =
new uint8_t[size];
1591 uint8_t errorType = *(
data + 2);
1597 NS_LOG_DEBUG(
"The error type value here " << (uint32_t)errorType);
1612 <<
"and the unreachable node is " << unreachAddress);
1621 dsr->DeleteAllRoutesIncludeLink(errorSource, unreachAddress, ipv4Address);
1624 uint32_t serialized =
DoSendError(newP, rerrUnreach, rerrSize, ipv4Address, protocol);
1643 uint32_t serialized = 0;
1658 uint8_t numberAddress = (buf[1] - 2) / 4;
1661 NS_LOG_DEBUG(
"The number of addresses " << (uint32_t)numberAddress);
1675 uint8_t length = sourceRoute.
GetLength();
1676 uint8_t nextAddressIndex;
1688 if (length % 2 != 0)
1695 if (segmentsLeft > numberAddress)
1704 if (segmentsLeft == 0 && targetAddress == ipv4Address)
1706 NS_LOG_INFO(
"This is the destination of the error, send error request");
1707 dsr->SendErrorRequest(rerr, protocol);
1708 return serializedSize;
1714 nextAddressIndex = numberAddress - segmentsLeft;
1724 return serializedSize;
1728 SetRoute(nextAddress, ipv4Address);
1729 dsr->ForwardErrPacket(rerr, newSourceRoute, nextAddress, protocol,
m_ipv4Route);
1730 return serializedSize;
1738 static TypeId tid =
TypeId(
"ns3::dsr::DsrOptionAckReq")
1740 .SetGroupName(
"Dsr")
1778 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Header
1779 << (uint32_t)protocol << isPromisc);
1796 NS_LOG_DEBUG(
"The next header value " << (uint32_t)protocol);
1808 .SetGroupName(
"Dsr")
1846 NS_LOG_FUNCTION(
this << packet << dsrP << ipv4Address << source << ipv4Header
1847 << (uint32_t)protocol << isPromisc);
1865 dsr->UpdateRouteEntry(realDst);
1869 dsr->CallCancelPacketTimer(ackId, ipv4Header, realSrc, realDst);
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
static uint32_t GetNNodes()
static Ptr< Node > GetNode(uint32_t n)
A base class which provides memory management and object aggregation.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
The Dsr Ack option number.
static TypeId GetTypeId()
Get the type ID.
uint8_t GetOptionNumber() const override
Get the option number.
static TypeId GetTypeId()
Get the type ID.
uint8_t GetOptionNumber() const override
Get the option number.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
~DsrOptionAckReq() override
static const uint8_t OPT_NUMBER
Dsr ack request option number.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void AddDsrOption(const DsrOptionHeader &option)
Serialize the option, prepending pad1 or padn option as necessary.
uint8_t GetOptionNumber() const override
Get the option number.
static TypeId GetTypeId()
Get the type ID.
~DsrOptionPad1() override
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
static const uint8_t OPT_NUMBER
Pad1 option number.
static const uint8_t OPT_NUMBER
PadN option number.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
static TypeId GetTypeId()
Get the type ID.
uint8_t GetOptionNumber() const override
Get the option number.
~DsrOptionPadn() override
uint8_t DoSendError(Ptr< Packet > p, DsrOptionRerrUnreachHeader &rerr, uint32_t rerrSize, Ipv4Address ipv4Address, uint8_t protocol)
Do Send error message.
static const uint8_t OPT_NUMBER
Dsr Route Error option number.
static TypeId GetTypeId()
Get the type ID.
~DsrOptionRerr() override
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
uint8_t GetOptionNumber() const override
Get the option number.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
Router alert option number.
static TypeId GetTypeId()
Get the type ID.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint8_t GetOptionNumber() const override
Get the option number.
~DsrOptionRrep() override
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
static TypeId GetTypeId()
Get the type ID.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
Rreq option number.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
uint8_t GetOptionNumber() const override
Get the option number.
~DsrOptionRreq() override
Destructor.
DsrOptionRreq()
Constructor.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static const uint8_t OPT_NUMBER
Source Route option number.
uint8_t Process(Ptr< Packet > packet, Ptr< Packet > dsrP, Ipv4Address ipv4Address, Ipv4Address source, const Ipv4Header &ipv4Header, uint8_t protocol, bool &isPromisc, Ipv4Address promiscSource) override
Process method.
uint8_t GetOptionNumber() const override
Get the option number.
static TypeId GetTypeId()
Get the type ID.
Introspection did not find any typical Config paths.
Ipv4Address SearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Search for the next hop in the route.
Ipv4Address ReverseSearchNextTwoHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next two hop in the route.
TracedCallback< Ptr< const Packet > > m_dropTrace
Drop trace callback.
Ptr< Node > GetNodeWithAddress(Ipv4Address ipv4Address)
Get the node object with Ipv4Address.
Ptr< Node > GetNode() const
Get the node.
Time ActiveRouteTimeout
The active route timeout value.
bool CheckDuplicates(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Check if the route already contains the node ip address.
void SetNode(Ptr< Node > node)
Set the node.
virtual uint8_t GetOptionNumber() const =0
Get the option number.
~DsrOptions() override
Destructor.
std::vector< Ipv4Address > m_finalRoute
The vector of final Ipv4 address.
void PrintVector(std::vector< Ipv4Address > &vec)
Print out the elements in the route vector.
bool IfDuplicates(std::vector< Ipv4Address > &vec, std::vector< Ipv4Address > &vec2)
Check if the two vectors contain duplicate or not.
bool ReverseRoutes(std::vector< Ipv4Address > &vec)
Reverse the routes.
void RemoveDuplicates(std::vector< Ipv4Address > &vec)
Remove the duplicates from the route.
uint32_t GetIDfromIP(Ipv4Address address)
Get the node id with Ipv4Address.
static TypeId GetTypeId()
Get the type identificator.
std::vector< Ipv4Address > CutRoute(Ipv4Address ipv4Address, std::vector< Ipv4Address > &nodeList)
Cut the route from ipv4Address to the end of the route vector.
bool ContainAddressAfter(Ipv4Address ipv4Address, Ipv4Address destAddress, std::vector< Ipv4Address > &nodeList)
Search for the ipv4 address in the node list.
TracedCallback< const DsrOptionSRHeader & > m_rxPacketTrace
The receive trace back, only triggered when final destination receive data packet.
Ipv4Address ReverseSearchNextHop(Ipv4Address ipv4Address, std::vector< Ipv4Address > &vec)
Reverse search for the next hop in the route.
Ptr< Ipv4Route > m_ipv4Route
The ipv4 route.
virtual Ptr< Ipv4Route > SetRoute(Ipv4Address nextHop, Ipv4Address srcAddress)
Set the route to use for data packets, used by the option headers when sending data/control packets.
Ptr< Node > m_node
the node
DsrRouteCacheEntry class for entries in the route cache.
IP_VECTOR GetVector() const
Get the IP vector.
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.