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

Ipv4 addresses are stored in host order in this class. More...

#include <ipv4-address.h>

Public Member Functions

 Ipv4Address ()
 
 Ipv4Address (uint32_t address)
 input address is in host order. More...
 
 Ipv4Address (char const *address)
 Constructs an Ipv4Address by parsing a the input C-string. More...
 
Ipv4Address CombineMask (Ipv4Mask const &mask) const
 Combine this address with a network mask. More...
 
uint32_t Get (void) const
 Get the host-order 32-bit IP address. More...
 
Ipv4Address GetSubnetDirectedBroadcast (Ipv4Mask const &mask) const
 Generate subnet-directed broadcast address corresponding to mask. More...
 
bool IsBroadcast (void) const
 
bool IsEqual (const Ipv4Address &other) const
 Comparison operation between two Ipv4Addresses. More...
 
bool IsLocalMulticast (void) const
 
bool IsMulticast (void) const
 
bool IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const
 Generate subnet-directed broadcast address corresponding to mask. More...
 
 operator Address () const
 Convert an instance of this class to a polymorphic Address instance. More...
 
void Print (std::ostream &os) const
 Print this address to the given output stream. More...
 
void Serialize (uint8_t buf[4]) const
 Serialize this address to a 4-byte buffer. More...
 
void Set (uint32_t address)
 input address is in host order. More...
 
void Set (char const *address)
 Sets an Ipv4Address by parsing a the input C-string. More...
 

Static Public Member Functions

static Ipv4Address ConvertFrom (const Address &address)
 
static Ipv4Address Deserialize (const uint8_t buf[4])
 
static Ipv4Address GetAny (void)
 
static Ipv4Address GetBroadcast (void)
 
static Ipv4Address GetLoopback (void)
 
static Ipv4Address GetZero (void)
 
static bool IsMatchingType (const Address &address)
 

Private Member Functions

Address ConvertTo (void) const
 

Static Private Member Functions

static uint8_t GetType (void)
 

Private Attributes

uint32_t m_address
 

Friends

bool operator!= (Ipv4Address const &a, Ipv4Address const &b)
 
bool operator< (Ipv4Address const &addrA, Ipv4Address const &addrB)
 
bool operator== (Ipv4Address const &a, Ipv4Address const &b)
 

Detailed Description

Ipv4 addresses are stored in host order in this class.

Definition at line 38 of file ipv4-address.h.

Constructor & Destructor Documentation

ns3::Ipv4Address::Ipv4Address ( )

Definition at line 187 of file ipv4-address.cc.

References NS_LOG_FUNCTION.

Referenced by CombineMask(), and GetSubnetDirectedBroadcast().

+ Here is the caller graph for this function:

ns3::Ipv4Address::Ipv4Address ( uint32_t  address)
explicit

input address is in host order.

Parameters
addressThe host order 32-bit address

Definition at line 192 of file ipv4-address.cc.

References first::address, m_address, and NS_LOG_FUNCTION.

ns3::Ipv4Address::Ipv4Address ( char const *  address)

Constructs an Ipv4Address by parsing a the input C-string.

Input address is in format: hhh.xxx.xxx.lll where h is the high byte and l the low byte

Parameters
addressC-string containing the address as described above

Definition at line 197 of file ipv4-address.cc.

References ns3::AsciiToIpv4Host(), m_address, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Member Function Documentation

Ipv4Address ns3::Ipv4Address::ConvertFrom ( const Address address)
static
Parameters
addressa polymorphic address
Returns
a new Ipv4Address from the polymorphic address

This function performs a type check and asserts if the type of the input address is not compatible with an Ipv4Address.

Definition at line 335 of file ipv4-address.cc.

References ns3::Address::CheckCompatible(), ns3::Address::CopyTo(), Deserialize(), GetType(), NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::UdpSocketImpl::DoSendTo(), ns3::PbbAddressBlockIpv4::PrintAddress(), ns3::PbbMessageIpv4::PrintOriginatorAddress(), ns3::UdpClient::Send(), ns3::UdpEchoClient::Send(), ns3::UdpTraceClient::SendPacket(), ns3::PbbAddressBlockIpv4::SerializeAddress(), ns3::PbbMessageIpv4::SerializeOriginatorAddress(), ns3::UdpClient::StartApplication(), ns3::UdpTraceClient::StartApplication(), and ns3::UdpEchoClient::StartApplication().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Address ns3::Ipv4Address::ConvertTo ( void  ) const
private

Definition at line 326 of file ipv4-address.cc.

References GetType(), NS_LOG_FUNCTION, and Serialize().

+ Here is the call graph for this function:

Ipv4Address ns3::Ipv4Address::GetAny ( void  )
static
Returns
the 0.0.0.0 address

Definition at line 360 of file ipv4-address.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::Ipv4EndPointDemux::Allocate(), ns3::Ipv4RawSocketImpl::Bind(), ns3::UdpSocketImpl::Bind(), ns3::NscTcpSocketImpl::Bind(), ns3::TcpSocketBase::Bind(), BuildAppsTest(), ns3::aodv::Bug772ChainTest::CreateDevices(), ns3::LenaTdTbfqFfMacSchedulerTestCase1::DoRun(), ns3::LenaFdTbfqFfMacSchedulerTestCase1::DoRun(), ns3::LenaPssFfMacSchedulerTestCase1::DoRun(), ns3::LteX2HandoverTestCase::DoRun(), ns3::LenaPssFfMacSchedulerTestCase2::DoRun(), ns3::LenaTdTbfqFfMacSchedulerTestCase2::DoRun(), ns3::LenaFdTbfqFfMacSchedulerTestCase2::DoRun(), ns3::EpcS1uDlTestCase::DoRun(), ns3::LteX2HandoverMeasuresTestCase::DoRun(), ns3::LteEpcE2eDataTestCase::DoRun(), ns3::BriteTopologyFunctionTestCase::DoRun(), ns3::EpcS1uUlTestCase::DoRun(), ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::Ipv4L3Protocol::IpMulticastForward(), ns3::Ipv4RawSocketImpl::Ipv4RawSocketImpl(), ns3::Ipv4EndPointDemux::Lookup(), main(), ns3::aodv::RoutingProtocol::NotifyAddAddress(), ns3::dsdv::RoutingProtocol::NotifyAddAddress(), ns3::aodv::RoutingProtocol::NotifyInterfaceUp(), ns3::dsdv::RoutingProtocol::NotifyInterfaceUp(), ns3::aodv::RoutingProtocol::NotifyRemoveAddress(), ns3::dsdv::RoutingProtocol::NotifyRemoveAddress(), ns3::PointToPointEpcHelper::PointToPointEpcHelper(), RunSimulation(), ns3::Ipv4RawSocketImpl::SendTo(), ns3::Ipv4EndPointDemux::SimpleLookup(), ns3::UdpEchoServer::StartApplication(), ns3::V4Ping::StartApplication(), ns3::UdpServer::StartApplication(), and Tunnel::Tunnel().

+ Here is the caller graph for this function:

Ipv4Address ns3::Ipv4Address::GetBroadcast ( void  )
static
Returns
the 255.255.255.255 address

Definition at line 367 of file ipv4-address.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::Ipv4FlowClassifier::Classify(), and main().

+ Here is the caller graph for this function:

Ipv4Address ns3::Ipv4Address::GetSubnetDirectedBroadcast ( Ipv4Mask const &  mask) const

Generate subnet-directed broadcast address corresponding to mask.

The subnet-directed broadcast address has the host bits set to all ones. If this method is called with a mask of 255.255.255.255, (i.e., the address is a /32 address), the program will assert, since there is no subnet associated with a /32 address.

Parameters
maska network mask

Definition at line 230 of file ipv4-address.cc.

References Get(), ns3::Ipv4Mask::GetInverse(), ns3::Ipv4Mask::GetOnes(), Ipv4Address(), NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Referenced by ns3::UdpSocketImpl::DoSendTo(), ns3::Ipv4FlowProbe::DropLogger(), and ns3::olsr::RoutingProtocol::SendPacket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8_t ns3::Ipv4Address::GetType ( void  )
staticprivate

Definition at line 345 of file ipv4-address.cc.

References NS_LOG_FUNCTION_NOARGS, and ns3::Address::Register().

Referenced by ConvertFrom(), ConvertTo(), and IsMatchingType().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::Ipv4Address::IsEqual ( const Ipv4Address other) const
inline

Comparison operation between two Ipv4Addresses.

Parameters
otheraddress to which to compare this address
Returns
True if the addresses are equal. False otherwise.

Definition at line 81 of file ipv4-address.h.

References m_address.

Referenced by ns3::Ipv4RoutingTableEntry::IsDefault(), ns3::Ipv4RoutingTableEntry::IsGateway(), ns3::ArpL3Protocol::Receive(), ns3::Ipv4StaticRouting::RouteInput(), ns3::Ipv4GlobalRouting::RouteInput(), and ns3::Ipv4L3Protocol::SendRealOut().

+ Here is the caller graph for this function:

bool ns3::Ipv4Address::IsLocalMulticast ( void  ) const
Returns
true only if address is in local multicast address scope, 224.0.0.0/24

Definition at line 272 of file ipv4-address.cc.

References m_address, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4StaticRouting::LookupStatic(), and ns3::Ipv4L3Protocol::Send().

+ Here is the caller graph for this function:

bool ns3::Ipv4Address::IsMatchingType ( const Address address)
static
Parameters
addressan address to compare type with
Returns
true if the type of the address stored internally is compatible with the type of the input address, false otherwise.

Definition at line 315 of file ipv4-address.cc.

References ns3::Address::CheckCompatible(), GetType(), and NS_LOG_FUNCTION.

Referenced by ns3::UdpHeader::CalculateHeaderChecksum(), ns3::TcpHeader::CalculateHeaderChecksum(), ns3::UdpSocketImpl::DoSendTo(), ns3::UdpClient::Send(), ns3::UdpEchoClient::Send(), ns3::UdpTraceClient::SendPacket(), ns3::UdpClient::StartApplication(), ns3::UdpTraceClient::StartApplication(), and ns3::UdpEchoClient::StartApplication().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::Ipv4Address::IsSubnetDirectedBroadcast ( Ipv4Mask const &  mask) const

Generate subnet-directed broadcast address corresponding to mask.

The subnet-directed broadcast address has the host bits set to all ones. If this method is called with a mask of 255.255.255.255, (i.e., the address is a /32 address), the program will assert, since there is no subnet associated with a /32 address.

Parameters
maska network mask
Returns
true if the address, when combined with the input mask, has all of its host bits set to one

Definition at line 241 of file ipv4-address.cc.

References Get(), ns3::Ipv4Mask::GetInverse(), ns3::Ipv4Mask::GetOnes(), and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4L3Protocol::IsUnicast(), ns3::Ipv4L3Protocol::LocalDeliver(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Ipv4Interface::Send(), and ns3::Ipv4L3Protocol::Send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ns3::Ipv4Address::operator Address ( ) const

Convert an instance of this class to a polymorphic Address instance.

Returns
a new Address instance

Definition at line 320 of file ipv4-address.cc.

void ns3::Ipv4Address::Print ( std::ostream &  os) const

Print this address to the given output stream.

The print format is in the typical "192.168.1.1"

Parameters
osThe output stream to which this Ipv4Address is printed

Definition at line 305 of file ipv4-address.cc.

References m_address, and NS_LOG_FUNCTION.

Referenced by ns3::NscTcpL4Protocol::AddInterface(), ns3::NscTcpSocketImpl::Connect(), ns3::operator<<(), ns3::PbbAddressBlockIpv4::PrintAddress(), ns3::PbbMessageIpv4::PrintOriginatorAddress(), and ns3::TcpL4Protocol::Receive().

+ Here is the caller graph for this function:

void ns3::Ipv4Address::Serialize ( uint8_t  buf[4]) const

Serialize this address to a 4-byte buffer.

Parameters
bufoutput buffer to which this address gets overwritten with this Ipv4Address

Definition at line 280 of file ipv4-address.cc.

References m_address, and NS_LOG_FUNCTION.

Referenced by ns3::InetSocketAddress::ConvertTo(), ConvertTo(), ns3::Mac48Address::GetMulticast(), ns3::Ipv6Address::MakeIpv4MappedAddress(), ns3::Ipv4PacketInfoTag::Serialize(), ns3::PbbAddressBlockIpv4::SerializeAddress(), and ns3::PbbMessageIpv4::SerializeOriginatorAddress().

+ Here is the caller graph for this function:

void ns3::Ipv4Address::Set ( uint32_t  address)

input address is in host order.

Parameters
addressThe host order 32-bit address

Definition at line 210 of file ipv4-address.cc.

References first::address, m_address, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4Header::Deserialize(), ns3::EpcTftClassifierTestSuite::EpcTftClassifierTestSuite(), ns3::GlobalRouter::GlobalRouter(), ns3::GlobalRouter::ProcessBridgedBroadcastLink(), ns3::GlobalRouter::ProcessSingleBroadcastLink(), and ns3::ReadFrom().

+ Here is the caller graph for this function:

void ns3::Ipv4Address::Set ( char const *  address)

Sets an Ipv4Address by parsing a the input C-string.

Input address is in format: hhh.xxx.xxx.lll where h is the high byte and l the low byte

Parameters
addressC-string containing the address as described above

Definition at line 216 of file ipv4-address.cc.

References ns3::AsciiToIpv4Host(), m_address, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Friends And Related Function Documentation

bool operator!= ( Ipv4Address const &  a,
Ipv4Address const &  b 
)
friend

Definition at line 301 of file ipv4-address.h.

bool operator< ( Ipv4Address const &  addrA,
Ipv4Address const &  addrB 
)
friend

Definition at line 305 of file ipv4-address.h.

bool operator== ( Ipv4Address const &  a,
Ipv4Address const &  b 
)
friend

Definition at line 297 of file ipv4-address.h.

Member Data Documentation

uint32_t ns3::Ipv4Address::m_address
private

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