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