A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ip-l4-protocol.cc
Go to the documentation of this file.
1
//
2
// Copyright (c) 2006 Georgia Tech Research Corporation
3
//
4
// SPDX-License-Identifier: GPL-2.0-only
5
//
6
// Author: George F. Riley<riley@ece.gatech.edu>
7
//
8
9
// NS3 - Layer 4 Protocol base class
10
// George F. Riley, Georgia Tech, Spring 2007
11
12
#include "
ip-l4-protocol.h
"
13
14
#include "ns3/integer.h"
15
#include "ns3/log.h"
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"IpL4Protocol"
);
21
22
NS_OBJECT_ENSURE_REGISTERED
(IpL4Protocol);
23
24
TypeId
25
IpL4Protocol::GetTypeId
()
26
{
27
static
TypeId
tid =
TypeId
(
"ns3::IpL4Protocol"
)
28
.
SetParent
<
Object
>()
29
.SetGroupName(
"Internet"
)
30
.AddAttribute(
"ProtocolNumber"
,
31
"The IP protocol number."
,
32
TypeId::ATTR_GET
,
33
IntegerValue
(0),
34
MakeIntegerAccessor
(&
IpL4Protocol::GetProtocolNumber
),
35
MakeIntegerChecker<int>
(0, 255));
36
return
tid;
37
}
38
39
IpL4Protocol::~IpL4Protocol
()
40
{
41
NS_LOG_FUNCTION
(
this
);
42
}
43
44
void
45
IpL4Protocol::ReceiveIcmp
(
Ipv4Address
icmpSource,
46
uint8_t icmpTtl,
47
uint8_t icmpType,
48
uint8_t icmpCode,
49
uint32_t
icmpInfo,
50
Ipv4Address
payloadSource,
51
Ipv4Address
payloadDestination,
52
const
uint8_t payload[8])
53
{
54
NS_LOG_FUNCTION
(
this
<< icmpSource <<
static_cast<
uint32_t
>
(icmpTtl)
55
<<
static_cast<
uint32_t
>
(icmpType) <<
static_cast<
uint32_t
>
(icmpCode)
56
<< icmpInfo << payloadSource << payloadDestination << payload);
57
}
58
59
void
60
IpL4Protocol::ReceiveIcmp
(
Ipv6Address
icmpSource,
61
uint8_t icmpTtl,
62
uint8_t icmpType,
63
uint8_t icmpCode,
64
uint32_t
icmpInfo,
65
Ipv6Address
payloadSource,
66
Ipv6Address
payloadDestination,
67
const
uint8_t payload[8])
68
{
69
NS_LOG_FUNCTION
(
this
<< icmpSource <<
static_cast<
uint32_t
>
(icmpTtl)
70
<<
static_cast<
uint32_t
>
(icmpType) <<
static_cast<
uint32_t
>
(icmpCode)
71
<< icmpInfo << payloadSource << payloadDestination << payload);
72
}
73
74
}
// namespace ns3
ns3::IntegerValue
Hold a signed integer type.
Definition
integer.h:34
ns3::IpL4Protocol::ReceiveIcmp
virtual void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, Ipv4Address payloadSource, Ipv4Address payloadDestination, const uint8_t payload[8])
Called from lower-level layers to send the ICMP packet up in the stack.
Definition
ip-l4-protocol.cc:45
ns3::IpL4Protocol::~IpL4Protocol
~IpL4Protocol() override
Definition
ip-l4-protocol.cc:39
ns3::IpL4Protocol::GetProtocolNumber
virtual int GetProtocolNumber() const =0
Returns the protocol number of this protocol.
ns3::IpL4Protocol::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ip-l4-protocol.cc:25
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv6Address
Describes an IPv6 address.
Definition
ipv6-address.h:38
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::ATTR_GET
@ ATTR_GET
The attribute can be read.
Definition
type-id.h:53
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ip-l4-protocol.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeIntegerChecker
Ptr< const AttributeChecker > MakeIntegerChecker()
Definition
integer.h:99
ns3::MakeIntegerAccessor
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Definition
integer.h:35
src
internet
model
ip-l4-protocol.cc
Generated on Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0