A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::Ipv4Interface Class Reference

The IPv4 representation of a network interface. More...

#include <ipv4-interface.h>

+ Inheritance diagram for ns3::Ipv4Interface:
+ Collaboration diagram for ns3::Ipv4Interface:

Public Member Functions

 Ipv4Interface ()
 
virtual ~Ipv4Interface ()
 
bool AddAddress (Ipv4InterfaceAddress address)
 
Ipv4InterfaceAddress GetAddress (uint32_t index) const
 
Ptr< ArpCacheGetArpCache () const
 
Ptr< NetDeviceGetDevice (void) const
 
uint16_t GetMetric (void) const
 
uint32_t GetNAddresses (void) const
 
bool IsDown (void) const
 
bool IsForwarding (void) const
 
bool IsUp (void) const
 
Ipv4InterfaceAddress RemoveAddress (uint32_t index)
 
Ipv4InterfaceAddress RemoveAddress (Ipv4Address address)
 Remove the given Ipv4 address from the interface. More...
 
void Send (Ptr< Packet > p, Ipv4Address dest)
 
void SetArpCache (Ptr< ArpCache >)
 
void SetDevice (Ptr< NetDevice > device)
 
void SetDown (void)
 
void SetForwarding (bool val)
 
void SetMetric (uint16_t metric)
 
void SetNode (Ptr< Node > node)
 
void SetUp (void)
 
- Public Member Functions inherited from ns3::Object
 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)
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 
- Public Member Functions inherited from ns3::ObjectBase
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 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)
 

Protected Member Functions

virtual void DoDispose (void)
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoInitialize (void)
 
virtual void NotifyNewAggregate (void)
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 

Private Types

typedef std::list
< Ipv4InterfaceAddress
Ipv4InterfaceAddressList
 
typedef std::list
< Ipv4InterfaceAddress >
::const_iterator 
Ipv4InterfaceAddressListCI
 
typedef std::list
< Ipv4InterfaceAddress >
::iterator 
Ipv4InterfaceAddressListI
 

Private Member Functions

void DoSetup (void)
 

Private Attributes

Ptr< ArpCachem_cache
 
Ptr< NetDevicem_device
 
bool m_forwarding
 
Ipv4InterfaceAddressList m_ifaddrs
 
bool m_ifup
 
uint16_t m_metric
 
Ptr< Nodem_node
 

Detailed Description

The IPv4 representation of a network interface.

This class roughly corresponds to the struct in_device of Linux; the main purpose is to provide address-family specific information (addresses) about an interface.

By default, Ipv4 interface are created in the "down" state no IP addresses. Before becoming useable, the user must add an address of some type and invoke Setup on them.

Config Paths

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

  • /NodeList/[i]/$ns3::Ipv4L3Protocol/InterfaceList/[i]

Attributes

  • ArpCache: The arp cache for this ipv4 interface
    • Set with class: ns3::PointerValue
    • Underlying type: ns3::Ptr< ns3::ArpCache >
    • Initial value: 0
    • Flags: construct write read

No TraceSources are defined for this type.

Definition at line 49 of file ipv4-interface.h.

Member Typedef Documentation

Definition at line 169 of file ipv4-interface.h.

Constructor & Destructor Documentation

ns3::Ipv4Interface::Ipv4Interface ( )

By default, Ipv4 interface are created in the "down" state with no IP addresses. Before becoming useable, the user must invoke SetUp on them once an Ipv4 address and mask have been set.

Definition at line 60 of file ipv4-interface.cc.

References NS_LOG_FUNCTION.

ns3::Ipv4Interface::~Ipv4Interface ( )
virtual

Definition at line 71 of file ipv4-interface.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

bool ns3::Ipv4Interface::AddAddress ( Ipv4InterfaceAddress  address)
Parameters
addressThe Ipv4InterfaceAddress to add to the interface
Returns
true if succeeded

Definition at line 295 of file ipv4-interface.cc.

References m_ifaddrs, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

void ns3::Ipv4Interface::DoDispose ( void  )
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 77 of file ipv4-interface.cc.

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

+ Here is the call graph for this function:

void ns3::Ipv4Interface::DoSetup ( void  )
private

Definition at line 102 of file ipv4-interface.cc.

References ns3::Object::GetObject(), m_cache, m_device, m_node, and NS_LOG_FUNCTION.

Referenced by SetDevice(), and SetNode().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Ipv4InterfaceAddress ns3::Ipv4Interface::GetAddress ( uint32_t  index) const
Parameters
indexIndex of Ipv4InterfaceAddress to return
Returns
The Ipv4InterfaceAddress address whose index is i

Definition at line 303 of file ipv4-interface.cc.

References m_ifaddrs, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4L3Protocol::GetAddress(), and ns3::Ipv4EndPointDemux::Lookup().

+ Here is the caller graph for this function:

Ptr< ArpCache > ns3::Ipv4Interface::GetArpCache ( ) const
Returns
ARP cache used by this interface

Definition at line 146 of file ipv4-interface.cc.

References m_cache, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

Ptr< NetDevice > ns3::Ipv4Interface::GetDevice ( void  ) const
Returns
the underlying NetDevice. This method cannot return zero.

Definition at line 118 of file ipv4-interface.cc.

References m_device, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::UdpSocketImpl::ForwardUp(), ns3::Ipv4L3Protocol::GetMtu(), ns3::Ipv4L3Protocol::GetNetDevice(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Ipv4L3Protocol::Receive(), and ns3::Ipv4L3Protocol::Send().

+ Here is the caller graph for this function:

uint16_t ns3::Ipv4Interface::GetMetric ( void  ) const
Returns
configured routing metric (cost) of this interface

Note: This is synonymous to the Metric value that ifconfig prints out. It is used by ns-3 global routing, but other routing daemons may choose to ignore it.

Definition at line 132 of file ipv4-interface.cc.

References m_metric, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

uint32_t ns3::Ipv4Interface::GetNAddresses ( void  ) const
Returns
the number of Ipv4InterfaceAddresss stored on this interface

Definition at line 288 of file ipv4-interface.cc.

References m_ifaddrs, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4L3Protocol::GetNAddresses(), and ns3::Ipv4EndPointDemux::Lookup().

+ Here is the caller graph for this function:

TypeId ns3::Ipv4Interface::GetTypeId ( void  )
static

Definition at line 40 of file ipv4-interface.cc.

References GetArpCache(), SetArpCache(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

bool ns3::Ipv4Interface::IsDown ( void  ) const
Returns
true if this interface is disabled, false otherwise.

Definition at line 165 of file ipv4-interface.cc.

References m_ifup, and NS_LOG_FUNCTION.

bool ns3::Ipv4Interface::IsForwarding ( void  ) const
Returns
true if this interface is enabled for IP forwarding of input datagrams

Definition at line 186 of file ipv4-interface.cc.

References m_forwarding, and NS_LOG_FUNCTION.

bool ns3::Ipv4Interface::IsUp ( void  ) const

These are IP interface states and may be distinct from NetDevice states, such as found in real implementations (where the device may be down but IP interface state is still up).

Returns
true if this interface is enabled, false otherwise.

These are IP interface states and may be distinct from NetDevice states, such as found in real implementations (where the device may be down but IP interface state is still up).

Definition at line 158 of file ipv4-interface.cc.

References m_ifup, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4L3Protocol::IsUp(), ns3::Ipv4L3Protocol::Receive(), and Send().

+ Here is the caller graph for this function:

Ipv4InterfaceAddress ns3::Ipv4Interface::RemoveAddress ( uint32_t  index)
Parameters
indexIndex of Ipv4InterfaceAddress to remove
Returns
The Ipv4InterfaceAddress address whose index is index

Definition at line 324 of file ipv4-interface.cc.

References m_ifaddrs, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Ipv4InterfaceAddress ns3::Ipv4Interface::RemoveAddress ( Ipv4Address  address)

Remove the given Ipv4 address from the interface.

Parameters
addressThe Ipv4 address to remove
Returns
The removed Ipv4 interface address
The null interface address if the interface did not contain the address or if loopback address was passed as argument

Definition at line 350 of file ipv4-interface.cc.

References first::address, ns3::Ipv4Address::GetLoopback(), m_ifaddrs, NS_LOG_FUNCTION, and NS_LOG_WARN.

+ Here is the call graph for this function:

void ns3::Ipv4Interface::Send ( Ptr< Packet p,
Ipv4Address  dest 
)
Parameters
ppacket to send
destnext hop address of packet.

This method will eventually call the private SendTo method which must be implemented by subclasses.

Todo:
additional checks needed here (such as whether multicast goes to loopback)?

Definition at line 200 of file ipv4-interface.cc.

References ns3::Object::GetObject(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Address::IsMulticast(), ns3::Ipv4Address::IsSubnetDirectedBroadcast(), IsUp(), m_cache, m_device, m_ifaddrs, m_node, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::NetDevice::PACKET_HOST, and ns3::Ipv4L3Protocol::PROT_NUMBER.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Ipv4Interface::SetArpCache ( Ptr< ArpCache a)

Definition at line 139 of file ipv4-interface.cc.

References m_cache, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

+ Here is the caller graph for this function:

void ns3::Ipv4Interface::SetDevice ( Ptr< NetDevice device)

Definition at line 94 of file ipv4-interface.cc.

References DoSetup(), m_device, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::Ipv4Interface::SetDown ( void  )

Disable this interface

Definition at line 179 of file ipv4-interface.cc.

References m_ifup, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

void ns3::Ipv4Interface::SetForwarding ( bool  val)
Parameters
valWhether to enable or disable IP forwarding for input datagrams

Definition at line 193 of file ipv4-interface.cc.

References m_forwarding, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

void ns3::Ipv4Interface::SetMetric ( uint16_t  metric)
Parameters
metricconfigured routing metric (cost) of this interface

Note: This is synonymous to the Metric value that ifconfig prints out. It is used by ns-3 global routing, but other routing daemons choose to ignore it.

Definition at line 125 of file ipv4-interface.cc.

References m_metric, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

void ns3::Ipv4Interface::SetNode ( Ptr< Node node)

Definition at line 86 of file ipv4-interface.cc.

References DoSetup(), m_node, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

void ns3::Ipv4Interface::SetUp ( void  )

Enable this interface

Definition at line 172 of file ipv4-interface.cc.

References m_ifup, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

Member Data Documentation

Ptr<ArpCache> ns3::Ipv4Interface::m_cache
private

Definition at line 178 of file ipv4-interface.h.

Referenced by DoSetup(), GetArpCache(), Send(), and SetArpCache().

Ptr<NetDevice> ns3::Ipv4Interface::m_device
private

Definition at line 177 of file ipv4-interface.h.

Referenced by DoDispose(), DoSetup(), GetDevice(), Send(), and SetDevice().

bool ns3::Ipv4Interface::m_forwarding
private

Definition at line 173 of file ipv4-interface.h.

Referenced by IsForwarding(), and SetForwarding().

Ipv4InterfaceAddressList ns3::Ipv4Interface::m_ifaddrs
private

Definition at line 175 of file ipv4-interface.h.

Referenced by AddAddress(), GetAddress(), GetNAddresses(), RemoveAddress(), and Send().

bool ns3::Ipv4Interface::m_ifup
private

Definition at line 172 of file ipv4-interface.h.

Referenced by IsDown(), IsUp(), SetDown(), and SetUp().

uint16_t ns3::Ipv4Interface::m_metric
private

Definition at line 174 of file ipv4-interface.h.

Referenced by GetMetric(), and SetMetric().

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

Definition at line 176 of file ipv4-interface.h.

Referenced by DoDispose(), DoSetup(), Send(), and SetNode().


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