The IPv4 representation of a network interface. More...
#include "ipv4-interface.h"
Public Member Functions | |
Ipv4Interface () | |
By default, Ipv4 interface are created in the "down" state with no IP addresses. More... | |
virtual | ~Ipv4Interface () |
bool | AddAddress (Ipv4InterfaceAddress address) |
Ipv4InterfaceAddress | GetAddress (uint32_t index) const |
Ptr< ArpCache > | GetArpCache () const |
Ptr< NetDevice > | GetDevice (void) const |
uint16_t | GetMetric (void) const |
uint32_t | GetNAddresses (void) const |
bool | IsDown (void) const |
bool | IsForwarding (void) const |
bool | 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). More... | |
Ipv4InterfaceAddress | RemoveAddress (uint32_t index) |
Ipv4InterfaceAddress | RemoveAddress (Ipv4Address address) |
Remove the given Ipv4 address from the interface. More... | |
void | Send (Ptr< Packet > p, const Ipv4Header &hdr, Ipv4Address dest) |
void | SetArpCache (Ptr< ArpCache > arpCache) |
Set ARP cache used by this interface. More... | |
void | SetDevice (Ptr< NetDevice > device) |
Set the NetDevice. More... | |
void | SetDown (void) |
Disable this interface. More... | |
void | SetForwarding (bool val) |
void | SetMetric (uint16_t metric) |
void | SetNode (Ptr< Node > node) |
Set node associated with interface. More... | |
void | SetTrafficControl (Ptr< TrafficControlLayer > tc) |
Set the TrafficControlLayer. More... | |
void | SetUp (void) |
Enable this interface. More... | |
![]() | |
Object () | |
Constructor. More... | |
virtual | ~Object () |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose (void) |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator (void) const |
Get an iterator to the Objects aggregated to this one. More... | |
virtual TypeId | GetInstanceTypeId (void) const |
Implement the GetInstanceTypeId method defined in ObjectBase. More... | |
template<typename T > | |
Ptr< T > | GetObject (void) const |
Get a pointer to the requested aggregated Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
void | Initialize (void) |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
bool | IsInitialized (void) const |
Check if the object has been initialized. More... | |
![]() | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
![]() | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising erros. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
![]() | |
static void | Cleanup (void) |
Noop. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Protected Member Functions | |
virtual void | DoDispose (void) |
Destructor implementation. More... | |
![]() | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | DoInitialize (void) |
Initialize() implementation. More... | |
virtual void | NotifyNewAggregate (void) |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted (void) |
Notifier called once the ObjectBase is fully constructed. More... | |
Private Types | |
typedef std::list< Ipv4InterfaceAddress > | Ipv4InterfaceAddressList |
Container for the Ipv4InterfaceAddresses. More... | |
typedef std::list< Ipv4InterfaceAddress >::const_iterator | Ipv4InterfaceAddressListCI |
Container Iterator for the Ipv4InterfaceAddresses. More... | |
typedef std::list< Ipv4InterfaceAddress >::iterator | Ipv4InterfaceAddressListI |
Const Container Iterator for the Ipv4InterfaceAddresses. More... | |
Private Member Functions | |
void | DoSetup (void) |
Initialize interface. More... | |
Private Attributes | |
Ptr< ArpCache > | m_cache |
ARP cache. More... | |
Ptr< NetDevice > | m_device |
The associated NetDevice. More... | |
bool | m_forwarding |
Forwarding state. More... | |
Ipv4InterfaceAddressList | m_ifaddrs |
Address list. More... | |
bool | m_ifup |
The state of this interface. More... | |
uint16_t | m_metric |
Interface metric. More... | |
Ptr< Node > | m_node |
The associated node. More... | |
Ptr< TrafficControlLayer > | m_tc |
The associated TrafficControlLayer. More... | |
Additional Inherited Members | |
![]() | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
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 usable, the user must add an address of some type and invoke Setup on them.
ns3::Ipv4Interface is accessible through the following paths with Config::Set and Config::Connect:
No TraceSources are defined for this type.
Size of this type is 80 bytes (on a 64-bit architecture).
Definition at line 53 of file ipv4-interface.h.
|
private |
Container for the Ipv4InterfaceAddresses.
Definition at line 203 of file ipv4-interface.h.
|
private |
Container Iterator for the Ipv4InterfaceAddresses.
Definition at line 208 of file ipv4-interface.h.
|
private |
Const Container Iterator for the Ipv4InterfaceAddresses.
Definition at line 213 of file ipv4-interface.h.
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 62 of file ipv4-interface.cc.
References NS_LOG_FUNCTION.
|
virtual |
Definition at line 74 of file ipv4-interface.cc.
References NS_LOG_FUNCTION.
bool ns3::Ipv4Interface::AddAddress | ( | Ipv4InterfaceAddress | address | ) |
address | The Ipv4InterfaceAddress to add to the interface |
Definition at line 308 of file ipv4-interface.cc.
References m_ifaddrs, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::AddAddress().
|
protectedvirtual |
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 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 80 of file ipv4-interface.cc.
References ns3::Object::DoDispose(), m_cache, m_device, m_node, m_tc, and NS_LOG_FUNCTION.
|
private |
Initialize interface.
Definition at line 114 of file ipv4-interface.cc.
References ns3::Object::GetObject(), m_cache, m_device, m_node, and NS_LOG_FUNCTION.
Referenced by SetDevice(), and SetNode().
Ipv4InterfaceAddress ns3::Ipv4Interface::GetAddress | ( | uint32_t | index | ) | const |
index | Index of Ipv4InterfaceAddress to return |
Definition at line 316 of file ipv4-interface.cc.
References m_ifaddrs, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::GetAddress(), ns3::Ipv4EndPointDemux::Lookup(), and ns3::Ipv4L3Protocol::Send().
Definition at line 158 of file ipv4-interface.cc.
References m_cache, and NS_LOG_FUNCTION.
Referenced by GetTypeId(), and ns3::Ipv4L3Protocol::Receive().
Definition at line 130 of file ipv4-interface.cc.
References m_device, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::AddIpv4Interface(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::UdpSocketImpl::ForwardUp(), ns3::Ipv4L3Protocol::GetMtu(), ns3::Ipv4L3Protocol::GetNetDevice(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Ipv4L3Protocol::Send(), and ns3::Ipv4L3Protocol::SendRealOut().
uint16_t ns3::Ipv4Interface::GetMetric | ( | void | ) | const |
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 144 of file ipv4-interface.cc.
References m_metric, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::GetMetric().
uint32_t ns3::Ipv4Interface::GetNAddresses | ( | void | ) | const |
Definition at line 301 of file ipv4-interface.cc.
References m_ifaddrs, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::GetNAddresses(), ns3::Ipv4EndPointDemux::Lookup(), and ns3::Ipv4L3Protocol::Send().
|
static |
Get the type ID.
Definition at line 41 of file ipv4-interface.cc.
References GetArpCache(), ns3::MakePointerAccessor(), SetArpCache(), and ns3::TypeId::SetParent().
bool ns3::Ipv4Interface::IsDown | ( | void | ) | const |
Definition at line 177 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION.
bool ns3::Ipv4Interface::IsForwarding | ( | void | ) | const |
Definition at line 198 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).
Definition at line 170 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::IsUp(), ns3::Ipv4L3Protocol::Receive(), Send(), and ns3::Ipv4L3Protocol::SendRealOut().
Ipv4InterfaceAddress ns3::Ipv4Interface::RemoveAddress | ( | uint32_t | index | ) |
index | Index of Ipv4InterfaceAddress to remove |
Definition at line 340 of file ipv4-interface.cc.
References m_ifaddrs, NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Ipv4InterfaceAddress ns3::Ipv4Interface::RemoveAddress | ( | Ipv4Address | address | ) |
Remove the given Ipv4 address from the interface.
address | The Ipv4 address to remove |
Definition at line 366 of file ipv4-interface.cc.
References first::address, ns3::Ipv4Address::GetLoopback(), m_ifaddrs, NS_LOG_FUNCTION, and NS_LOG_WARN.
void ns3::Ipv4Interface::Send | ( | Ptr< Packet > | p, |
const Ipv4Header & | hdr, | ||
Ipv4Address | dest | ||
) |
p | packet to send |
hdr | IPv4 header |
dest | next hop address of packet. |
This method will eventually call the private SendTo method which must be implemented by subclasses.
Definition at line 212 of file ipv4-interface.cc.
References ns3::Packet::AddHeader(), ns3::Object::GetObject(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Address::IsMulticast(), ns3::Ipv4Address::IsSubnetDirectedBroadcast(), IsUp(), m_cache, m_device, m_ifaddrs, m_node, m_tc, NS_ASSERT, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::NetDevice::PACKET_HOST, and ns3::Ipv4L3Protocol::PROT_NUMBER.
Referenced by ns3::Ipv4L3Protocol::Send(), and ns3::Ipv4L3Protocol::SendRealOut().
Set ARP cache used by this interface.
arpCache | the ARP cache |
Definition at line 151 of file ipv4-interface.cc.
References m_cache, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
Set the NetDevice.
device | NetDevice |
Definition at line 99 of file ipv4-interface.cc.
References DoSetup(), m_device, and NS_LOG_FUNCTION.
void ns3::Ipv4Interface::SetDown | ( | void | ) |
Disable this interface.
Definition at line 191 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::SetDown().
void ns3::Ipv4Interface::SetForwarding | ( | bool | val | ) |
val | Whether to enable or disable IP forwarding for input datagrams |
Definition at line 205 of file ipv4-interface.cc.
References m_forwarding, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::SetForwarding().
void ns3::Ipv4Interface::SetMetric | ( | uint16_t | metric | ) |
metric | 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 choose to ignore it.
Definition at line 137 of file ipv4-interface.cc.
References m_metric, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::SetMetric().
Set node associated with interface.
node | node |
Definition at line 91 of file ipv4-interface.cc.
References DoSetup(), m_node, and NS_LOG_FUNCTION.
void ns3::Ipv4Interface::SetTrafficControl | ( | Ptr< TrafficControlLayer > | tc | ) |
Set the TrafficControlLayer.
tc | TrafficControlLayer object |
Definition at line 107 of file ipv4-interface.cc.
References m_tc, and NS_LOG_FUNCTION.
void ns3::Ipv4Interface::SetUp | ( | void | ) |
Enable this interface.
Definition at line 184 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::SetUp().
ARP cache.
Definition at line 224 of file ipv4-interface.h.
Referenced by DoDispose(), DoSetup(), GetArpCache(), Send(), and SetArpCache().
The associated NetDevice.
Definition at line 222 of file ipv4-interface.h.
Referenced by DoDispose(), DoSetup(), GetDevice(), Send(), and SetDevice().
|
private |
Forwarding state.
Definition at line 218 of file ipv4-interface.h.
Referenced by IsForwarding(), and SetForwarding().
|
private |
Address list.
Definition at line 220 of file ipv4-interface.h.
Referenced by AddAddress(), GetAddress(), GetNAddresses(), RemoveAddress(), and Send().
|
private |
|
private |
Interface metric.
Definition at line 219 of file ipv4-interface.h.
Referenced by GetMetric(), and SetMetric().
The associated node.
Definition at line 221 of file ipv4-interface.h.
Referenced by DoDispose(), DoSetup(), Send(), and SetNode().
|
private |
The associated TrafficControlLayer.
Definition at line 223 of file ipv4-interface.h.
Referenced by DoDispose(), Send(), and SetTrafficControl().