|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
25 #include "ns3/assert.h"
28 #include "ns3/packet.h"
29 #include "ns3/boolean.h"
30 #include "ns3/ipv4-route.h"
31 #include "ns3/ipv6-interface.h"
47 .SetGroupName (
"Internet")
82 Ptr<Node> node = this->GetObject<Node> ();
85 Ptr<Ipv4> ipv4 = this->GetObject<Ipv4> ();
91 ipv4->AggregateObject (rawFactory);
115 NS_LOG_FUNCTION (
this << packet << dest <<
static_cast<uint32_t
> (type) <<
static_cast<uint32_t
> (code));
117 NS_ASSERT (ipv4 != 0 && ipv4->GetRoutingProtocol () != 0);
124 route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
129 SendMessage (packet, source, dest, type, code, route);
140 NS_LOG_FUNCTION (
this << packet << source << dest <<
static_cast<uint32_t
> (type) <<
static_cast<uint32_t
> (code) << route);
169 uint8_t code, uint16_t nextHopMtu)
171 NS_LOG_FUNCTION (
this << header << *orgData << (uint32_t) code << nextHopMtu);
217 const uint8_t payload[8])
219 NS_LOG_FUNCTION (
this << source << icmp << info << ipHeader << payload);
258 Forward (source, icmp, 0, ipHeader, payload);
288 Ipv6Header
const &header,
289 Ptr<Ipv6Interface> incomingInterface)
291 NS_LOG_FUNCTION (
this << p << header.GetSource () << header.GetDestination () << incomingInterface);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
void SendDestUnreachPort(Ipv4Header header, Ptr< const Packet > orgData)
Send a Time Exceeded ICMP error.
virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
ICMP Time Exceeded header.
void AddHeader(const Header &header)
Add header to this packet.
SocketErrno
Enumeration of the possible errors returned by a socket.
void SetNode(Ptr< Node > node)
Set the node the protocol is associated with.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsNull(void) const
Check for null implementation.
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Receive method.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void HandleEcho(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Echo packet.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
void SendDestUnreachFragNeeded(Ipv4Header header, Ptr< const Packet > orgData, uint16_t nextHopMtu)
Send a Destination Unreachable - Fragmentation needed ICMP error.
Ipv4 addresses are stored in host order in this class.
virtual void DoDispose(void)
Destructor implementation.
@ ICMPV4_FRAGMENT_REASSEMBLY
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual int GetProtocolNumber(void) const
Get the protocol number.
Access to the IPv4 forwarding table, interfaces, and configuration.
This is the implementation of the ICMP protocol as described in RFC 792.
static const uint8_t PROT_NUMBER
ICMP protocol number (0x1)
void SendTimeExceededTtl(Ipv4Header header, Ptr< const Packet > orgData, bool isFragment)
Send a Time Exceeded ICMP error.
void SetHeader(Ipv4Header header)
Set the ICMP carried IPv4 header.
ICMP Destination Unreachable header.
Ipv4Header GetHeader(void) const
Get the ICMP carried IPv4 header.
Ipv4Header GetHeader(void) const
Get the ICMP carried IPv4 header.
static uint16_t GetStaticProtocolNumber(void)
Get the protocol number.
void HandleDestUnreach(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Destination Unreachable packet.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
virtual ~Icmpv4L4Protocol()
static bool ChecksumEnabled(void)
void GetData(uint8_t payload[8]) const
Get the ICMP carried data.
static TypeId GetTypeId(void)
Get the type ID.
uint16_t GetNextHopMtu(void) const
Get the next hop MTU.
Ptr< Node > m_node
the node this protocol is associated with
L4 Protocol abstract base class.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
void Forward(Ipv4Address source, Icmpv4Header icmp, uint32_t info, Ipv4Header ipHeader, const uint8_t payload[8])
Forward the message to an L4 protocol.
IpL4Protocol::DownTargetCallback m_downTarget
callback to Ipv4::Send
void GetData(uint8_t payload[8]) const
Get the ICMP carried data.
@ ICMPV4_PORT_UNREACHABLE
void SetHeader(Ipv4Header header)
Set the ICMP carried IPv4 header.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void SendDestUnreach(Ipv4Header header, Ptr< const Packet > orgData, uint8_t code, uint16_t nextHopMtu)
Send an ICMP Destination Unreachable packet.
void SetData(Ptr< const Packet > data)
Set the ICMP carried data.
virtual IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
virtual void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)=0
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
void SendMessage(Ptr< Packet > packet, Ipv4Address dest, uint8_t type, uint8_t code)
Send a generic ICMP packet.
void SetData(Ptr< const Packet > data)
Get the ICMP carried data.
virtual void SetDownTarget(IpL4Protocol::DownTargetCallback cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
void HandleTimeExceeded(Ptr< Packet > p, Icmpv4Header icmp, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Time Exceeded packet.
virtual void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
virtual void DoDispose(void)
Destructor implementation.
void Nullify(void)
Discard the implementation, set it to null.
void SetNextHopMtu(uint16_t mtu)
Set the next hop MTU.