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-rsendbuff.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_SENDBUFF_H
33
#define DSR_SENDBUFF_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
SendBuffEntry
46
{
47
public
:
48
// / c-tor
49
SendBuffEntry
(
Ptr<const Packet>
pa = 0,
Ipv4Address
d =
Ipv4Address
(),
50
Time
exp =
Simulator::Now
(), uint8_t p = 0)
51
:
m_packet
(pa),
52
m_dst
(d),
53
m_expire
(exp +
Simulator
::
Now
()),
54
m_protocol
(p)
55
{
56
}
61
bool
operator==
(
SendBuffEntry
const
& o)
const
62
{
63
return
((
m_packet
== o.
m_packet
) && (
m_dst
== o.
m_dst
) && (
m_expire
== o.
m_expire
));
64
}
65
// /\name Fields
66
// \{
67
Ptr<const Packet>
GetPacket
()
const
68
{
69
return
m_packet
;
70
}
71
void
SetPacket
(
Ptr<const Packet>
p)
72
{
73
m_packet
= p;
74
}
75
Ipv4Address
GetDestination
()
const
76
{
77
return
m_dst
;
78
}
79
void
SetDestination
(
Ipv4Address
d)
80
{
81
m_dst
= d;
82
}
83
void
SetExpireTime
(
Time
exp)
84
{
85
m_expire
= exp +
Simulator::Now
();
86
}
87
Time
GetExpireTime
()
const
88
{
89
return
m_expire
-
Simulator::Now
();
90
}
91
void
SetProtocol
(uint8_t p)
92
{
93
m_protocol
= p;
94
}
95
uint8_t
GetProtocol
()
const
96
{
97
return
m_protocol
;
98
}
99
// \}
100
private
:
101
// / Data packet
102
Ptr<const Packet>
m_packet
;
103
// / Destination address
104
Ipv4Address
m_dst
;
105
// / Expire time for queue entry
106
Time
m_expire
;
107
// / The protocol number
108
uint8_t
m_protocol
;
109
};
110
115
/************************************************************************************************************************/
116
class
SendBuffer
117
{
118
public
:
119
// / Default c-tor
120
SendBuffer
()
121
{
122
}
123
// / Push entry in queue, if there is no entry with the same packet and destination address in queue.
124
bool
Enqueue
(
SendBuffEntry
& entry);
125
// / Return first found (the earliest) entry for given destination
126
bool
Dequeue
(
Ipv4Address
dst,
SendBuffEntry
& entry);
127
// / Remove all packets with destination IP address dst
128
void
DropPacketWithDst
(
Ipv4Address
dst);
129
// / Finds whether a packet with destination dst exists in the queue
130
bool
Find
(
Ipv4Address
dst);
131
// / Number of entries
132
uint32_t
GetSize
();
133
// /\name Fields
134
// \{
135
uint32_t
GetMaxQueueLen
()
const
136
{
137
return
m_maxLen
;
138
}
139
void
SetMaxQueueLen
(uint32_t len)
140
{
141
m_maxLen
= len;
142
}
143
Time
GetSendBufferTimeout
()
const
144
{
145
return
m_sendBufferTimeout
;
146
}
147
void
SetSendBufferTimeout
(
Time
t)
148
{
149
m_sendBufferTimeout
= t;
150
}
151
// \}
152
153
std::vector<SendBuffEntry> &
GetBuffer
()
154
{
155
return
m_sendBuffer
;
156
}
157
158
private
:
159
160
std::vector<SendBuffEntry>
m_sendBuffer
;
161
void
Purge
();
162
void
Drop
(
SendBuffEntry
en, std::string reason);
163
uint32_t
m_maxLen
;
164
Time
m_sendBufferTimeout
;
165
static
bool
IsEqual
(
SendBuffEntry
en,
const
Ipv4Address
dst)
166
{
167
return
(en.
GetDestination
() == dst);
168
}
169
};
170
/*******************************************************************************************************************************/
171
}
// namespace dsr
172
}
// namespace ns3
173
174
#endif
/* DSR_SENDBUFF_H */
ns3::dsr::SendBuffer::m_sendBufferTimeout
Time m_sendBufferTimeout
The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Definition:
dsr-rsendbuff.h:164
ns3::dsr::SendBuffer::Find
bool Find(Ipv4Address dst)
Definition:
dsr-rsendbuff.cc:123
ns3::dsr::SendBuffEntry::m_expire
Time m_expire
Definition:
dsr-rsendbuff.h:106
ns3::dsr::SendBuffer::Drop
void Drop(SendBuffEntry en, std::string reason)
Notify that packet is dropped from queue by timeout.
Definition:
dsr-rsendbuff.cc:172
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::dsr::SendBuffer::GetSize
uint32_t GetSize()
Definition:
dsr-rsendbuff.cc:45
ns3::Ptr< const Packet >
ns3::Simulator
Control the scheduling of simulation events.
Definition:
simulator.h:62
ns3::dsr::SendBuffEntry::m_dst
Ipv4Address m_dst
Definition:
dsr-rsendbuff.h:104
ns3::dsr::SendBuffEntry::GetDestination
Ipv4Address GetDestination() const
Definition:
dsr-rsendbuff.h:75
ns3::dsr::SendBuffer::GetBuffer
std::vector< SendBuffEntry > & GetBuffer()
Definition:
dsr-rsendbuff.h:153
ns3::dsr::SendBuffEntry::SetDestination
void SetDestination(Ipv4Address d)
Definition:
dsr-rsendbuff.h:79
ns3::dsr::SendBuffer::Purge
void Purge()
Remove all expired entries.
Definition:
dsr-rsendbuff.cc:151
ns3::dsr::SendBuffEntry::operator==
bool operator==(SendBuffEntry const &o) const
Definition:
dsr-rsendbuff.h:61
ns3::dsr::SendBuffEntry::SetProtocol
void SetProtocol(uint8_t p)
Definition:
dsr-rsendbuff.h:91
ns3::dsr::SendBuffEntry::m_protocol
uint8_t m_protocol
Definition:
dsr-rsendbuff.h:108
ns3::dsr::SendBuffer::SendBuffer
SendBuffer()
Definition:
dsr-rsendbuff.h:120
ns3::dsr::SendBuffEntry::SetPacket
void SetPacket(Ptr< const Packet > p)
Definition:
dsr-rsendbuff.h:71
ns3::dsr::SendBuffEntry
DSR Send Buffer Entry.
Definition:
dsr-rsendbuff.h:45
ns3::dsr::SendBuffEntry::SendBuffEntry
SendBuffEntry(Ptr< const Packet > pa=0, Ipv4Address d=Ipv4Address(), Time exp=Simulator::Now(), uint8_t p=0)
Definition:
dsr-rsendbuff.h:49
ns3::dsr::SendBuffer::GetMaxQueueLen
uint32_t GetMaxQueueLen() const
Definition:
dsr-rsendbuff.h:135
ns3::dsr::SendBuffer::Dequeue
bool Dequeue(Ipv4Address dst, SendBuffEntry &entry)
Definition:
dsr-rsendbuff.cc:103
ns3::dsr::SendBuffEntry::GetPacket
Ptr< const Packet > GetPacket() const
Definition:
dsr-rsendbuff.h:67
ns3::Simulator::Now
static Time Now(void)
Definition:
simulator.cc:180
ns3::dsr::SendBuffEntry::SetExpireTime
void SetExpireTime(Time exp)
Definition:
dsr-rsendbuff.h:83
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
ns3::dsr::SendBuffEntry::GetProtocol
uint8_t GetProtocol() const
Definition:
dsr-rsendbuff.h:95
ns3::dsr::SendBuffer
DSR send buffer.
Definition:
dsr-rsendbuff.h:116
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:287
ns3::dsr::SendBuffer::m_maxLen
uint32_t m_maxLen
The maximum number of packets that we allow a routing protocol to buffer.
Definition:
dsr-rsendbuff.h:163
ns3::dsr::SendBuffer::m_sendBuffer
std::vector< SendBuffEntry > m_sendBuffer
The send buffer to cache unsent packet.
Definition:
dsr-rsendbuff.h:160
ns3::dsr::SendBuffer::IsEqual
static bool IsEqual(SendBuffEntry en, const Ipv4Address dst)
Definition:
dsr-rsendbuff.h:165
ns3::dsr::SendBuffer::DropPacketWithDst
void DropPacketWithDst(Ipv4Address dst)
Definition:
dsr-rsendbuff.cc:83
ns3::dsr::SendBuffer::SetSendBufferTimeout
void SetSendBufferTimeout(Time t)
Definition:
dsr-rsendbuff.h:147
ns3::dsr::SendBuffer::SetMaxQueueLen
void SetMaxQueueLen(uint32_t len)
Definition:
dsr-rsendbuff.h:139
ns3::dsr::SendBuffer::GetSendBufferTimeout
Time GetSendBufferTimeout() const
Definition:
dsr-rsendbuff.h:143
ns3::dsr::SendBuffer::Enqueue
bool Enqueue(SendBuffEntry &entry)
Definition:
dsr-rsendbuff.cc:52
ns3::dsr::SendBuffEntry::GetExpireTime
Time GetExpireTime() const
Definition:
dsr-rsendbuff.h:87
ns3::dsr::SendBuffEntry::m_packet
Ptr< const Packet > m_packet
Definition:
dsr-rsendbuff.h:102
src
dsr
model
dsr-rsendbuff.h
Generated on Sat Nov 16 2013 16:17:39 for ns-3 by
1.8.5