A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::Mac8Address Class Reference

A class used for addressing MAC8 MAC's. More...

#include "mac8-address.h"

+ Collaboration diagram for ns3::Mac8Address:

Public Member Functions

 Mac8Address ()
 Constructor.
 
 Mac8Address (uint8_t addr)
 Create Mac8Address object with address addr.
 
virtual ~Mac8Address ()
 Destructor.
 
Address ConvertTo () const
 Convert to a generic Address.
 
void CopyFrom (const uint8_t *pBuffer)
 Sets address to address stored in parameter.
 
void CopyTo (uint8_t *pBuffer) const
 Writes address to buffer parameter.
 
 operator Address () const
 Create a generic Address.
 

Static Public Member Functions

static Mac8Address Allocate ()
 Allocates Mac8Address from 0-254.
 
static Mac8Address ConvertFrom (const Address &address)
 Convert a generic address to a Mac8Address.
 
static Mac8Address GetBroadcast ()
 Get the broadcast address (255).
 
static bool IsMatchingType (const Address &address)
 Check that a generic Address is compatible with Mac8Address.
 
static void ResetAllocationIndex ()
 Reset the Mac8Address allocation index.
 

Static Private Member Functions

static uint8_t GetType ()
 Get the Mac8Address type.
 

Private Attributes

uint8_t m_address
 The address.
 

Static Private Attributes

static uint8_t m_allocationIndex = 0
 Address allocation index.
 

Friends

bool operator!= (const Mac8Address &a, const Mac8Address &b)
 Address comparison, unequal.
 
bool operator< (const Mac8Address &a, const Mac8Address &b)
 Address comparison, less than.
 
std::ostream & operator<< (std::ostream &os, const Mac8Address &address)
 Write address to stream os as 8 bit integer.
 
bool operator== (const Mac8Address &a, const Mac8Address &b)
 Address comparison, equality.
 
std::istream & operator>> (std::istream &is, Mac8Address &address)
 Read address from stream is as 8 bit integer.
 

Detailed Description

A class used for addressing MAC8 MAC's.

This implementation uses a simple 8 bit flat addressing scheme. It is unlikely that perceived underwater networks will soon exceed 200 nodes (or the overlapping of two underwater networks

  • the ocean is big), so this should provide adequate addressing for most applications.

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

Constructor & Destructor Documentation

◆ Mac8Address() [1/2]

ns3::Mac8Address::Mac8Address ( )

Constructor.

Definition at line 33 of file mac8-address.cc.

References m_address.

Referenced by Allocate(), and GetBroadcast().

+ Here is the caller graph for this function:

◆ Mac8Address() [2/2]

ns3::Mac8Address::Mac8Address ( uint8_t  addr)

Create Mac8Address object with address addr.

Parameters
addrByte address to assign to this address.

Definition at line 38 of file mac8-address.cc.

◆ ~Mac8Address()

ns3::Mac8Address::~Mac8Address ( )
virtual

Destructor.

Definition at line 43 of file mac8-address.cc.

Member Function Documentation

◆ Allocate()

Mac8Address ns3::Mac8Address::Allocate ( )
static

Allocates Mac8Address from 0-254.

Will wrap back to 0 if more than 254 are allocated. Excludes the broadcast address.

Returns
The next sequential Mac8Address.

Definition at line 99 of file mac8-address.cc.

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

Referenced by UanTest::CreateNode(), and ns3::UanHelper::Install().

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

◆ ConvertFrom()

◆ ConvertTo()

Address ns3::Mac8Address::ConvertTo ( ) const

Convert to a generic Address.

Returns
The Address value.

Definition at line 55 of file mac8-address.cc.

References GetType(), and m_address.

+ Here is the call graph for this function:

◆ CopyFrom()

void ns3::Mac8Address::CopyFrom ( const uint8_t *  pBuffer)

Sets address to address stored in parameter.

Parameters
pBufferBuffer to extract address from.

Definition at line 81 of file mac8-address.cc.

References m_address.

◆ CopyTo()

void ns3::Mac8Address::CopyTo ( uint8_t *  pBuffer) const

Writes address to buffer parameter.

Parameters
pBuffer

Definition at line 87 of file mac8-address.cc.

References m_address.

Referenced by ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(), ns3::UanHeaderCommon::Serialize(), and ns3::UanHeaderRcCts::Serialize().

+ Here is the caller graph for this function:

◆ GetBroadcast()

Mac8Address ns3::Mac8Address::GetBroadcast ( )
static

Get the broadcast address (255).

Returns
Broadcast address.

Definition at line 93 of file mac8-address.cc.

References Mac8Address().

Referenced by ns3::UanMacRc::Associate(), ns3::UanMacRc::AssociateTimeout(), ns3::UanMacCw::PhyRxPacketGood(), ns3::UanMacRc::ReceiveOkFromPhy(), ns3::UanMacRcGw::ReceivePacket(), ns3::UanMacRc::RtsTimeout(), ns3::UanMacAloha::RxPacketGood(), ns3::UanMacRc::SendRts(), and ns3::UanMacRcGw::StartCycle().

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

◆ GetType()

uint8_t ns3::Mac8Address::GetType ( )
staticprivate

Get the Mac8Address type.

Returns
The type value.

Definition at line 48 of file mac8-address.cc.

References ns3::Address::Register().

Referenced by ConvertTo(), and IsMatchingType().

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

◆ IsMatchingType()

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

Check that a generic Address is compatible with Mac8Address.

Parameters
addressAddress to test.
Returns
True if address given is consistent with Mac8Address.

Definition at line 70 of file mac8-address.cc.

References GetType().

Referenced by ConvertFrom(), ns3::MockNetDevice::IsBroadcast(), ns3::MockNetDevice::IsMulticast(), ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(), and ns3::Ipv6AddressHelper::NewAddress().

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

◆ operator Address()

ns3::Mac8Address::operator Address ( ) const

Create a generic Address.

Returns
The Address.

Definition at line 75 of file mac8-address.cc.

◆ ResetAllocationIndex()

void ns3::Mac8Address::ResetAllocationIndex ( )
static

Reset the Mac8Address 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 118 of file mac8-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 Mac8Address a,
const Mac8Address b 
)
friend

Address comparison, unequal.

Parameters
aFirst address to compare.
bSecond address to compare.
Returns
True if a != b.

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

◆ operator<

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

Address comparison, less than.

Parameters
aFirst address to compare.
bSecond address to compare.
Returns
True if a < b.

Definition at line 125 of file mac8-address.cc.

◆ operator<<

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

Write address to stream os as 8 bit integer.

Parameters
osThe output stream.
addressThe address
Returns
The output stream.

Definition at line 143 of file mac8-address.cc.

◆ operator==

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

Address comparison, equality.

Parameters
aFirst address to compare.
bSecond address to compare.
Returns
True if a == b.

Definition at line 132 of file mac8-address.cc.

◆ operator>>

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

Read address from stream is as 8 bit integer.

Parameters
isThe input stream.
addressThe address variable to set.
Returns
The input stream.

Definition at line 151 of file mac8-address.cc.

Member Data Documentation

◆ m_address

uint8_t ns3::Mac8Address::m_address
private

The address.

Definition at line 135 of file mac8-address.h.

Referenced by Mac8Address(), ConvertFrom(), ConvertTo(), CopyFrom(), and CopyTo().

◆ m_allocationIndex

uint8_t ns3::Mac8Address::m_allocationIndex = 0
staticprivate

Address allocation index.

Definition at line 134 of file mac8-address.h.

Referenced by Allocate(), and ResetAllocationIndex().


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