ns-3
ns3::Ipv6RawSocketImpl Class Reference

IPv6 raw socket. More...

#include <ipv6-raw-socket-impl.h>

Inheritance diagram for ns3::Ipv6RawSocketImpl:
Collaboration diagram for ns3::Ipv6RawSocketImpl:

List of all members.

Classes

struct  Data
 IPv6 raw data and additionnal information.

Public Member Functions

 Ipv6RawSocketImpl ()
 Constructor.
virtual ~Ipv6RawSocketImpl ()
 Destructor.
void SetNode (Ptr< Node > node)
 Set the node.
virtual enum Socket::SocketErrno GetErrno () const
 Get last error number.
virtual enum Socket::SocketType GetSocketType () const
 Get socket type (NS3_SOCK_RAW)
virtual Ptr< NodeGetNode () const
 Get node.
virtual int Bind (const Address &address)
 Bind the socket to address.
virtual int Bind ()
 Bind socket.
virtual int GetSockName (Address &address) const
 Get socket address.
virtual int Close ()
 Close the socket.
virtual int ShutdownSend ()
 Shutdown send capability.
virtual int ShutdownRecv ()
 Shutdown receive capability.
virtual int Connect (const Address &address)
 Connect to address.
virtual int Listen ()
 Listen.
virtual uint32_t GetTxAvailable () const
 Get TX size available.
virtual uint32_t GetRxAvailable () const
 Get RX size available.
virtual int Send (Ptr< Packet > p, uint32_t flags)
 Send a packet.
virtual int SendTo (Ptr< Packet > p, uint32_t flags, const Address &toAddress)
 Send a packet.
virtual Ptr< PacketRecv (uint32_t maxSize, uint32_t flags)
 Receive packet.
virtual Ptr< PacketRecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)
 Receive packet.
void SetProtocol (uint16_t protocol)
 Set protocol field.
bool ForwardUp (Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device)
 Forward up to receive method.
virtual bool SetAllowBroadcast (bool allowBroadcast)
 Configure whether broadcast datagram transmissions are allowed.
virtual bool GetAllowBroadcast () const
 Query whether broadcast datagram transmissions are allowed.

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID of this class.

Detailed Description

IPv6 raw socket.

A RAW Socket typically is used to access specific IP layers not usually available through L4 sockets, e.g., ICMP. The implementer should take particular care to define the Ipv6RawSocketImpl Attributes, and in particular the Protocol attribute. Not setting it will result in a zero protocol at IP level (corresponding to the HopByHop IPv6 Extension header, i.e., Ipv6ExtensionHopByHopHeader) when sending data through the socket, which is probably not the intended behavior.

A correct example is (from src/applications/model/radvd.cc):

   if (!m_socket)
     {
       TypeId tid = TypeId::LookupByName ("ns3::Ipv6RawSocketFactory");
       m_socket = Socket::CreateSocket (GetNode (), tid);

       NS_ASSERT (m_socket);

       m_socket->SetAttribute ("Protocol", UintegerValue(Ipv6Header::IPV6_ICMPV6));
       m_socket->SetRecvCallback (MakeCallback (&Radvd::HandleRead, this));
     }

Member Function Documentation

int ns3::Ipv6RawSocketImpl::Bind ( const Address address) [virtual]

Bind the socket to address.

Parameters:
addressbind to this address
Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), and NS_LOG_FUNCTION.

int ns3::Ipv6RawSocketImpl::Bind ( void  ) [virtual]

Bind socket.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References ns3::Ipv6Address::GetAny(), and NS_LOG_FUNCTION_NOARGS.

int ns3::Ipv6RawSocketImpl::Close ( void  ) [virtual]

Close the socket.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References ns3::Object::GetObject(), and NS_LOG_FUNCTION_NOARGS.

int ns3::Ipv6RawSocketImpl::Connect ( const Address address) [virtual]

Connect to address.

Parameters:
addressaddress
Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References ns3::Inet6SocketAddress::ConvertFrom(), ns3::Inet6SocketAddress::GetIpv6(), ns3::Inet6SocketAddress::IsMatchingType(), and NS_LOG_FUNCTION.

Query whether broadcast datagram transmissions are allowed.

This method corresponds to using getsockopt() SO_BROADCAST of real network or BSD sockets.

Returns:
true if broadcast is allowed, false otherwise

Implements ns3::Socket.

enum Socket::SocketErrno ns3::Ipv6RawSocketImpl::GetErrno ( void  ) const [virtual]

Get last error number.

Returns:
error number

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

Ptr< Node > ns3::Ipv6RawSocketImpl::GetNode ( void  ) const [virtual]

Get node.

Returns:
node associated with this raw socket.

Implements ns3::Socket.

uint32_t ns3::Ipv6RawSocketImpl::GetRxAvailable ( void  ) const [virtual]

Get RX size available.

Returns:
RX size

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

enum Socket::SocketType ns3::Ipv6RawSocketImpl::GetSocketType ( void  ) const [virtual]

Get socket type (NS3_SOCK_RAW)

Returns:
socket type

Implements ns3::Socket.

int ns3::Ipv6RawSocketImpl::GetSockName ( Address address) const [virtual]

Get socket address.

Parameters:
addresssocket address if method success
Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

uint32_t ns3::Ipv6RawSocketImpl::GetTxAvailable ( void  ) const [virtual]

Get TX size available.

Returns:
TX size

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

Get the type ID of this class.

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

Returns:
type ID

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

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

Attributes defined for this type:

  • Protocol: Protocol number to match.
  • IcmpFilter: Any ICMPv6 header whose type field matches a bit in this filter is dropped.

No TraceSources defined for this type.

Reimplemented from ns3::Object.

References ns3::TypeId::SetParent().

int ns3::Ipv6RawSocketImpl::Listen ( void  ) [virtual]

Listen.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

Ptr< Packet > ns3::Ipv6RawSocketImpl::Recv ( uint32_t  maxSize,
uint32_t  flags 
) [virtual]

Receive packet.

Parameters:
maxSizemaximum size
flagsadditionnal flags
Returns:
packet received

Implements ns3::Socket.

References NS_LOG_FUNCTION, and RecvFrom().

Ptr< Packet > ns3::Ipv6RawSocketImpl::RecvFrom ( uint32_t  maxSize,
uint32_t  flags,
Address fromAddress 
) [virtual]

Receive packet.

Parameters:
maxSizemaximum size
flagsadditionnal flags
fromAddresssource address
Returns:
packet received

Implements ns3::Socket.

References ns3::Packet::CreateFragment(), NS_LOG_FUNCTION, and ns3::Packet::RemoveAtStart().

Referenced by Recv().

int ns3::Ipv6RawSocketImpl::Send ( Ptr< Packet p,
uint32_t  flags 
) [virtual]

Send a packet.

Parameters:
ppacket to send
flagsadditionnal flags
Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References NS_LOG_FUNCTION, and SendTo().

bool ns3::Ipv6RawSocketImpl::SetAllowBroadcast ( bool  allowBroadcast) [virtual]

Configure whether broadcast datagram transmissions are allowed.

This method corresponds to using setsockopt() SO_BROADCAST of real network or BSD sockets. If set on a socket, this option will enable or disable packets to be transmitted to broadcast destination addresses.

Parameters:
allowBroadcastWhether broadcast is allowed
Returns:
true if operation succeeds

Implements ns3::Socket.

Set the node.

Parameters:
nodenode to set

References NS_LOG_FUNCTION.

void ns3::Ipv6RawSocketImpl::SetProtocol ( uint16_t  protocol)

Set protocol field.

Parameters:
protocolprotocol to set
int ns3::Ipv6RawSocketImpl::ShutdownRecv ( void  ) [virtual]

Shutdown receive capability.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.

int ns3::Ipv6RawSocketImpl::ShutdownSend ( void  ) [virtual]

Shutdown send capability.

Returns:
0 if success, -1 otherwise

Implements ns3::Socket.

References NS_LOG_FUNCTION_NOARGS.


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