A Discrete-Event Network Simulator
API
ns3::Mac16Address Class Reference

This class can contain 16 bit addresses. More...

#include "mac16-address.h"

+ Collaboration diagram for ns3::Mac16Address:

Public Member Functions

 Mac16Address ()=default
 
 Mac16Address (const char *str)
 
 Mac16Address (uint16_t addr)
 
Address ConvertTo () const
 
uint16_t ConvertToInt () const
 
void CopyFrom (const uint8_t buffer[2])
 
void CopyTo (uint8_t buffer[2]) const
 
bool IsBroadcast () const
 Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF). More...
 
bool IsMulticast () const
 Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e., if its first 3 bits are 100). More...
 
 operator Address () const
 

Static Public Member Functions

static Mac16Address Allocate ()
 Allocate a new Mac16Address. More...
 
static Mac16Address ConvertFrom (const Address &address)
 
static Mac16Address GetBroadcast ()
 
static Mac16Address GetMulticast (Ipv6Address address)
 Returns the multicast address associated with an IPv6 address according to RFC 4944 Section 9. More...
 
static bool IsMatchingType (const Address &address)
 
static void ResetAllocationIndex ()
 Reset the Mac16Address allocation index. More...
 

Static Private Member Functions

static uint8_t GetType ()
 Return the Type of address. More...
 

Private Attributes

uint8_t m_address [2] {0}
 Address value. More...
 

Static Private Attributes

static uint64_t m_allocationIndex = 0
 Address allocation index. More...
 

Friends

bool operator!= (const Mac16Address &a, const Mac16Address &b)
 Not equal to operator. More...
 
bool operator< (const Mac16Address &a, const Mac16Address &b)
 Less than operator. More...
 
std::ostream & operator<< (std::ostream &os, const Mac16Address &address)
 Stream insertion operator. More...
 
bool operator== (const Mac16Address &a, const Mac16Address &b)
 Equal to operator. More...
 
std::istream & operator>> (std::istream &is, Mac16Address &address)
 Stream extraction operator. More...
 

Detailed Description

This class can contain 16 bit addresses.

See also
attribute_Mac16Address

Definition at line 43 of file mac16-address.h.

Constructor & Destructor Documentation

◆ Mac16Address() [1/3]

ns3::Mac16Address::Mac16Address ( )
default

◆ Mac16Address() [2/3]

ns3::Mac16Address::Mac16Address ( const char *  str)
Parameters
stra string representing the new Mac16Address

The format of the string is "xx:xx"

Definition at line 40 of file mac16-address.cc.

References m_address, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

◆ Mac16Address() [3/3]

ns3::Mac16Address::Mac16Address ( uint16_t  addr)
Parameters
addrThe 16 bit unsigned integer used to create a Mac16Address object.

Create a Mac16Address from an 16 bit unsigned integer.

Definition at line 54 of file mac16-address.cc.

References m_address, and NS_LOG_FUNCTION.

Member Function Documentation

◆ Allocate()

Mac16Address ns3::Mac16Address::Allocate ( )
static

Allocate a new Mac16Address.

Returns
newly allocated mac16Address

Definition at line 114 of file mac16-address.cc.

References first::address, m_allocationIndex, NS_LOG_FUNCTION_NOARGS, ResetAllocationIndex(), and ns3::Simulator::ScheduleDestroy().

+ Here is the call graph for this function:

◆ ConvertFrom()

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

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

Definition at line 88 of file mac16-address.cc.

References first::address, GetType(), m_address, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(), ns3::Ipv6AddressHelper::NewAddress(), ns3::SixLowPanMesh::Print(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), ns3::LrWpanNetDevice::Send(), and ns3::LrWpanNetDevice::SetAddress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConvertTo()

Address ns3::Mac16Address::ConvertTo ( ) const
Returns
a new Address instance

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

Definition at line 98 of file mac16-address.cc.

References GetType(), m_address, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ ConvertToInt()

uint16_t ns3::Mac16Address::ConvertToInt ( ) const
Returns
the mac address in a 16 bit unsigned integer

Convert an instance of this class to a 16 bit unsigned integer.

Definition at line 105 of file mac16-address.cc.

References m_address.

◆ CopyFrom()

void ns3::Mac16Address::CopyFrom ( const uint8_t  buffer[2])
Parameters
bufferaddress in network order

Copy the input address to our internal buffer.

Definition at line 62 of file mac16-address.cc.

References m_address, and NS_LOG_FUNCTION.

Referenced by AssociateIndication(), ns3::LrWpanHelper::CreateAssociatedPan(), ns3::SixLowPanNetDevice::Get16MacFrom48Mac(), GetMulticast(), ns3::ReadFrom(), ns3::LrWpanNetDevice::Send(), and ns3::LrWpanNetDevice::SetAddress().

+ Here is the caller graph for this function:

◆ CopyTo()

void ns3::Mac16Address::CopyTo ( uint8_t  buffer[2]) const
Parameters
bufferaddress in network order

Copy the internal address to the input buffer.

Definition at line 69 of file mac16-address.cc.

References m_address, and NS_LOG_FUNCTION.

Referenced by ns3::LrWpanNetDevice::BuildPseudoMacAddress(), ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(), and ns3::WriteTo().

+ Here is the caller graph for this function:

◆ GetBroadcast()

Mac16Address ns3::Mac16Address::GetBroadcast ( )
static
Returns
the broadcast address (0xFFFF)

Definition at line 147 of file mac16-address.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::LrWpanNetDevice::GetBroadcast(), and ns3::MockNetDevice::GetBroadcast().

+ Here is the caller graph for this function:

◆ GetMulticast()

Mac16Address ns3::Mac16Address::GetMulticast ( Ipv6Address  address)
static

Returns the multicast address associated with an IPv6 address according to RFC 4944 Section 9.

An IPv6 packet with a multicast destination address (DST), consisting of the sixteen octets DST[1] through DST[16], is transmitted to the following 802.15.4 16-bit multicast address:

  0                   1
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |1 0 0|DST[15]* |   DST[16]     |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Here, DST[15]* refers to the last 5 bits in octet DST[15], that is, bits 3-7 within DST[15]. The initial 3-bit pattern of "100" follows the 16-bit address format for multicast addresses (Section 12).

Parameters
addressbase IPv6 address
Returns
the multicast 16-bit address.

Definition at line 156 of file mac16-address.cc.

References first::address, CopyFrom(), and NS_LOG_FUNCTION.

Referenced by ns3::MockNetDevice::GetMulticast(), and ns3::LrWpanNetDevice::GetMulticast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetType()

uint8_t ns3::Mac16Address::GetType ( )
staticprivate

Return the Type of address.

Returns
type of address

Definition at line 138 of file mac16-address.cc.

References NS_LOG_FUNCTION_NOARGS, ns3::Address::Register(), and check-style-clang-format::type.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsBroadcast()

bool ns3::Mac16Address::IsBroadcast ( ) const

Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).

Returns
true if the address is 0xFFFF

Definition at line 175 of file mac16-address.cc.

References m_address, and NS_LOG_FUNCTION.

Referenced by LrWpanDataIfsTestCase::DataReceivedDev0(), LrWpanDataIfsTestCase::DataReceivedDev1(), ns3::LrWpanMac::McpsDataRequest(), ns3::LrWpanMac::PdDataIndication(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), and ns3::LrWpanMac::RemoveFirstTxQElement().

+ Here is the caller graph for this function:

◆ IsMatchingType()

bool ns3::Mac16Address::IsMatchingType ( const Address address)
static

◆ IsMulticast()

bool ns3::Mac16Address::IsMulticast ( ) const

Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e., if its first 3 bits are 100).

Returns
true if the address is in the range 0x8000 - 0x9FFF

Definition at line 182 of file mac16-address.cc.

References m_address, and NS_LOG_FUNCTION.

Referenced by ns3::LrWpanMac::McpsDataRequest(), ns3::LrWpanMac::PdDataIndication(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), and ns3::LrWpanMac::RemoveFirstTxQElement().

+ Here is the caller graph for this function:

◆ operator Address()

ns3::Mac16Address::operator Address ( ) const
Returns
a new Address instance

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

Definition at line 82 of file mac16-address.cc.

◆ ResetAllocationIndex()

void ns3::Mac16Address::ResetAllocationIndex ( )
static

Reset the Mac16Address allocation index.

This function resets (to zero) the global integer that is used for unique address allocation. It is automatically called whenever

SimulatorDestroy ();

is called. It may also be optionally called by user code if there is a need to force a reset of this allocation index.

Definition at line 131 of file mac16-address.cc.

References m_allocationIndex, and NS_LOG_FUNCTION_NOARGS.

Referenced by Allocate().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Mac16Address a,
const Mac16Address b 
)
friend

Not equal to operator.

Parameters
athe first operand
bthe first operand
Returns
true if the operands are not equal

Definition at line 244 of file mac16-address.h.

◆ operator<

bool operator< ( const Mac16Address a,
const Mac16Address b 
)
friend

Less than operator.

Parameters
athe first operand
bthe first operand
Returns
true if the operand a is less than operand b

Definition at line 249 of file mac16-address.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Mac16Address address 
)
friend

Stream insertion operator.

Parameters
osthe stream
addressthe address
Returns
a reference to the stream

Definition at line 190 of file mac16-address.cc.

◆ operator==

bool operator== ( const Mac16Address a,
const Mac16Address b 
)
friend

Equal to operator.

Parameters
athe first operand
bthe first operand
Returns
true if the operands are equal

Definition at line 238 of file mac16-address.h.

◆ operator>>

std::istream& operator>> ( std::istream &  is,
Mac16Address address 
)
friend

Stream extraction operator.

Parameters
isthe stream
addressthe address
Returns
a reference to the stream

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

Member Data Documentation

◆ m_address

uint8_t ns3::Mac16Address::m_address[2] {0}
private

◆ m_allocationIndex

uint64_t ns3::Mac16Address::m_allocationIndex = 0
staticprivate

Address allocation index.

Definition at line 231 of file mac16-address.h.

Referenced by Allocate(), and ResetAllocationIndex().


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