An implementation of the ARP protocol. More...
#include <arp-l3-protocol.h>
Public Member Functions | |
ArpL3Protocol () | |
virtual | ~ArpL3Protocol () |
int64_t | AssignStreams (int64_t stream) |
Ptr< ArpCache > | CreateCache (Ptr< NetDevice > device, Ptr< Ipv4Interface > interface) |
bool | Lookup (Ptr< Packet > p, Ipv4Address destination, Ptr< NetDevice > device, Ptr< ArpCache > cache, Address *hardwareDestination) |
Perform an ARP lookup. More... | |
void | Receive (Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) |
Receive a packet. More... | |
void | SetNode (Ptr< Node > node) |
![]() | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
![]() | |
SimpleRefCount () | |
SimpleRefCount (const SimpleRefCount &o) | |
uint32_t | GetReferenceCount (void) const |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
![]() | |
virtual | ~ObjectBase () |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
![]() | |
static TypeId | GetTypeId (void) |
![]() | |
static void | Cleanup (void) |
![]() | |
static TypeId | GetTypeId (void) |
Static Public Attributes | |
static const uint16_t | PROT_NUMBER = 0x0806 |
Protected Member Functions | |
virtual void | DoDispose (void) |
virtual void | NotifyNewAggregate () |
![]() | |
Object (const Object &o) | |
virtual void | DoInitialize (void) |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
Private Types | |
typedef std::list< Ptr < ArpCache > > | CacheList |
Private Member Functions | |
ArpL3Protocol (const ArpL3Protocol &o) | |
Ptr< ArpCache > | FindCache (Ptr< NetDevice > device) |
ArpL3Protocol & | operator= (const ArpL3Protocol &o) |
void | SendArpReply (Ptr< const ArpCache > cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac) |
void | SendArpRequest (Ptr< const ArpCache >cache, Ipv4Address to) |
Private Attributes | |
CacheList | m_cacheList |
TracedCallback< Ptr< const Packet > > | m_dropTrace |
Ptr< Node > | m_node |
Ptr< RandomVariableStream > | m_requestJitter |
An implementation of the ARP protocol.
ns3::ArpL3Protocol is accessible through the following paths with Config::Set and Config::Connect:
Definition at line 49 of file arp-l3-protocol.h.
|
private |
Definition at line 99 of file arp-l3-protocol.h.
ns3::ArpL3Protocol::ArpL3Protocol | ( | ) |
Definition at line 65 of file arp-l3-protocol.cc.
References NS_LOG_FUNCTION.
|
virtual |
Definition at line 70 of file arp-l3-protocol.cc.
References NS_LOG_FUNCTION.
|
private |
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.
stream | first stream index to use |
Definition at line 76 of file arp-l3-protocol.cc.
References m_requestJitter, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().
Ptr< ArpCache > ns3::ArpL3Protocol::CreateCache | ( | Ptr< NetDevice > | device, |
Ptr< Ipv4Interface > | interface | ||
) |
Definition at line 126 of file arp-l3-protocol.cc.
References ns3::ArpCache::Flush(), ns3::Object::GetObject(), m_cacheList, m_node, ns3::MakeCallback(), NS_ASSERT, NS_LOG_FUNCTION, SendArpRequest(), and ns3::ArpCache::SetDevice().
|
protectedvirtual |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden 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 112 of file arp-l3-protocol.cc.
References ns3::Object::Dispose(), ns3::Object::DoDispose(), m_cacheList, m_node, and NS_LOG_FUNCTION.
Definition at line 140 of file arp-l3-protocol.cc.
References m_cacheList, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by Receive().
|
static |
Definition at line 44 of file arp-l3-protocol.cc.
References m_cacheList, m_dropTrace, m_requestJitter, ns3::MakeObjectVectorAccessor(), ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
bool ns3::ArpL3Protocol::Lookup | ( | Ptr< Packet > | p, |
Ipv4Address | destination, | ||
Ptr< NetDevice > | device, | ||
Ptr< ArpCache > | cache, | ||
Address * | hardwareDestination | ||
) |
Perform an ARP lookup.
p | |
destination | |
device | |
cache | |
hardwareDestination |
Definition at line 258 of file arp-l3-protocol.cc.
References ns3::ArpCache::Add(), ns3::Node::GetId(), ns3::ArpCache::Entry::GetMacAddress(), ns3::RandomVariableStream::GetValue(), ns3::ArpCache::Entry::IsAlive(), ns3::ArpCache::Entry::IsDead(), ns3::ArpCache::Entry::IsExpired(), ns3::ArpCache::Entry::IsWaitReply(), ns3::ArpCache::Lookup(), m_dropTrace, m_node, m_requestJitter, ns3::ArpCache::Entry::MarkWaitReply(), NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Simulator::Schedule(), SendArpRequest(), and ns3::ArpCache::Entry::UpdateWaitReply().
|
protectedvirtual |
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 overriden 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.
This function must be implemented in the stack that needs to notify other stacks connected to the node of their presence in the node.
Reimplemented from ns3::Object.
Definition at line 95 of file arp-l3-protocol.cc.
References m_node, ns3::Object::NotifyNewAggregate(), NS_LOG_FUNCTION, and SetNode().
|
private |
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.
Definition at line 156 of file arp-l3-protocol.cc.
References ns3::Packet::Copy(), ns3::ArpCache::Entry::DequeuePending(), FindCache(), ns3::ArpHeader::GetDestinationHardwareAddress(), ns3::ArpHeader::GetDestinationIpv4Address(), ns3::Node::GetId(), ns3::Packet::GetSize(), ns3::ArpHeader::GetSourceHardwareAddress(), ns3::ArpHeader::GetSourceIpv4Address(), ns3::Ipv4Address::IsEqual(), 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().
|
private |
Definition at line 348 of file arp-l3-protocol.cc.
References ns3::Packet::AddHeader(), ns3::Node::GetId(), m_node, NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and ns3::ArpHeader::SetReply().
Referenced by Receive().
|
private |
Definition at line 327 of file arp-l3-protocol.cc.
References ns3::Packet::AddHeader(), ns3::Node::GetId(), ns3::Object::GetObject(), ns3::Ipv4InterfaceAddress::GLOBAL, m_node, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, ns3::Ipv4Header::SetDestination(), and ns3::ArpHeader::SetRequest().
Referenced by CreateCache(), and Lookup().
Definition at line 84 of file arp-l3-protocol.cc.
References m_node, and NS_LOG_FUNCTION.
Referenced by NotifyNewAggregate().
|
private |
Definition at line 105 of file arp-l3-protocol.h.
Referenced by CreateCache(), DoDispose(), FindCache(), and GetTypeId().
|
private |
Definition at line 107 of file arp-l3-protocol.h.
Referenced by GetTypeId(), Lookup(), and Receive().
Definition at line 106 of file arp-l3-protocol.h.
Referenced by CreateCache(), DoDispose(), Lookup(), NotifyNewAggregate(), Receive(), SendArpReply(), SendArpRequest(), and SetNode().
|
private |
Definition at line 108 of file arp-l3-protocol.h.
Referenced by AssignStreams(), GetTypeId(), and Lookup().
|
static |
Definition at line 53 of file arp-l3-protocol.h.
Referenced by ns3::Ipv4L3Protocol::AddInterface(), SendArpReply(), and SendArpRequest().