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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
dsr-errorbuff.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Yufei Cheng
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: Yufei Cheng <yfcheng@ittc.ku.edu>
19
*
20
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22
* Information and Telecommunication Technology Center (ITTC)
23
* and Department of Electrical Engineering and Computer Science
24
* The University of Kansas Lawrence, KS USA.
25
*
26
* Work supported in part by NSF FIND (Future Internet Design) Program
27
* under grant CNS-0626918 (Postmodern Internet Architecture),
28
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29
* US Department of Defense (DoD), and ITTC at The University of Kansas.
30
*/
31
32
#ifndef DSR_ERRORBUFF_H
33
#define DSR_ERRORBUFF_H
34
35
#include <vector>
36
#include "ns3/ipv4-routing-protocol.h"
37
#include "ns3/simulator.h"
38
39
namespace
ns3 {
40
namespace
dsr {
45
class
ErrorBuffEntry
46
{
47
public
:
48
// / c-tor
49
ErrorBuffEntry
(
Ptr<const Packet>
pa = 0,
Ipv4Address
d =
Ipv4Address
(),
Ipv4Address
s
=
Ipv4Address
(),
50
Ipv4Address
n =
Ipv4Address
(),
Time
exp =
Simulator::Now
(), uint8_t p = 0)
51
:
m_packet
(pa),
52
m_dst
(d),
53
m_source
(
s
),
54
m_nextHop
(n),
55
m_expire
(exp +
Simulator
::
Now
()),
56
m_protocol
(p)
57
{
58
}
63
bool
operator==
(
ErrorBuffEntry
const
& o)
const
64
{
65
return
((
m_packet
== o.
m_packet
) && (
m_source
== o.
m_source
) && (
m_nextHop
== o.
m_nextHop
) && (
m_dst
== o.
m_dst
) && (
m_expire
== o.
m_expire
));
66
}
67
// /\name Fields
68
// \{
69
Ptr<const Packet>
GetPacket
()
const
70
{
71
return
m_packet
;
72
}
73
void
SetPacket
(
Ptr<const Packet>
p)
74
{
75
m_packet
= p;
76
}
77
Ipv4Address
GetDestination
()
const
78
{
79
return
m_dst
;
80
}
81
void
SetDestination
(
Ipv4Address
d)
82
{
83
m_dst
= d;
84
}
85
Ipv4Address
GetSource
()
const
86
{
87
return
m_source
;
88
}
89
void
SetSource
(
Ipv4Address
s
)
90
{
91
m_source
=
s
;
92
}
93
Ipv4Address
GetNextHop
()
const
94
{
95
return
m_nextHop
;
96
}
97
void
SetNextHop
(
Ipv4Address
n)
98
{
99
m_nextHop
= n;
100
}
101
void
SetExpireTime
(
Time
exp)
102
{
103
m_expire
= exp +
Simulator::Now
();
104
}
105
Time
GetExpireTime
()
const
106
{
107
return
m_expire
-
Simulator::Now
();
108
}
109
void
SetProtocol
(uint8_t p)
110
{
111
m_protocol
= p;
112
}
113
uint8_t
GetProtocol
()
const
114
{
115
return
m_protocol
;
116
}
117
// \}
118
private
:
119
// / Data packet
120
Ptr<const Packet>
m_packet
;
121
// / Destination address
122
Ipv4Address
m_dst
;
123
// / Source address
124
Ipv4Address
m_source
;
125
// / Nexthop address
126
Ipv4Address
m_nextHop
;
127
// / Expire time for queue entry
128
Time
m_expire
;
129
// / The protocol number
130
uint8_t
m_protocol
;
131
};
132
137
/************************************************************************************************************************/
138
class
ErrorBuffer
139
{
140
public
:
141
// / Default c-tor
142
ErrorBuffer
()
143
{
144
}
145
// / Push entry in queue, if there is no entry with the same packet and destination address in queue.
146
bool
Enqueue
(
ErrorBuffEntry
& entry);
147
// / Return first found (the earliest) entry for given destination
148
bool
Dequeue
(
Ipv4Address
dst,
ErrorBuffEntry
& entry);
149
// / Remove all packets with the error link
150
void
DropPacketForErrLink
(
Ipv4Address
source,
Ipv4Address
nextHop);
151
// / Finds whether a packet with destination dst exists in the queue
152
bool
Find
(
Ipv4Address
dst);
153
// / Number of entries
154
uint32_t
GetSize
();
155
// /\name Fields
156
// \{
157
uint32_t
GetMaxQueueLen
()
const
158
{
159
return
m_maxLen
;
160
}
161
void
SetMaxQueueLen
(uint32_t len)
162
{
163
m_maxLen
= len;
164
}
165
Time
GetErrorBufferTimeout
()
const
166
{
167
return
m_errorBufferTimeout
;
168
}
169
void
SetErrorBufferTimeout
(
Time
t)
170
{
171
m_errorBufferTimeout
= t;
172
}
173
// \}
174
175
std::vector<ErrorBuffEntry> &
GetBuffer
()
176
{
177
return
m_errorBuffer
;
178
}
179
180
private
:
181
// / The send buffer to cache unsent packet
182
std::vector<ErrorBuffEntry>
m_errorBuffer
;
183
// / Remove all expired entries
184
void
Purge
();
185
// / Notify that packet is dropped from queue by timeout
186
void
Drop
(
ErrorBuffEntry
en, std::string reason);
187
// / Notify that packet is dropped from queue by timeout
188
void
DropLink
(
ErrorBuffEntry
en, std::string reason);
189
// / The maximum number of packets that we allow a routing protocol to buffer.
190
uint32_t
m_maxLen
;
191
// / The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
192
Time
m_errorBufferTimeout
;
193
// / Check if the send buffer entry is the same or not
194
static
bool
LinkEqual
(
ErrorBuffEntry
en,
const
std::vector<Ipv4Address> link)
195
{
196
return
((en.
GetSource
() == link[0]) && (en.
GetNextHop
() == link[1]));
197
}
198
};
199
/*******************************************************************************************************************************/
200
}
// namespace dsr
201
}
// namespace ns3
202
203
#endif
/* DSR_ERRORBUFF_H */
ns3::dsr::ErrorBuffer::Dequeue
bool Dequeue(Ipv4Address dst, ErrorBuffEntry &entry)
Definition:
dsr-errorbuff.cc:108
ns3::dsr::ErrorBuffEntry::ErrorBuffEntry
ErrorBuffEntry(Ptr< const Packet > pa=0, Ipv4Address d=Ipv4Address(), Ipv4Address s=Ipv4Address(), Ipv4Address n=Ipv4Address(), Time exp=Simulator::Now(), uint8_t p=0)
Definition:
dsr-errorbuff.h:49
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::dsr::ErrorBuffer::m_maxLen
uint32_t m_maxLen
Definition:
dsr-errorbuff.h:190
ns3::Ptr< const Packet >
ns3::Simulator
Control the scheduling of simulation events.
Definition:
simulator.h:62
ns3::dsr::ErrorBuffEntry::SetDestination
void SetDestination(Ipv4Address d)
Definition:
dsr-errorbuff.h:81
ns3::dsr::ErrorBuffer::m_errorBufferTimeout
Time m_errorBufferTimeout
Definition:
dsr-errorbuff.h:192
ns3::dsr::ErrorBuffer::SetErrorBufferTimeout
void SetErrorBufferTimeout(Time t)
Definition:
dsr-errorbuff.h:169
ns3::dsr::ErrorBuffer::Enqueue
bool Enqueue(ErrorBuffEntry &entry)
Definition:
dsr-errorbuff.cc:52
ns3::dsr::ErrorBuffer::DropPacketForErrLink
void DropPacketForErrLink(Ipv4Address source, Ipv4Address nextHop)
Definition:
dsr-errorbuff.cc:84
ns3::dsr::ErrorBuffer::GetMaxQueueLen
uint32_t GetMaxQueueLen() const
Definition:
dsr-errorbuff.h:157
ns3::dsr::ErrorBuffEntry::m_source
Ipv4Address m_source
Definition:
dsr-errorbuff.h:124
ns3::dsr::ErrorBuffEntry::GetProtocol
uint8_t GetProtocol() const
Definition:
dsr-errorbuff.h:113
ns3::dsr::ErrorBuffEntry::SetSource
void SetSource(Ipv4Address s)
Definition:
dsr-errorbuff.h:89
ns3::dsr::ErrorBuffEntry::m_protocol
uint8_t m_protocol
Definition:
dsr-errorbuff.h:130
ns3::dsr::ErrorBuffEntry::m_expire
Time m_expire
Definition:
dsr-errorbuff.h:128
ns3::dsr::ErrorBuffEntry::SetPacket
void SetPacket(Ptr< const Packet > p)
Definition:
dsr-errorbuff.h:73
ns3::dsr::ErrorBuffEntry::GetNextHop
Ipv4Address GetNextHop() const
Definition:
dsr-errorbuff.h:93
s
Ptr< SampleEmitter > s
Definition:
double-probe-test-suite.cc:51
ns3::dsr::ErrorBuffEntry::operator==
bool operator==(ErrorBuffEntry const &o) const
Definition:
dsr-errorbuff.h:63
ns3::dsr::ErrorBuffer::Purge
void Purge()
Definition:
dsr-errorbuff.cc:156
ns3::dsr::ErrorBuffer::DropLink
void DropLink(ErrorBuffEntry en, std::string reason)
Definition:
dsr-errorbuff.cc:186
ns3::dsr::ErrorBuffEntry::GetPacket
Ptr< const Packet > GetPacket() const
Definition:
dsr-errorbuff.h:69
ns3::dsr::ErrorBuffer::LinkEqual
static bool LinkEqual(ErrorBuffEntry en, const std::vector< Ipv4Address > link)
Definition:
dsr-errorbuff.h:194
ns3::dsr::ErrorBuffEntry::GetDestination
Ipv4Address GetDestination() const
Definition:
dsr-errorbuff.h:77
ns3::dsr::ErrorBuffer::GetSize
uint32_t GetSize()
Definition:
dsr-errorbuff.cc:45
ns3::dsr::ErrorBuffEntry::SetProtocol
void SetProtocol(uint8_t p)
Definition:
dsr-errorbuff.h:109
ns3::dsr::ErrorBuffEntry::m_packet
Ptr< const Packet > m_packet
Definition:
dsr-errorbuff.h:120
ns3::dsr::ErrorBuffEntry
DSR Error Buffer Entry.
Definition:
dsr-errorbuff.h:45
ns3::dsr::ErrorBuffer::Find
bool Find(Ipv4Address dst)
Definition:
dsr-errorbuff.cc:128
ns3::dsr::ErrorBuffer::SetMaxQueueLen
void SetMaxQueueLen(uint32_t len)
Definition:
dsr-errorbuff.h:161
ns3::dsr::ErrorBuffEntry::SetNextHop
void SetNextHop(Ipv4Address n)
Definition:
dsr-errorbuff.h:97
ns3::Simulator::Now
static Time Now(void)
Definition:
simulator.cc:180
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:287
ns3::dsr::ErrorBuffEntry::m_dst
Ipv4Address m_dst
Definition:
dsr-errorbuff.h:122
ns3::dsr::ErrorBuffer::ErrorBuffer
ErrorBuffer()
Definition:
dsr-errorbuff.h:142
ns3::dsr::ErrorBuffEntry::GetSource
Ipv4Address GetSource() const
Definition:
dsr-errorbuff.h:85
ns3::dsr::ErrorBuffer::Drop
void Drop(ErrorBuffEntry en, std::string reason)
Definition:
dsr-errorbuff.cc:177
ns3::dsr::ErrorBuffEntry::m_nextHop
Ipv4Address m_nextHop
Definition:
dsr-errorbuff.h:126
ns3::dsr::ErrorBuffer
DSR error buffer.
Definition:
dsr-errorbuff.h:138
ns3::dsr::ErrorBuffer::GetErrorBufferTimeout
Time GetErrorBufferTimeout() const
Definition:
dsr-errorbuff.h:165
ns3::dsr::ErrorBuffEntry::SetExpireTime
void SetExpireTime(Time exp)
Definition:
dsr-errorbuff.h:101
ns3::dsr::ErrorBuffEntry::GetExpireTime
Time GetExpireTime() const
Definition:
dsr-errorbuff.h:105
ns3::dsr::ErrorBuffer::GetBuffer
std::vector< ErrorBuffEntry > & GetBuffer()
Definition:
dsr-errorbuff.h:175
ns3::dsr::ErrorBuffer::m_errorBuffer
std::vector< ErrorBuffEntry > m_errorBuffer
Definition:
dsr-errorbuff.h:182
src
dsr
model
dsr-errorbuff.h
Generated on Sat Nov 16 2013 16:17:38 for ns-3 by
1.8.5