An implementation of the ARP protocol. More...
#include <arp-l3-protocol.h>
Public Member Functions | |
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) |
Public Member Functions inherited from ns3::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) |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount (const SimpleRefCount &o) | |
uint32_t | GetReferenceCount (void) const |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
Public Member Functions inherited from ns3::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 Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Static Public Attributes | |
static const uint16_t | PROT_NUMBER = 0x0806 |
Protected Member Functions | |
virtual void | DoDispose (void) |
virtual void | NotifyNewAggregate () |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
virtual void | DoInitialize (void) |
Protected Member Functions inherited from ns3::ObjectBase | |
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 |
An implementation of the ARP protocol.
ns3::ArpL3Protocol is accessible through the following paths with Config::Set and Config::Connect:
Definition at line 48 of file arp-l3-protocol.h.
|
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 97 of file arp-l3-protocol.cc.
References ns3::Object::Dispose(), ns3::Object::DoDispose(), and NS_LOG_FUNCTION.
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 243 of file arp-l3-protocol.cc.
References ns3::ArpCache::Add(), ns3::Node::GetId(), ns3::ArpCache::Entry::GetMacAddress(), ns3::ArpCache::Entry::IsAlive(), ns3::ArpCache::Entry::IsDead(), ns3::ArpCache::Entry::IsExpired(), ns3::ArpCache::Entry::IsWaitReply(), ns3::ArpCache::Lookup(), ns3::ArpCache::Entry::MarkWaitReply(), NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Packet::PeekPacketTag(), 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 80 of file arp-l3-protocol.cc.
References ns3::Object::NotifyNewAggregate(), and NS_LOG_FUNCTION.
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.
Note: we do not update the ARP cache when we receive an ARP request from an unknown node. See bug #107
Definition at line 141 of file arp-l3-protocol.cc.
References ns3::Packet::Copy(), ns3::ArpCache::Entry::DequeuePending(), ns3::Node::GetId(), ns3::Packet::GetSize(), ns3::Ipv4Address::IsEqual(), ns3::ArpCache::Entry::IsWaitReply(), ns3::ArpCache::Entry::MarkAlive(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by ns3::Ipv4L3Protocol::AddInterface().