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);
bool IsNull(void) const
Check for null implementation.
void Nullify(void)
Discard the implementation, set it to null.
ICMP Destination Unreachable header.
void GetData(uint8_t payload[8]) const
Get the ICMP carried data.
Ipv4Header GetHeader(void) const
Get the ICMP carried IPv4 header.
void SetNextHopMtu(uint16_t mtu)
Set the next hop MTU.
uint16_t GetNextHopMtu(void) const
Get the next hop MTU.
void SetHeader(Ipv4Header header)
Set the ICMP carried IPv4 header.
void SetData(Ptr< const Packet > data)
Set the ICMP carried data.
@ ICMPV4_PORT_UNREACHABLE
This is the implementation of the ICMP protocol as described in RFC 792.
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...
virtual ~Icmpv4L4Protocol()
Ptr< Node > m_node
the node this protocol is associated with
void SendTimeExceededTtl(Ipv4Header header, Ptr< const Packet > orgData, bool isFragment)
Send a Time Exceeded ICMP error.
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Receive method.
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...
static const uint8_t PROT_NUMBER
ICMP protocol number (0x1)
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
virtual int GetProtocolNumber(void) const
Get the protocol number.
void SendDestUnreach(Ipv4Header header, Ptr< const Packet > orgData, uint8_t code, uint16_t nextHopMtu)
Send an ICMP Destination Unreachable packet.
void SetNode(Ptr< Node > node)
Set the node the protocol is associated with.
static uint16_t GetStaticProtocolNumber(void)
Get the protocol number.
void SendDestUnreachPort(Ipv4Header header, Ptr< const Packet > orgData)
Send a Time Exceeded ICMP error.
void HandleEcho(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Echo packet.
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...
static TypeId GetTypeId(void)
Get the type ID.
void HandleTimeExceeded(Ptr< Packet > p, Icmpv4Header icmp, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Time Exceeded packet.
IpL4Protocol::DownTargetCallback m_downTarget
callback to Ipv4::Send
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 SendDestUnreachFragNeeded(Ipv4Header header, Ptr< const Packet > orgData, uint16_t nextHopMtu)
Send a Destination Unreachable - Fragmentation needed ICMP error.
void SendMessage(Ptr< Packet > packet, Ipv4Address dest, uint8_t type, uint8_t code)
Send a generic ICMP packet.
void HandleDestUnreach(Ptr< Packet > p, Icmpv4Header header, Ipv4Address source, Ipv4Address destination)
Handles an incoming ICMP Destination Unreachable packet.
virtual void DoDispose(void)
Destructor implementation.
void Forward(Ipv4Address source, Icmpv4Header icmp, uint32_t info, Ipv4Header ipHeader, const uint8_t payload[8])
Forward the message to an L4 protocol.
ICMP Time Exceeded header.
Ipv4Header GetHeader(void) const
Get the ICMP carried IPv4 header.
void SetHeader(Ipv4Header header)
Set the ICMP carried IPv4 header.
void GetData(uint8_t payload[8]) const
Get the ICMP carried data.
@ ICMPV4_FRAGMENT_REASSEMBLY
void SetData(Ptr< const Packet > data)
Get the ICMP carried data.
L4 Protocol abstract base class.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)=0
static bool ChecksumEnabled(void)
virtual void DoDispose(void)
Destructor implementation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
SocketErrno
Enumeration of the possible errors returned by a socket.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...