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