ns-3
ns3::Ipv6L3Protocol Class Reference

IPv6 layer implementation. More...

#include <ipv6-l3-protocol.h>

Inheritance diagram for ns3::Ipv6L3Protocol:
Collaboration diagram for ns3::Ipv6L3Protocol:

List of all members.

Public Types

enum  DropReason {
  DROP_TTL_EXPIRED = 1, DROP_NO_ROUTE, DROP_INTERFACE_DOWN, DROP_ROUTE_ERROR,
  DROP_UNKNOWN_PROTOCOL
}
 Reason why a packet has been dropped. More...

Public Member Functions

 Ipv6L3Protocol ()
 Constructor.
virtual ~Ipv6L3Protocol ()
 Destructor.
void SetNode (Ptr< Node > node)
 Set node for this stack.
void Insert (Ptr< IpL4Protocol > protocol)
 Add an L4 protocol.
void Remove (Ptr< IpL4Protocol > protocol)
 Remove an L4 protocol.
Ptr< IpL4ProtocolGetProtocol (int protocolNumber) const
 Get L4 protocol by protocol number.
Ptr< SocketCreateRawSocket ()
 Create raw IPv6 socket.
void DeleteRawSocket (Ptr< Socket > socket)
 Remove raw IPv6 socket.
void SetDefaultTtl (uint8_t ttl)
 Set the default TTL.
void Receive (Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
 Receive method when a packet arrive in the stack. This method removes IPv6 header and forward up to L4 protocol.
void Send (Ptr< Packet > packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr< Ipv6Route > route)
 Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers.
void SetRoutingProtocol (Ptr< Ipv6RoutingProtocol > routingProtocol)
 Set routing protocol for this stack.
Ptr< Ipv6RoutingProtocolGetRoutingProtocol () const
 Get current routing protocol used.
uint32_t AddInterface (Ptr< NetDevice > device)
 Add IPv6 interface for a device.
Ptr< Ipv6InterfaceGetInterface (uint32_t i) const
 Get an interface.
uint32_t GetNInterfaces () const
 Get current number of interface on this stack.
int32_t GetInterfaceForAddress (Ipv6Address addr) const
 Get interface index which has specified IPv6 address.
int32_t GetInterfaceForPrefix (Ipv6Address addr, Ipv6Prefix mask) const
 Get interface index which match specified address/prefix.
int32_t GetInterfaceForDevice (Ptr< const NetDevice > device) const
 Get interface index which is on a specified net device.
bool AddAddress (uint32_t i, Ipv6InterfaceAddress address)
 Add an address on interface.
Ipv6InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const
 Get an address.
uint32_t GetNAddresses (uint32_t interface) const
 Get number of address for an interface.
bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex)
 Remove an address from an interface.
void SetMetric (uint32_t i, uint16_t metric)
 Set metric for an interface.
uint16_t GetMetric (uint32_t i) const
 Get metric for an interface.
uint16_t GetMtu (uint32_t i) const
 Get MTU for an interface.
bool IsUp (uint32_t i) const
 Is specified interface up ?
void SetUp (uint32_t i)
 Set an interface up.
void SetDown (uint32_t i)
 set an interface down.
bool IsForwarding (uint32_t i) const
 Is interface allows forwarding ?
void SetForwarding (uint32_t i, bool val)
 Enable or disable forwarding on interface.
Ptr< NetDeviceGetNetDevice (uint32_t i)
 Get device by index.
Ptr< Icmpv6L4ProtocolGetIcmpv6 () const
 Get ICMPv6 protocol.
void AddAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, uint8_t flags, uint32_t validTime, uint32_t preferredTime, Ipv6Address defaultRouter=Ipv6Address::GetZero())
 Add an autoconfigured address with RA information.
void RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, Ipv6Address defaultRouter)
 Remove an autoconfigured address.
virtual void RegisterExtensions ()
 Register the IPv6 Extensions.
virtual void RegisterOptions ()
 Register the IPv6 Options.
- Public Member Functions inherited from ns3::Ipv6
 Ipv6 ()
 Constructor.
virtual ~Ipv6 ()
 Destructor.
- Public Member Functions inherited from ns3::Object
virtual TypeId GetInstanceTypeId (void) const
template<typename T >
Ptr< T > GetObject (void) const
template<typename T >
Ptr< T > GetObject (TypeId tid) const
void Dispose (void)
void AggregateObject (Ptr< Object > other)
AggregateIterator GetAggregateIterator (void) const
void Start (void)
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount (const SimpleRefCount &o)
SimpleRefCountoperator= (const SimpleRefCount &o)
void Ref (void) const
void Unref (void) const
uint32_t GetReferenceCount (void) const
- Public Member Functions inherited from ns3::ObjectBase
void SetAttribute (std::string name, const AttributeValue &value)
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
void GetAttribute (std::string name, AttributeValue &value) const
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
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 ()
 Get the type ID of this class.

Static Public Attributes

static const uint16_t PROT_NUMBER = 0x86DD
 The protocol number for IPv6 (0x86DD).
- Static Public Attributes inherited from ns3::Ipv6
static const uint32_t IF_ANY = 0xffffffff
 Any interface magic number.

Protected Member Functions

virtual void DoDispose ()
 Dispose object.
virtual void NotifyNewAggregate ()
 Notify other components connected to the node that a new stack member is now connected.

Friends

class Ipv6L3ProtocolTestCase
class Ipv6ExtensionLooseRouting

Detailed Description

IPv6 layer implementation.

This class contains two distinct groups of trace sources. The trace sources 'Rx' and 'Tx' are called, respectively, immediately after receiving from the NetDevice and immediately before sending to a NetDevice for transmitting a packet. These are low level trace sources that include the Ipv6Header already serialized into the packet. In contrast, the Drop, SendOutgoing, UnicastForward, and LocalDeliver trace sources are slightly higher-level and pass around the Ipv6Header as an explicit parameter and not as part of the packet.


Member Enumeration Documentation

Reason why a packet has been dropped.

Enumerator:
DROP_TTL_EXPIRED 

Packet TTL has expired

DROP_NO_ROUTE 

No route to host

DROP_INTERFACE_DOWN 

Interface is down so can not send packet

DROP_ROUTE_ERROR 

Route error

DROP_UNKNOWN_PROTOCOL 

Unknown L4 protocol


Member Function Documentation

bool ns3::Ipv6L3Protocol::AddAddress ( uint32_t  i,
Ipv6InterfaceAddress  address 
)
virtual

Add an address on interface.

Parameters:
iinterface index
addressto add

Implements ns3::Ipv6.

References ns3::Ipv6Interface::AddAddress(), GetInterface(), ns3::Ipv6RoutingProtocol::NotifyAddAddress(), and NS_LOG_FUNCTION.

Referenced by AddAutoconfiguredAddress().

void ns3::Ipv6L3Protocol::AddAutoconfiguredAddress ( uint32_t  interface,
Ipv6Address  network,
Ipv6Prefix  mask,
uint8_t  flags,
uint32_t  validTime,
uint32_t  preferredTime,
Ipv6Address  defaultRouter = Ipv6Address::GetZero () 
)

Add an autoconfigured address with RA information.

Parameters:
interfaceinterface index
networknetwork prefix
masknetwork mask
flagsflags of the prefix information option (home agent, ...)
validTimevalid time of the prefix
preferredTimepreferred time of the prefix
defaultRouterdefault router address

References AddAddress(), ns3::Mac48Address::ConvertFrom(), ns3::Ipv6InterfaceAddress::GetAddress(), ns3::NetDevice::GetAddress(), ns3::Ipv6Address::GetAny(), ns3::Ipv6Interface::GetDevice(), GetInterface(), GetRoutingProtocol(), ns3::Mac48Address::IsMatchingType(), ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6RoutingProtocol::NotifyAddRoute(), NS_FATAL_ERROR, NS_LOG_FUNCTION, and NS_LOG_INFO.

uint32_t ns3::Ipv6L3Protocol::AddInterface ( Ptr< NetDevice device)
virtual

Add IPv6 interface for a device.

Parameters:
devicenet device
Returns:
interface index

Implements ns3::Ipv6.

References ns3::MakeCallback(), NS_LOG_FUNCTION, PROT_NUMBER, Receive(), and ns3::Node::RegisterProtocolHandler().

Ptr< Socket > ns3::Ipv6L3Protocol::CreateRawSocket ( void  )

Create raw IPv6 socket.

Returns:
newly raw socket

References NS_LOG_FUNCTION_NOARGS.

void ns3::Ipv6L3Protocol::DeleteRawSocket ( Ptr< Socket socket)

Remove raw IPv6 socket.

Parameters:
socketsocket to remove

References NS_LOG_FUNCTION.

Ipv6InterfaceAddress ns3::Ipv6L3Protocol::GetAddress ( uint32_t  interfaceIndex,
uint32_t  addressIndex 
) const
virtual

Get an address.

Parameters:
interfaceIndexinterface index
addressIndexaddress index on the interface
Returns:
Ipv6InterfaceAddress or assert if not found

Implements ns3::Ipv6.

References ns3::Ipv6Interface::GetAddress(), GetInterface(), and NS_LOG_FUNCTION.

Ptr< Icmpv6L4Protocol > ns3::Ipv6L3Protocol::GetIcmpv6 ( ) const
Ptr< Ipv6Interface > ns3::Ipv6L3Protocol::GetInterface ( uint32_t  i) const
int32_t ns3::Ipv6L3Protocol::GetInterfaceForAddress ( Ipv6Address  addr) const
virtual

Get interface index which has specified IPv6 address.

Parameters:
addrIPv6 address
Returns:
interface index or -1 if not found

Implements ns3::Ipv6.

References NS_LOG_FUNCTION.

Referenced by Send().

int32_t ns3::Ipv6L3Protocol::GetInterfaceForDevice ( Ptr< const NetDevice device) const
virtual

Get interface index which is on a specified net device.

Parameters:
devicenet device

Implements ns3::Ipv6.

References NS_LOG_FUNCTION.

Referenced by Send().

int32_t ns3::Ipv6L3Protocol::GetInterfaceForPrefix ( Ipv6Address  addr,
Ipv6Prefix  mask 
) const
virtual

Get interface index which match specified address/prefix.

Parameters:
addrIPv6 address
maskIPv6 prefix (mask)
Returns:
interface index or -1 if not found

Implements ns3::Ipv6.

References ns3::Ipv6Address::CombinePrefix(), and NS_LOG_FUNCTION.

uint16_t ns3::Ipv6L3Protocol::GetMetric ( uint32_t  i) const
virtual

Get metric for an interface.

Parameters:
iindex
Returns:
metric

Implements ns3::Ipv6.

References GetInterface(), ns3::Ipv6Interface::GetMetric(), and NS_LOG_FUNCTION.

uint16_t ns3::Ipv6L3Protocol::GetMtu ( uint32_t  i) const
virtual

Get MTU for an interface.

Parameters:
iindex
Returns:
MTU

Implements ns3::Ipv6.

References ns3::Ipv6Interface::GetDevice(), GetInterface(), ns3::NetDevice::GetMtu(), and NS_LOG_FUNCTION.

uint32_t ns3::Ipv6L3Protocol::GetNAddresses ( uint32_t  interface) const
virtual

Get number of address for an interface.

Parameters:
interfaceinterface index
Returns:
number of address

Implements ns3::Ipv6.

References GetInterface(), ns3::Ipv6Interface::GetNAddresses(), and NS_LOG_FUNCTION.

Ptr< NetDevice > ns3::Ipv6L3Protocol::GetNetDevice ( uint32_t  i)
virtual

Get device by index.

Parameters:
idevice index on this stack
Returns:
NetDevice pointer

Implements ns3::Ipv6.

References ns3::Ipv6Interface::GetDevice(), GetInterface(), and NS_LOG_FUNCTION.

Referenced by Send().

uint32_t ns3::Ipv6L3Protocol::GetNInterfaces ( void  ) const
virtual

Get current number of interface on this stack.

Returns:
number of interface registered

Implements ns3::Ipv6.

References NS_LOG_FUNCTION_NOARGS.

Ptr< IpL4Protocol > ns3::Ipv6L3Protocol::GetProtocol ( int  protocolNumber) const

Get L4 protocol by protocol number.

Parameters:
protocolNumberprotocol number
Returns:
corresponding Ipv6L4Protocol or 0 if not found

References NS_LOG_FUNCTION.

Referenced by GetIcmpv6().

Ptr< Ipv6RoutingProtocol > ns3::Ipv6L3Protocol::GetRoutingProtocol ( void  ) const
virtual

Get current routing protocol used.

Returns:
routing protocol

Implements ns3::Ipv6.

References NS_LOG_FUNCTION_NOARGS.

Referenced by AddAutoconfiguredAddress(), and RemoveAutoconfiguredAddress().

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

Get the type ID of this class.

This method returns the TypeId associated to ns3::Ipv6L3Protocol.

Returns:
type ID

Attributes defined for this type:

  • DefaultTtl: The TTL value set by default on all outgoing packets generated on this node.
  • InterfaceList: The set of IPv6 interfaces associated to this IPv6 stack.
  • SendIcmpv6Redirect: Send the ICMPv6 Redirect when appropriate.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: true
    • Flags: construct write read

Attributes defined in parent class ns3::Ipv6:

  • IpForward: Globally enable or disable IP forwarding for all current and future IPv6 devices.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read

TraceSources defined for this type:

  • Tx: Send IPv6 packet to outgoing interface.
  • Rx: Receive IPv6 packet from incoming interface.
  • Drop: Drop IPv6 packet

Reimplemented from ns3::Ipv6.

References ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().

void ns3::Ipv6L3Protocol::Insert ( Ptr< IpL4Protocol protocol)

Add an L4 protocol.

Parameters:
protocolL4 protocol

References NS_LOG_FUNCTION.

bool ns3::Ipv6L3Protocol::IsForwarding ( uint32_t  i) const
virtual

Is interface allows forwarding ?

Parameters:
iinterface index

Implements ns3::Ipv6.

References GetInterface(), ns3::Ipv6Interface::IsForwarding(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

bool ns3::Ipv6L3Protocol::IsUp ( uint32_t  i) const
virtual

Is specified interface up ?

Parameters:
iinterface index

Implements ns3::Ipv6.

References GetInterface(), ns3::Ipv6Interface::IsUp(), and NS_LOG_FUNCTION.

void ns3::Ipv6L3Protocol::NotifyNewAggregate ( void  )
protectedvirtual

Notify other components connected to the node that a new stack member is now connected.

This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.

Reimplemented from ns3::Object.

References NS_LOG_FUNCTION_NOARGS, and SetNode().

void ns3::Ipv6L3Protocol::Receive ( Ptr< NetDevice device,
Ptr< const Packet p,
uint16_t  protocol,
const Address from,
const Address to,
NetDevice::PacketType  packetType 
)

Receive method when a packet arrive in the stack. This method removes IPv6 header and forward up to L4 protocol.

Parameters:
devicenetwork device
pthe packet
protocolnext header value
fromaddress of the correspondant
toaddress of the destination
packetTypetype of the packet

References ns3::Packet::Copy(), DROP_INTERFACE_DOWN, DROP_NO_ROUTE, ns3::Ipv6Header::GetDestinationAddress(), ns3::Ipv6Interface::GetDevice(), ns3::Node::GetId(), ns3::Ipv6Header::GetNextHeader(), ns3::Object::GetObject(), ns3::Ipv6Header::GetPayloadLength(), ns3::Ipv6Interface::IsUp(), ns3::MakeCallback(), NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, and ns3::Ipv6RoutingProtocol::RouteInput().

Referenced by AddInterface().

void ns3::Ipv6L3Protocol::Remove ( Ptr< IpL4Protocol protocol)

Remove an L4 protocol.

Parameters:
protocolL4 protocol to remove

References NS_LOG_FUNCTION.

bool ns3::Ipv6L3Protocol::RemoveAddress ( uint32_t  interfaceIndex,
uint32_t  addressIndex 
)
virtual

Remove an address from an interface.

Parameters:
interfaceIndexinterface index
addressIndexaddress index on the interface

Implements ns3::Ipv6.

References GetInterface(), ns3::Ipv6RoutingProtocol::NotifyRemoveAddress(), NS_LOG_FUNCTION, and ns3::Ipv6Interface::RemoveAddress().

Referenced by RemoveAutoconfiguredAddress().

void ns3::Ipv6L3Protocol::RemoveAutoconfiguredAddress ( uint32_t  interface,
Ipv6Address  network,
Ipv6Prefix  mask,
Ipv6Address  defaultRouter 
)
void ns3::Ipv6L3Protocol::Send ( Ptr< Packet packet,
Ipv6Address  source,
Ipv6Address  destination,
uint8_t  protocol,
Ptr< Ipv6Route route 
)
void ns3::Ipv6L3Protocol::SetDefaultTtl ( uint8_t  ttl)

Set the default TTL.

Parameters:
ttlTTL to set

References NS_LOG_FUNCTION.

void ns3::Ipv6L3Protocol::SetDown ( uint32_t  i)
virtual

set an interface down.

Parameters:
iinterface index

Implements ns3::Ipv6.

References GetInterface(), ns3::Ipv6RoutingProtocol::NotifyInterfaceDown(), NS_LOG_FUNCTION, and ns3::Ipv6Interface::SetDown().

void ns3::Ipv6L3Protocol::SetForwarding ( uint32_t  i,
bool  val 
)
virtual

Enable or disable forwarding on interface.

Parameters:
iinterface index
valtrue = enable forwarding, false = disable

Implements ns3::Ipv6.

References GetInterface(), NS_LOG_FUNCTION, and ns3::Ipv6Interface::SetForwarding().

void ns3::Ipv6L3Protocol::SetMetric ( uint32_t  i,
uint16_t  metric 
)
virtual

Set metric for an interface.

Parameters:
iindex
metric

Implements ns3::Ipv6.

References GetInterface(), NS_LOG_FUNCTION, and ns3::Ipv6Interface::SetMetric().

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

Set node for this stack.

Parameters:
nodenode to set

References NS_LOG_FUNCTION.

Referenced by NotifyNewAggregate().

void ns3::Ipv6L3Protocol::SetRoutingProtocol ( Ptr< Ipv6RoutingProtocol routingProtocol)
virtual

Set routing protocol for this stack.

Parameters:
routingProtocolIPv6 routing protocol to set

Implements ns3::Ipv6.

References NS_LOG_FUNCTION, and ns3::Ipv6RoutingProtocol::SetIpv6().

void ns3::Ipv6L3Protocol::SetUp ( uint32_t  i)
virtual

Set an interface up.

Parameters:
iinterface index

Implements ns3::Ipv6.

References GetInterface(), ns3::Ipv6RoutingProtocol::NotifyInterfaceUp(), NS_LOG_FUNCTION, and ns3::Ipv6Interface::SetUp().


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