A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::ArpL3Protocol Class Reference

An implementation of the ARP protocol. More...

#include "arp-l3-protocol.h"

+ Inheritance diagram for ns3::ArpL3Protocol:
+ Collaboration diagram for ns3::ArpL3Protocol:

Public Member Functions

 ArpL3Protocol ()
 
 ArpL3Protocol (const ArpL3Protocol &)=delete
 
 ~ArpL3Protocol () override
 
int64_t AssignStreams (int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model.
 
Ptr< ArpCacheCreateCache (Ptr< NetDevice > device, Ptr< Ipv4Interface > interface)
 Create an ARP cache for the device/interface.
 
bool Lookup (Ptr< Packet > p, const Ipv4Header &ipHeader, Ipv4Address destination, Ptr< NetDevice > device, Ptr< ArpCache > cache, Address *hardwareDestination)
 Perform an ARP lookup.
 
ArpL3Protocoloperator= (const ArpL3Protocol &)=delete
 
void Receive (Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
 Receive a packet.
 
void SetNode (Ptr< Node > node)
 Set the node the ARP L3 protocol is associated with.
 
void SetTrafficControl (Ptr< TrafficControlLayer > tc)
 Set the TrafficControlLayer.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Static Public Attributes

static const uint16_t PROT_NUMBER = 0x0806
 ARP protocol number (0x0806)
 

Protected Member Functions

void DoDispose () override
 Destructor implementation.
 
void NotifyNewAggregate () override
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Private Types

typedef std::list< Ptr< ArpCache > > CacheList
 container of the ARP caches
 

Private Member Functions

Ptr< ArpCacheFindCache (Ptr< NetDevice > device)
 Finds the cache associated with a NetDevice.
 
void SendArpReply (Ptr< const ArpCache > cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac)
 Send an ARP reply to an host.
 
void SendArpRequest (Ptr< const ArpCache > cache, Ipv4Address to)
 Send an ARP request to an host.
 

Private Attributes

CacheList m_cacheList
 ARP cache container.
 
TracedCallback< Ptr< const Packet > > m_dropTrace
 trace for packets dropped by ARP
 
Ptr< Nodem_node
 node the ARP L3 protocol is associated with
 
Ptr< RandomVariableStreamm_requestJitter
 jitter to de-sync ARP requests
 
Ptr< TrafficControlLayerm_tc
 The associated TrafficControlLayer.
 

Additional Inherited Members

Detailed Description

An implementation of the ARP protocol.

Config Paths

ns3::ArpL3Protocol is accessible through the following paths with Config::Set and Config::Connect:

  • "/NodeList/[i]/$ns3::ArpL3Protocol"

Attributes

TraceSources

Group: Internet

Size of this type is 128 bytes (on a 64-bit architecture).

Definition at line 44 of file arp-l3-protocol.h.

Member Typedef Documentation

◆ CacheList

typedef std::list<Ptr<ArpCache> > ns3::ArpL3Protocol::CacheList
private

container of the ARP caches

Definition at line 133 of file arp-l3-protocol.h.

Constructor & Destructor Documentation

◆ ArpL3Protocol() [1/2]

ns3::ArpL3Protocol::ArpL3Protocol ( )

Definition at line 65 of file arp-l3-protocol.cc.

References NS_LOG_FUNCTION.

◆ ~ArpL3Protocol()

ns3::ArpL3Protocol::~ArpL3Protocol ( )
override

Definition at line 71 of file arp-l3-protocol.cc.

References NS_LOG_FUNCTION.

◆ ArpL3Protocol() [2/2]

ns3::ArpL3Protocol::ArpL3Protocol ( const ArpL3Protocol & )
delete

Member Function Documentation

◆ AssignStreams()

int64_t ns3::ArpL3Protocol::AssignStreams ( int64_t stream)

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.

Parameters
streamfirst stream index to use
Returns
the number of stream indices assigned by this model

Definition at line 77 of file arp-l3-protocol.cc.

References m_requestJitter, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().

+ Here is the call graph for this function:

◆ CreateCache()

Ptr< ArpCache > ns3::ArpL3Protocol::CreateCache ( Ptr< NetDevice > device,
Ptr< Ipv4Interface > interface )

Create an ARP cache for the device/interface.

Parameters
devicethe NetDevice
interfacethe Ipv4Interface
Returns
a smart pointer to the ARP cache

Definition at line 135 of file arp-l3-protocol.cc.

References ns3::CreateObject(), ns3::ArpCache::Flush(), ns3::Object::GetObject(), m_cacheList, m_node, ns3::MakeCallback(), NS_ASSERT, NS_LOG_FUNCTION, and SendArpRequest().

+ Here is the call graph for this function:

◆ DoDispose()

void ns3::ArpL3Protocol::DoDispose ( )
overrideprotectedvirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Reimplemented from ns3::Object.

Definition at line 120 of file arp-l3-protocol.cc.

References ns3::Object::DoDispose(), m_cacheList, m_node, m_tc, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ FindCache()

Ptr< ArpCache > ns3::ArpL3Protocol::FindCache ( Ptr< NetDevice > device)
private

Finds the cache associated with a NetDevice.

Parameters
devicethe NetDevice
Returns
the ARP cache, or null if no cache is found

Definition at line 149 of file arp-l3-protocol.cc.

References m_cacheList, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by Receive().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::ArpL3Protocol::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 36 of file arp-l3-protocol.cc.

References m_cacheList, m_dropTrace, m_requestJitter, ns3::MakeObjectVectorAccessor(), ns3::MakeObjectVectorChecker(), ns3::MakePointerAccessor(), ns3::MakePointerChecker(), ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ Lookup()

bool ns3::ArpL3Protocol::Lookup ( Ptr< Packet > p,
const Ipv4Header & ipHeader,
Ipv4Address destination,
Ptr< NetDevice > device,
Ptr< ArpCache > cache,
Address * hardwareDestination )

Perform an ARP lookup.

Parameters
pthe packet
ipHeaderthe IPv4 header
destinationdestination IP address
deviceoutgoing device
cacheARP cache
hardwareDestinationfilled with the destination MAC address (if the entry exists)
Returns
true if there is a matching ARP Entry

Definition at line 277 of file arp-l3-protocol.cc.

References ns3::Node::GetId(), ns3::ArpCache::Entry::GetMacAddress(), ns3::RandomVariableStream::GetValue(), ns3::ArpCache::Entry::IsAlive(), ns3::ArpCache::Entry::IsAutoGenerated(), ns3::ArpCache::Entry::IsDead(), ns3::ArpCache::Entry::IsExpired(), ns3::ArpCache::Entry::IsPermanent(), ns3::ArpCache::Entry::IsWaitReply(), m_dropTrace, m_node, m_requestJitter, ns3::ArpCache::Entry::MarkWaitReply(), ns3::MilliSeconds(), NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Simulator::Schedule(), SendArpRequest(), and ns3::ArpCache::Entry::UpdateWaitReply().

+ Here is the call graph for this function:

◆ NotifyNewAggregate()

void ns3::ArpL3Protocol::NotifyNewAggregate ( )
overrideprotectedvirtual

Notify all Objects aggregated to this one of a new Object being aggregated.

This method is invoked whenever two sets of Objects are aggregated together. It is invoked exactly once for each Object in both sets. This method can be overridden by subclasses who wish to be notified of aggregation events. These subclasses must chain up to their base class NotifyNewAggregate() method.

It is safe to call GetObject() and AggregateObject() from within this method.

Reimplemented from ns3::Object.

Definition at line 103 of file arp-l3-protocol.cc.

References ns3::Object::GetObject(), m_node, ns3::Object::NotifyNewAggregate(), NS_LOG_FUNCTION, and SetNode().

+ Here is the call graph for this function:

◆ operator=()

ArpL3Protocol & ns3::ArpL3Protocol::operator= ( const ArpL3Protocol & )
delete

◆ Receive()

void ns3::ArpL3Protocol::Receive ( Ptr< NetDevice > device,
Ptr< const Packet > p,
uint16_t protocol,
const Address & from,
const Address & to,
NetDevice::PacketType packetType )

Receive a packet.

Parameters
devicethe source NetDevice
pthe packet
protocolthe protocol
fromthe source address
tothe destination address
packetTypetype of packet (i.e., unicast, multicast, etc.)
Internal:
Note: we do not update the ARP cache when we receive an ARP request from an unknown node. See Bug 107

Definition at line 165 of file arp-l3-protocol.cc.

References ns3::ArpCache::Entry::DequeuePending(), FindCache(), ns3::ArpHeader::GetDestinationHardwareAddress(), ns3::ArpHeader::GetDestinationIpv4Address(), ns3::Node::GetId(), ns3::ArpHeader::GetSourceHardwareAddress(), ns3::ArpHeader::GetSourceIpv4Address(), ns3::ArpHeader::IsReply(), ns3::ArpHeader::IsRequest(), ns3::ArpCache::Entry::IsWaitReply(), m_dropTrace, m_node, ns3::ArpCache::Entry::MarkAlive(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and SendArpReply().

Referenced by ns3::Ipv4L3Protocol::AddInterface().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendArpReply()

void ns3::ArpL3Protocol::SendArpReply ( Ptr< const ArpCache > cache,
Ipv4Address myIp,
Ipv4Address toIp,
Address toMac )
private

Send an ARP reply to an host.

Parameters
cachethe ARP cache to use
myIpthe source IP address
toIpthe destination IP
toMacthe destination MAC address

Definition at line 396 of file arp-l3-protocol.cc.

References ns3::Create(), ns3::Node::GetId(), m_node, m_tc, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and ns3::ArpHeader::SetReply().

Referenced by Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendArpRequest()

void ns3::ArpL3Protocol::SendArpRequest ( Ptr< const ArpCache > cache,
Ipv4Address to )
private

Send an ARP request to an host.

Parameters
cachethe ARP cache to use
tothe destination IP

Definition at line 377 of file arp-l3-protocol.cc.

References ns3::Create(), ns3::Ipv4Address::GetBroadcast(), ns3::Node::GetId(), ns3::Object::GetObject(), ns3::Ipv4InterfaceAddress::GLOBAL, m_node, m_tc, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and ns3::ArpHeader::SetRequest().

Referenced by CreateCache(), and Lookup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetNode()

void ns3::ArpL3Protocol::SetNode ( Ptr< Node > node)

Set the node the ARP L3 protocol is associated with.

Parameters
nodethe node

Definition at line 85 of file arp-l3-protocol.cc.

References m_node, and NS_LOG_FUNCTION.

Referenced by NotifyNewAggregate().

+ Here is the caller graph for this function:

◆ SetTrafficControl()

void ns3::ArpL3Protocol::SetTrafficControl ( Ptr< TrafficControlLayer > tc)

Set the TrafficControlLayer.

Parameters
tcTrafficControlLayer object

Definition at line 92 of file arp-l3-protocol.cc.

References m_tc, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_cacheList

CacheList ns3::ArpL3Protocol::m_cacheList
private

ARP cache container.

Definition at line 157 of file arp-l3-protocol.h.

Referenced by CreateCache(), DoDispose(), FindCache(), and GetTypeId().

◆ m_dropTrace

TracedCallback<Ptr<const Packet> > ns3::ArpL3Protocol::m_dropTrace
private

trace for packets dropped by ARP

Definition at line 159 of file arp-l3-protocol.h.

Referenced by GetTypeId(), Lookup(), and Receive().

◆ m_node

Ptr<Node> ns3::ArpL3Protocol::m_node
private

node the ARP L3 protocol is associated with

Definition at line 158 of file arp-l3-protocol.h.

Referenced by CreateCache(), DoDispose(), Lookup(), NotifyNewAggregate(), Receive(), SendArpReply(), SendArpRequest(), and SetNode().

◆ m_requestJitter

Ptr<RandomVariableStream> ns3::ArpL3Protocol::m_requestJitter
private

jitter to de-sync ARP requests

Definition at line 160 of file arp-l3-protocol.h.

Referenced by AssignStreams(), GetTypeId(), and Lookup().

◆ m_tc

Ptr<TrafficControlLayer> ns3::ArpL3Protocol::m_tc
private

The associated TrafficControlLayer.

Definition at line 161 of file arp-l3-protocol.h.

Referenced by DoDispose(), SendArpReply(), SendArpRequest(), and SetTrafficControl().

◆ PROT_NUMBER

const uint16_t ns3::ArpL3Protocol::PROT_NUMBER = 0x0806
static

The documentation for this class was generated from the following files: