An implementation of the ARP protocol. More...
#include <arp-l3-protocol.h>
Public Member Functions | |
ArpL3Protocol () | |
virtual | ~ArpL3Protocol () |
void | SetNode (Ptr< Node > node) |
Ptr< ArpCache > | CreateCache (Ptr< NetDevice > device, Ptr< Ipv4Interface > interface) |
void | Receive (Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) |
Receive a packet. | |
bool | Lookup (Ptr< Packet > p, Ipv4Address destination, Ptr< NetDevice > device, Ptr< ArpCache > cache, Address *hardwareDestination) |
Perform an ARP lookup. | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
This method returns the TypeId associated to ns3::ArpL3Protocol. | |
Static Public Attributes | |
static const uint16_t | PROT_NUMBER = 0x0806 |
Protected Member Functions | |
virtual void | DoDispose (void) |
Private Types | |
typedef std::list< Ptr < ArpCache > > | CacheList |
Private Member Functions | |
Ptr< ArpCache > | FindCache (Ptr< NetDevice > device) |
void | SendArpRequest (Ptr< const ArpCache >cache, Ipv4Address to) |
void | SendArpReply (Ptr< const ArpCache > cache, Ipv4Address toIp, Address toMac) |
Private Attributes | |
CacheList | m_cacheList |
Ptr< Node > | m_node |
TracedCallback< Ptr< const Packet > > | m_dropTrace |
An implementation of the ARP protocol.
Definition at line 48 of file arp-l3-protocol.h.
typedef std::list<Ptr<ArpCache> > ns3::ArpL3Protocol::CacheList [private] |
Definition at line 82 of file arp-l3-protocol.h.
ns3::ArpL3Protocol::ArpL3Protocol | ( | ) |
Definition at line 58 of file arp-l3-protocol.cc.
References NS_LOG_FUNCTION.
ns3::ArpL3Protocol::~ArpL3Protocol | ( | ) | [virtual] |
Definition at line 63 of file arp-l3-protocol.cc.
References NS_LOG_FUNCTION.
Ptr< ArpCache > ns3::ArpL3Protocol::CreateCache | ( | Ptr< NetDevice > | device, | |
Ptr< Ipv4Interface > | interface | |||
) |
Definition at line 90 of file arp-l3-protocol.cc.
References ns3::ArpCache::Flush(), m_cacheList, m_node, ns3::MakeCallback(), NS_ASSERT, NS_LOG_FUNCTION, and SendArpRequest().
void ns3::ArpL3Protocol::DoDispose | ( | void | ) | [protected, virtual] |
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.
Reimplemented from ns3::Object.
Definition at line 76 of file arp-l3-protocol.cc.
References m_cacheList, m_node, and NS_LOG_FUNCTION.
Definition at line 104 of file arp-l3-protocol.cc.
References m_cacheList, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by Receive().
TypeId ns3::ArpL3Protocol::GetTypeId | ( | void | ) | [static] |
This method returns the TypeId associated to ns3::ArpL3Protocol.
This object is accessible through the following paths with Config::Set and Config::Connect:
Attributes defined for this type:
TraceSources defined for this type:
Reimplemented from ns3::Object.
Definition at line 42 of file arp-l3-protocol.cc.
References ns3::TypeId::AddTraceSource(), m_cacheList, m_dropTrace, 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 197 of file arp-l3-protocol.cc.
References ns3::ArpCache::Entry::GetMacAddress(), ns3::ArpCache::Entry::IsAlive(), ns3::ArpCache::Entry::IsDead(), ns3::ArpCache::Entry::IsExpired(), ns3::ArpCache::Entry::IsWaitReply(), m_dropTrace, m_node, ns3::ArpCache::Entry::MarkWaitReply(), NS_FATAL_ERROR, NS_LOG_FUNCTION, NS_LOG_LOGIC, SendArpRequest(), and ns3::ArpCache::Entry::UpdateWaitReply().
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 120 of file arp-l3-protocol.cc.
References ns3::ArpCache::Entry::DequeuePending(), FindCache(), ns3::ArpHeader::GetDestinationHardwareAddress(), ns3::ArpHeader::GetDestinationIpv4Address(), 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().
void ns3::ArpL3Protocol::SendArpReply | ( | Ptr< const ArpCache > | cache, | |
Ipv4Address | toIp, | |||
Address | toMac | |||
) | [private] |
Definition at line 285 of file arp-l3-protocol.cc.
References m_node, NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and ns3::ArpHeader::SetReply().
Referenced by Receive().
void ns3::ArpL3Protocol::SendArpRequest | ( | Ptr< const ArpCache > | cache, | |
Ipv4Address | to | |||
) | [private] |
Definition at line 266 of file arp-l3-protocol.cc.
References m_node, NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and ns3::ArpHeader::SetRequest().
Referenced by CreateCache(), and Lookup().
Definition at line 69 of file arp-l3-protocol.cc.
References m_node, and NS_LOG_FUNCTION.
CacheList ns3::ArpL3Protocol::m_cacheList [private] |
Definition at line 86 of file arp-l3-protocol.h.
Referenced by CreateCache(), DoDispose(), FindCache(), and GetTypeId().
TracedCallback<Ptr<const Packet> > ns3::ArpL3Protocol::m_dropTrace [private] |
Definition at line 88 of file arp-l3-protocol.h.
Referenced by GetTypeId(), Lookup(), and Receive().
Ptr<Node> ns3::ArpL3Protocol::m_node [private] |
Definition at line 87 of file arp-l3-protocol.h.
Referenced by CreateCache(), DoDispose(), Lookup(), Receive(), SendArpReply(), SendArpRequest(), and SetNode().
const uint16_t ns3::ArpL3Protocol::PROT_NUMBER = 0x0806 [static] |
Definition at line 52 of file arp-l3-protocol.h.
Referenced by ns3::Ipv4L3Protocol::AddInterface(), SendArpReply(), and SendArpRequest().