A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ipv4-queue-disc-item.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2016 Universita' degli Studi di Napoli Federico II
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
19
#include "ns3/log.h"
20
#include "
ipv4-queue-disc-item.h
"
21
22
namespace
ns3
{
23
24
NS_LOG_COMPONENT_DEFINE
(
"Ipv4QueueDiscItem"
);
25
26
Ipv4QueueDiscItem::Ipv4QueueDiscItem
(
Ptr<Packet>
p,
const
Address
& addr,
27
uint16_t protocol,
const
Ipv4Header
& header)
28
:
QueueDiscItem
(p, addr, protocol),
29
m_header (header),
30
m_headerAdded (false)
31
{
32
}
33
34
Ipv4QueueDiscItem::~Ipv4QueueDiscItem
()
35
{
36
NS_LOG_FUNCTION
(
this
);
37
}
38
39
uint32_t
Ipv4QueueDiscItem::GetSize
(
void
)
const
40
{
41
NS_LOG_FUNCTION
(
this
);
42
Ptr<Packet>
p =
GetPacket
();
43
NS_ASSERT
(p != 0);
44
uint32_t ret = p->
GetSize
();
45
if
(!
m_headerAdded
)
46
{
47
ret +=
m_header
.
GetSerializedSize
();
48
}
49
return
ret;
50
}
51
52
const
Ipv4Header
&
53
Ipv4QueueDiscItem::GetHeader
(
void
)
const
54
{
55
return
m_header
;
56
}
57
58
void
Ipv4QueueDiscItem::AddHeader
(
void
)
59
{
60
NS_LOG_FUNCTION
(
this
);
61
62
NS_ASSERT_MSG
(!
m_headerAdded
,
"The header has been already added to the packet"
);
63
Ptr<Packet>
p =
GetPacket
();
64
NS_ASSERT
(p != 0);
65
p->
AddHeader
(
m_header
);
66
m_headerAdded
=
true
;
67
}
68
69
void
70
Ipv4QueueDiscItem::Print
(std::ostream& os)
const
71
{
72
if
(!
m_headerAdded
)
73
{
74
os <<
m_header
<<
" "
;
75
}
76
os <<
GetPacket
() <<
" "
77
<<
"Dst addr "
<<
GetAddress
() <<
" "
78
<<
"proto "
<< (uint16_t)
GetProtocol
() <<
" "
79
<<
"txq "
<< (uint8_t)
GetTxQueueIndex
()
80
;
81
}
82
83
bool
84
Ipv4QueueDiscItem::Mark
(
void
)
85
{
86
NS_LOG_FUNCTION
(
this
);
87
if
(!
m_headerAdded
&& (
m_header
.
GetEcn
() ==
Ipv4Header::ECN_ECT1
||
m_header
.
GetEcn
() ==
Ipv4Header::ECN_ECT0
))
88
{
89
m_header
.
SetEcn
(
Ipv4Header::ECN_CE
);
90
return
true
;
91
}
92
return
false
;
93
}
94
95
96
bool
97
Ipv4QueueDiscItem::GetUint8Value
(
QueueItem::Uint8Values
field, uint8_t& value)
const
98
{
99
bool
ret =
false
;
100
101
switch
(field)
102
{
103
case
IP_DSFIELD
:
104
value =
m_header
.
GetTos
();
105
ret =
true
;
106
break
;
107
}
108
109
return
ret;
110
}
111
112
}
// namespace ns3
ns3::QueueDiscItem::GetTxQueueIndex
uint8_t GetTxQueueIndex(void) const
Get the transmission queue index included in this item.
Definition:
queue-item.cc:105
ns3::Ipv4QueueDiscItem::~Ipv4QueueDiscItem
virtual ~Ipv4QueueDiscItem()
Definition:
ipv4-queue-disc-item.cc:34
ns3::Ptr< Packet >
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:213
ns3::Ipv4QueueDiscItem::m_header
Ipv4Header m_header
The IPv4 header.
Definition:
ipv4-queue-disc-item.h:106
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition:
assert.h:67
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::Ipv4QueueDiscItem::Print
virtual void Print(std::ostream &os) const
Print the item contents.
Definition:
ipv4-queue-disc-item.cc:70
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition:
packet.h:821
ns3::QueueDiscItem
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition:
queue-item.h:148
ns3::QueueDiscItem::GetAddress
Address GetAddress(void) const
Get the MAC address included in this item.
Definition:
queue-item.cc:91
ns3::Ipv4Header::ECN_ECT0
Definition:
ipv4-header.h:114
ns3::Ipv4QueueDiscItem::GetSize
virtual uint32_t GetSize(void) const
Definition:
ipv4-queue-disc-item.cc:39
ns3::Ipv4QueueDiscItem::Ipv4QueueDiscItem
Ipv4QueueDiscItem()
Default constructor.
ns3::Address
a polymophic address class
Definition:
address.h:90
ns3::Ipv4Header
Packet header for IPv4.
Definition:
ipv4-header.h:33
NS_ASSERT_MSG
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
ns3::Ipv4QueueDiscItem::GetHeader
const Ipv4Header & GetHeader(void) const
Definition:
ipv4-queue-disc-item.cc:53
ns3::Ipv4QueueDiscItem::GetUint8Value
virtual bool GetUint8Value(Uint8Values field, uint8_t &value) const
Retrieve the value of a given field from the packet, if present.
Definition:
ipv4-queue-disc-item.cc:97
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv4QueueDiscItem::Mark
virtual bool Mark(void)
Marks the packet by setting ECN_CE bits if the packet has ECN_ECT0 or ECN_ECT1 bits set...
Definition:
ipv4-queue-disc-item.cc:84
ns3::QueueItem::IP_DSFIELD
Definition:
queue-item.h:78
ns3::QueueItem::Uint8Values
Uint8Values
1-byte fields of the packet whose value can be retrieved, if present
Definition:
queue-item.h:76
ns3::Ipv4Header::ECN_ECT1
Definition:
ipv4-header.h:113
ipv4-queue-disc-item.h
ns3::Ipv4Header::SetEcn
void SetEcn(EcnType ecn)
Set ECN Field.
Definition:
ipv4-header.cc:97
ns3::Ipv4Header::ECN_CE
Definition:
ipv4-header.h:115
ns3::Ipv4QueueDiscItem::AddHeader
virtual void AddHeader(void)
Add the header to the packet.
Definition:
ipv4-queue-disc-item.cc:58
ns3::Ipv4QueueDiscItem::m_headerAdded
bool m_headerAdded
True if the header has already been added to the packet.
Definition:
ipv4-queue-disc-item.h:107
ns3::Ipv4Header::GetTos
uint8_t GetTos(void) const
Definition:
ipv4-header.cc:194
ns3::QueueDiscItem::GetProtocol
uint16_t GetProtocol(void) const
Get the L3 protocol included in this item.
Definition:
queue-item.cc:98
ns3::Ipv4Header::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition:
ipv4-header.cc:375
ns3::Ipv4Header::GetEcn
EcnType GetEcn(void) const
Definition:
ipv4-header.cc:167
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Add header to this packet.
Definition:
packet.cc:256
ns3::QueueItem::GetPacket
Ptr< Packet > GetPacket(void) const
Definition:
queue-item.cc:42
src
internet
model
ipv4-queue-disc-item.cc
Generated on Wed Mar 21 2018 14:24:10 for ns-3 by
1.8.9.1