A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
ip-l4-protocol.cc
Go to the documentation of this file.
1
//
2
// Copyright (c) 2006 Georgia Tech Research Corporation
3
//
4
// This program is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License version 2 as
6
// published by the Free Software Foundation;
7
//
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
//
17
// Author: George F. Riley<riley@ece.gatech.edu>
18
//
19
20
// NS3 - Layer 4 Protocol base class
21
// George F. Riley, Georgia Tech, Spring 2007
22
23
#include "
ip-l4-protocol.h
"
24
25
#include "ns3/integer.h"
26
#include "ns3/log.h"
27
28
namespace
ns3
29
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"IpL4Protocol"
);
32
33
NS_OBJECT_ENSURE_REGISTERED
(IpL4Protocol);
34
35
TypeId
36
IpL4Protocol::GetTypeId
()
37
{
38
static
TypeId
tid =
TypeId
(
"ns3::IpL4Protocol"
)
39
.
SetParent
<
Object
>()
40
.SetGroupName(
"Internet"
)
41
.AddAttribute(
"ProtocolNumber"
,
42
"The IP protocol number."
,
43
TypeId::ATTR_GET
,
44
IntegerValue
(0),
45
MakeIntegerAccessor
(&
IpL4Protocol::GetProtocolNumber
),
46
MakeIntegerChecker<int>(0, 255));
47
return
tid;
48
}
49
50
IpL4Protocol::~IpL4Protocol
()
51
{
52
NS_LOG_FUNCTION
(
this
);
53
}
54
55
void
56
IpL4Protocol::ReceiveIcmp
(
Ipv4Address
icmpSource,
57
uint8_t icmpTtl,
58
uint8_t icmpType,
59
uint8_t icmpCode,
60
uint32_t icmpInfo,
61
Ipv4Address
payloadSource,
62
Ipv4Address
payloadDestination,
63
const
uint8_t payload[8])
64
{
65
NS_LOG_FUNCTION
(
this
<< icmpSource <<
static_cast<
uint32_t
>
(icmpTtl)
66
<<
static_cast<
uint32_t
>
(icmpType) <<
static_cast<
uint32_t
>
(icmpCode)
67
<< icmpInfo << payloadSource << payloadDestination << payload);
68
}
69
70
void
71
IpL4Protocol::ReceiveIcmp
(
Ipv6Address
icmpSource,
72
uint8_t icmpTtl,
73
uint8_t icmpType,
74
uint8_t icmpCode,
75
uint32_t icmpInfo,
76
Ipv6Address
payloadSource,
77
Ipv6Address
payloadDestination,
78
const
uint8_t payload[8])
79
{
80
NS_LOG_FUNCTION
(
this
<< icmpSource <<
static_cast<
uint32_t
>
(icmpTtl)
81
<<
static_cast<
uint32_t
>
(icmpType) <<
static_cast<
uint32_t
>
(icmpCode)
82
<< icmpInfo << payloadSource << payloadDestination << payload);
83
}
84
85
}
// namespace ns3
ns3::IntegerValue
Hold a signed integer type.
Definition:
integer.h:45
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:56
ns3::IpL4Protocol::~IpL4Protocol
~IpL4Protocol() override
Definition:
ip-l4-protocol.cc:50
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:36
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:49
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::ATTR_GET
@ ATTR_GET
The attribute can be read.
Definition:
type-id.h:64
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:240
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ip-l4-protocol.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeIntegerAccessor
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Definition:
integer.h:46
src
internet
model
ip-l4-protocol.cc
Generated on Sun Mar 3 2024 17:10:58 for ns-3 by
1.9.1