ns-3
ns3::Icmpv6L4Protocol Class Reference

An implementation of the ICMPv6 protocol. More...

#include <icmpv6-l4-protocol.h>

Inheritance diagram for ns3::Icmpv6L4Protocol:
Collaboration diagram for ns3::Icmpv6L4Protocol:

List of all members.

Public Member Functions

 Icmpv6L4Protocol ()
 Constructor.
virtual ~Icmpv6L4Protocol ()
 Destructor.
void SetNode (Ptr< Node > node)
 Set the node.
void NotifyNewAggregate ()
 This method is called by AddAgregate and completes the aggregation by setting the node in the ICMPv6 stack and adding ICMPv6 factory to IPv6 stack connected to the node.
virtual int GetProtocolNumber () const
 Get the protocol number.
virtual int GetVersion () const
 Get the version of the protocol.
void SendMessage (Ptr< Packet > packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl)
 Send a packet via ICMPv6, note that packet already contains ICMPv6 header.
void SendMessage (Ptr< Packet > packet, Ipv6Address dst, Icmpv6Header &icmpv6Hdr, uint8_t ttl)
 Send a packet via ICMPv6.
void DoDAD (Ipv6Address target, Ptr< Ipv6Interface > interface)
 Do the Duplication Address Detection (DAD). It consists in sending a NS with our IPv6 as target. If we received a NA with matched target address, we could not use the address, else the address pass from TENTATIVE to PERMANENT.
void SendNA (Ipv6Address src, Ipv6Address dst, Address *hardwareAddress, uint8_t flags)
 Send a Neighbor Adverstisement.
void SendEchoReply (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr< Packet > data)
 Send a Echo Reply.
void SendNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress)
 Send a Neighbor Solicitation.
void SendErrorDestinationUnreachable (Ptr< Packet > malformedPacket, Ipv6Address dst, uint8_t code)
 Send an error Destination Unreachable.
void SendErrorTooBig (Ptr< Packet > malformedPacket, Ipv6Address dst, uint32_t mtu)
 Send an error Too Big.
void SendErrorTimeExceeded (Ptr< Packet > malformedPacket, Ipv6Address dst, uint8_t code)
 Send an error Time Exceeded.
void SendErrorParameterError (Ptr< Packet > malformedPacket, Ipv6Address dst, uint8_t code, uint32_t ptr)
 Send an error Parameter Error.
void SendRedirection (Ptr< Packet > redirectedPacket, Ipv6Address dst, Ipv6Address redirTarget, Ipv6Address redirDestination, Address redirHardwareTarget)
 Send an ICMPv6 Redirection.
Ptr< PacketForgeNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress)
 Forge a Neighbor Solicitation.
Ptr< PacketForgeNA (Ipv6Address src, Ipv6Address dst, Address *hardwareAddress, uint8_t flags)
 Forge a Neighbor Advertisement.
Ptr< PacketForgeRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress)
 Forge a Router Solicitation.
Ptr< PacketForgeEchoRequest (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr< Packet > data)
 Forge an Echo Request.
virtual enum
Ipv6L4Protocol::RxStatus_e 
Receive (Ptr< Packet > p, Ipv6Address const &src, Ipv6Address const &dst, Ptr< Ipv6Interface > interface)
 Receive method.
bool Lookup (Ipv6Address dst, Ptr< NetDevice > device, Ptr< NdiscCache > cache, Address *hardwareDestination)
 Lookup in the ND cache for the IPv6 address.
bool Lookup (Ptr< Packet > p, Ipv6Address dst, Ptr< NetDevice > device, Ptr< NdiscCache > cache, Address *hardwareDestination)
 Lookup in the ND cache for the IPv6 address (similar as ARP protocol).
void SendRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress)
 Send a Router Solicitation.
Ptr< NdiscCacheCreateCache (Ptr< NetDevice > device, Ptr< Ipv6Interface > interface)
 Create a neighbor cache.
bool IsAlwaysDad () const
 Is the node must do DAD.

Static Public Member Functions

static TypeId GetTypeId ()
 Interface ID.
static uint16_t GetStaticProtocolNumber ()
 Get ICMPv6 protocol number.
static void FunctionDadTimeout (Ptr< Icmpv6L4Protocol > icmpv6, Ipv6Interface *interface, Ipv6Address addr)
 Function called when DAD timeout.

Static Public Attributes

static const uint8_t PROT_NUMBER = 58
 ICMPv6 protocol number (58).
static const uint8_t MAX_INITIAL_RTR_ADVERT_INTERVAL = 16
 Neighbor Discovery router constants : max initial RA initial interval.
static const uint8_t MAX_INITIAL_RTR_ADVERTISEMENTS = 3
 Neighbor Discovery router constants : max initial RA transmission.
static const uint8_t MAX_FINAL_RTR_ADVERTISEMENTS = 3
 Neighbor Discovery router constants : max final RA transmission.
static const uint8_t MIN_DELAY_BETWEEN_RAS = 3
 Neighbor Discovery router constants : min delay between RA.
static const uint32_t MAX_RA_DELAY_TIME = 500
 Neighbor Discovery router constants : max delay between RA.
static const uint8_t MAX_RTR_SOLICITATION_DELAY = 1
 Neighbor Discovery host constants : max RS delay.
static const uint8_t RTR_SOLICITATION_INTERVAL = 4
 Neighbor Discovery host constants : RS interval.
static const uint8_t MAX_RTR_SOLICITATIONS = 3
 Neighbor Discovery host constants : max RS transmission.
static const uint8_t MAX_MULTICAST_SOLICIT = 3
 Neighbor Discovery node constants : max multicast solicitations.
static const uint8_t MAX_UNICAST_SOLICIT = 3
 Neighbor Discovery node constants : max unicast solicitations.
static const uint8_t MAX_ANYCAST_DELAY_TIME = 1
 Neighbor Discovery node constants : max anycast delay.
static const uint8_t MAX_NEIGHBOR_ADVERTISEMENT = 3
 Neighbor Discovery node constants : max NA transmission.
static const uint32_t REACHABLE_TIME = 30000
 Neighbor Discovery node constants : reachable time.
static const uint32_t RETRANS_TIMER = 1000
 Neighbor Discovery node constants : retransmission timer.
static const uint8_t DELAY_FIRST_PROBE_TIME = 5
 Neighbor Discovery node constants : delay for the first probe.
static const double MIN_RANDOM_FACTOR = 0.5
 Neighbor Discovery node constants : min random factor.
static const double MAX_RANDOM_FACTOR = 1.5
 Neighbor Discovery node constants : max random factor.

Protected Member Functions

virtual void DoDispose ()
 Dispose this object.

Detailed Description

An implementation of the ICMPv6 protocol.


Member Function Documentation

Create a neighbor cache.

Parameters:
devicethet NetDevice
interfacethe IPv6 interface
Returns:
a smart pointer of NdCache or 0 if problem

References ns3::NetDevice::AddLinkChangeCallback(), ns3::NdiscCache::Flush(), ns3::MakeCallback(), and ns3::NdiscCache::SetDevice().

void ns3::Icmpv6L4Protocol::DoDAD ( Ipv6Address  target,
Ptr< Ipv6Interface interface 
)

Do the Duplication Address Detection (DAD). It consists in sending a NS with our IPv6 as target. If we received a NA with matched target address, we could not use the address, else the address pass from TENTATIVE to PERMANENT.

Parameters:
targettarget address
interfaceinterface

References ForgeNS(), ns3::NetDevice::GetAddress(), ns3::Ipv6Interface::GetDevice(), ns3::Object::GetObject(), ns3::Packet::GetUid(), ns3::Ipv6Address::MakeSolicitedAddress(), NS_ASSERT, NS_LOG_FUNCTION, ns3::Ipv6Interface::Send(), and ns3::Ipv6Interface::SetNsDadUid().

Referenced by ns3::Ipv6Interface::AddAddress().

Ptr< Packet > ns3::Icmpv6L4Protocol::ForgeEchoRequest ( Ipv6Address  src,
Ipv6Address  dst,
uint16_t  id,
uint16_t  seq,
Ptr< Packet data 
)

Forge an Echo Request.

Parameters:
srcsource address
dstdestination address
idID of the packet
seqsequence number
datathe data
Returns:
Echo Request packet (without IPv6 header)

References ns3::Packet::AddHeader(), ns3::Packet::Copy(), NS_LOG_FUNCTION, ns3::Icmpv6Echo::SetId(), and ns3::Icmpv6Echo::SetSeq().

Ptr< Packet > ns3::Icmpv6L4Protocol::ForgeNA ( Ipv6Address  src,
Ipv6Address  dst,
Address hardwareAddress,
uint8_t  flags 
)

Forge a Neighbor Advertisement.

Parameters:
srcsource IPv6 address
dstdestination IPv6 address
hardwareAddressour mac address
flagsflags (bitfield => R (4), S (2), O (1))
Returns:
NA packet (with IPv6 header)

References ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Ipv6Address::GetAny(), ns3::Icmpv6NA::GetSerializedSize(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, ns3::Icmpv6NA::SetFlagO(), ns3::Icmpv6NA::SetFlagR(), ns3::Icmpv6NA::SetFlagS(), and ns3::Icmpv6NA::SetIpv6Target().

Ptr< Packet > ns3::Icmpv6L4Protocol::ForgeNS ( Ipv6Address  src,
Ipv6Address  dst,
Ipv6Address  target,
Address  hardwareAddress 
)

Forge a Neighbor Solicitation.

Parameters:
srcsource IPv6 address
dstdestination IPv6 address
targettarget IPv6 address
hardwareAddressour mac address
Returns:
NS packet (with IPv6 header)

References ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::Ipv6Address::GetAny(), ns3::Icmpv6NS::GetSerializedSize(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and PROT_NUMBER.

Referenced by DoDAD().

Ptr< Packet > ns3::Icmpv6L4Protocol::ForgeRS ( Ipv6Address  src,
Ipv6Address  dst,
Address  hardwareAddress 
)

Forge a Router Solicitation.

Parameters:
srcsource IPv6 address
dstdestination IPv6 address
hardwareAddressour mac address
Returns:
RS packet (with IPv6 header)

References ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Icmpv6RS::GetSerializedSize(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and PROT_NUMBER.

int ns3::Icmpv6L4Protocol::GetProtocolNumber ( void  ) const [virtual]

Get the protocol number.

Returns:
protocol number

Implements ns3::Ipv6L4Protocol.

References NS_LOG_FUNCTION_NOARGS, and PROT_NUMBER.

uint16_t ns3::Icmpv6L4Protocol::GetStaticProtocolNumber ( void  ) [static]

Get ICMPv6 protocol number.

Returns:
protocol number

References NS_LOG_FUNCTION_NOARGS, and PROT_NUMBER.

Referenced by ns3::Ipv6RawSocketImpl::ForwardUp(), ns3::Ipv6L3Protocol::GetIcmpv6(), and ns3::Ipv6RawSocketImpl::SendTo().

Interface ID.

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

This object is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/DeviceList/[i]/$ns3::AlohaNoackNetDevice/Phy/$ns3::Icmpv6L4Protocol
  • /NodeList/[i]/DeviceList/[i]/$ns3::AlohaNoackNetDevice/Phy/$ns3::Ipv6L4Protocol/$ns3::Icmpv6L4Protocol
  • /NodeList/[i]/DeviceList/[i]/$ns3::NonCommunicatingNetDevice/Phy/$ns3::Icmpv6L4Protocol
  • /NodeList/[i]/DeviceList/[i]/$ns3::NonCommunicatingNetDevice/Phy/$ns3::Ipv6L4Protocol/$ns3::Icmpv6L4Protocol

Attributes defined for this type:

  • DAD: Always do DAD check.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: true
    • Flags: construct write read

Attributes defined in parent class ns3::Ipv6L4Protocol:

  • ProtocolNumber: The IPv6 protocol number.

No TraceSources defined for this type.

Reimplemented from ns3::Ipv6L4Protocol.

References ns3::TypeId::SetParent().

int ns3::Icmpv6L4Protocol::GetVersion ( ) const [virtual]

Get the version of the protocol.

Returns:
version

References NS_LOG_FUNCTION_NOARGS.

Is the node must do DAD.

Returns:
true if node has to do DAD.
bool ns3::Icmpv6L4Protocol::Lookup ( Ipv6Address  dst,
Ptr< NetDevice device,
Ptr< NdiscCache cache,
Address hardwareDestination 
)

Lookup in the ND cache for the IPv6 address.

Parameters:
dstdestination address
devicedevice
cachethe neighbor cache
hardwareDestinationhardware address
Note:
Unlike other Lookup method, it does not send NS request!

References ns3::NdiscCache::Lookup(), and NS_LOG_FUNCTION.

enum Ipv6L4Protocol::RxStatus_e ns3::Icmpv6L4Protocol::Receive ( Ptr< Packet p,
Ipv6Address const &  src,
Ipv6Address const &  dst,
Ptr< Ipv6Interface interface 
) [virtual]

Receive method.

Parameters:
pthe packet
srcsource address
dstdestination address
interfacethe interface from which the packet is coming

Implements ns3::Ipv6L4Protocol.

References ns3::Packet::Copy(), ns3::Packet::CopyData(), ns3::Ipv6Interface::GetDevice(), ns3::Ipv6::GetInterfaceForDevice(), ns3::Object::GetObject(), ns3::Ipv6::IsForwarding(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Ipv6L4Protocol::RX_OK.

void ns3::Icmpv6L4Protocol::SendEchoReply ( Ipv6Address  src,
Ipv6Address  dst,
uint16_t  id,
uint16_t  seq,
Ptr< Packet data 
)

Send a Echo Reply.

Parameters:
srcsource IPv6 address
dstdestination IPv6 address
idid of the packet
seqsequence number
dataauxiliary data

References ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Packet::Copy(), ns3::Icmpv6Echo::GetSerializedSize(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, PROT_NUMBER, SendMessage(), ns3::Icmpv6Echo::SetId(), and ns3::Icmpv6Echo::SetSeq().

void ns3::Icmpv6L4Protocol::SendErrorDestinationUnreachable ( Ptr< Packet malformedPacket,
Ipv6Address  dst,
uint8_t  code 
)

Send an error Destination Unreachable.

Parameters:
malformedPacketthe malformed packet
dstdestination IPv6 address
codecode of the error

References ns3::Packet::CreateFragment(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, SendMessage(), ns3::Icmpv6Header::SetCode(), and ns3::Icmpv6DestinationUnreachable::SetPacket().

void ns3::Icmpv6L4Protocol::SendErrorParameterError ( Ptr< Packet malformedPacket,
Ipv6Address  dst,
uint8_t  code,
uint32_t  ptr 
)

Send an error Parameter Error.

Parameters:
malformedPacketthe malformed packet
dstdestination IPv6 address
codecode of the error
ptrbyte of p where the error is located

References ns3::Packet::CreateFragment(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, SendMessage(), ns3::Icmpv6Header::SetCode(), ns3::Icmpv6ParameterError::SetPacket(), and ns3::Icmpv6ParameterError::SetPtr().

void ns3::Icmpv6L4Protocol::SendErrorTimeExceeded ( Ptr< Packet malformedPacket,
Ipv6Address  dst,
uint8_t  code 
)

Send an error Time Exceeded.

Parameters:
malformedPacketthe malformed packet
dstdestination IPv6 address
codecode of the error

References ns3::Packet::CreateFragment(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, SendMessage(), ns3::Icmpv6Header::SetCode(), and ns3::Icmpv6TimeExceeded::SetPacket().

void ns3::Icmpv6L4Protocol::SendErrorTooBig ( Ptr< Packet malformedPacket,
Ipv6Address  dst,
uint32_t  mtu 
)

Send an error Too Big.

Parameters:
malformedPacketthe malformed packet
dstdestination IPv6 address
mtuthe mtu

References ns3::Packet::CreateFragment(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, SendMessage(), ns3::Icmpv6Header::SetCode(), ns3::Icmpv6TooBig::SetMtu(), and ns3::Icmpv6TooBig::SetPacket().

void ns3::Icmpv6L4Protocol::SendMessage ( Ptr< Packet packet,
Ipv6Address  src,
Ipv6Address  dst,
uint8_t  ttl 
)

Send a packet via ICMPv6, note that packet already contains ICMPv6 header.

Parameters:
packetthe packet to send which contains ICMPv6 header
srcsource address
dstdestination address
ttlnext hop limit

References ns3::Packet::AddPacketTag(), ns3::Object::GetObject(), NS_ASSERT, NS_LOG_FUNCTION, and PROT_NUMBER.

Referenced by SendEchoReply(), SendErrorDestinationUnreachable(), SendErrorParameterError(), SendErrorTimeExceeded(), SendErrorTooBig(), SendNA(), SendNS(), SendRedirection(), and SendRS().

void ns3::Icmpv6L4Protocol::SendMessage ( Ptr< Packet packet,
Ipv6Address  dst,
Icmpv6Header icmpv6Hdr,
uint8_t  ttl 
)

Send a packet via ICMPv6.

Parameters:
packetthe packet to send
dstdestination address
icmpv6HdrICMPv6 header (needed to calculate checksum after source address is determined by routing stuff
ttlnext hop limit

References ns3::Packet::AddHeader(), ns3::Packet::AddPacketTag(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Object::GetObject(), ns3::Icmpv6Header::GetSerializedSize(), ns3::Packet::GetSize(), NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, NS_LOG_WARN, and PROT_NUMBER.

void ns3::Icmpv6L4Protocol::SendNA ( Ipv6Address  src,
Ipv6Address  dst,
Address hardwareAddress,
uint8_t  flags 
)

Send a Neighbor Adverstisement.

Parameters:
srcsource IPv6 address
dstdestination IPv6 address
hardwareAddressour MAC address
flagsto set (4 = flag R, 2 = flag S, 3 = flag O)

References ns3::Packet::AddHeader(), ns3::Ipv6Address::GetAny(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and SendMessage().

void ns3::Icmpv6L4Protocol::SendNS ( Ipv6Address  src,
Ipv6Address  dst,
Ipv6Address  target,
Address  hardwareAddress 
)

Send a Neighbor Solicitation.

Parameters:
srcsource IPv6 address
dstdestination IPv6 address
targettarget IPv6 address
hardwareAddressour mac address

References ns3::Packet::AddHeader(), ns3::Ipv6Address::GetAllNodesMulticast(), ns3::Ipv6Address::GetAny(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and SendMessage().

Referenced by Lookup().

void ns3::Icmpv6L4Protocol::SendRedirection ( Ptr< Packet redirectedPacket,
Ipv6Address  dst,
Ipv6Address  redirTarget,
Ipv6Address  redirDestination,
Address  redirHardwareTarget 
)

Send an ICMPv6 Redirection.

Parameters:
redirectedPacketthe redirected packet
dstdestination IPv6 address
redirTargetIPv6 target address for Icmpv6Redirection
redirDestinationIPv6 destination address for Icmpv6Redirection
redirHardwareTargetL2 target address for Icmpv6OptionRdirected

References ns3::Packet::AddAtEnd(), ns3::Packet::AddHeader(), ns3::Packet::CreateFragment(), ns3::Address::GetLength(), ns3::Icmpv6OptionLinkLayerAddress::GetSerializedSize(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, SendMessage(), ns3::Icmpv6OptionLinkLayerAddress::SetAddress(), ns3::Icmpv6Redirection::SetDestination(), ns3::Icmpv6OptionRedirected::SetPacket(), and ns3::Icmpv6Redirection::SetTarget().

void ns3::Icmpv6L4Protocol::SendRS ( Ipv6Address  src,
Ipv6Address  dst,
Address  hardwareAddress 
)

Send a Router Solicitation.

Parameters:
srclink-local source address
dstdestination address (usealy ff02::2 i.e all-routers)
hardwareAddresslink-layer address (SHOULD be included if src is not ::

References ns3::Packet::AddHeader(), ns3::Ipv6Address::GetAny(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, NS_LOG_LOGIC, PROT_NUMBER, and SendMessage().

Referenced by FunctionDadTimeout().

Set the node.

Parameters:
nodethe node to set

References NS_LOG_FUNCTION.

Referenced by NotifyNewAggregate().


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