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
fd-net-device.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 INRIA, 2012 University of Washington
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: Alina Quereilhac <alina.quereilhac@inria.fr>
19
* Claudio Freire <klaussfreire@sourceforge.net>
20
*/
21
22
#ifndef FD_NET_DEVICE_H
23
#define FD_NET_DEVICE_H
24
25
#include "ns3/address.h"
26
#include "ns3/callback.h"
27
#include "ns3/data-rate.h"
28
#include "ns3/event-id.h"
29
#include "ns3/mac48-address.h"
30
#include "ns3/net-device.h"
31
#include "ns3/node.h"
32
#include "ns3/packet.h"
33
#include "ns3/ptr.h"
34
#include "ns3/system-condition.h"
35
#include "ns3/traced-callback.h"
36
#include "ns3/unix-fd-reader.h"
37
#include "ns3/system-mutex.h"
38
39
#include <
string.h
>
40
41
namespace
ns3 {
42
43
class
FdNetDeviceFdReader
:
public
FdReader
44
{
45
public
:
49
FdNetDeviceFdReader
();
50
55
void
SetBufferSize
(uint32_t bufferSize);
56
57
private
:
58
FdReader::Data
DoRead
(
void
);
59
60
uint32_t
m_bufferSize
;
61
};
62
63
class
Node
;
64
82
class
FdNetDevice
:
public
NetDevice
83
{
84
public
:
85
static
TypeId
GetTypeId
(
void
);
86
90
enum
EncapsulationMode
91
{
92
DIX
,
93
LLC
,
94
DIXPI
,
100
};
101
105
FdNetDevice
();
106
110
virtual
~FdNetDevice
();
111
118
void
SetEncapsulationMode
(
FdNetDevice::EncapsulationMode
mode);
119
125
FdNetDevice::EncapsulationMode
GetEncapsulationMode
(
void
)
const
;
126
131
void
SetFileDescriptor
(
int
fd);
132
138
void
Start
(
Time
tStart);
139
145
void
Stop
(
Time
tStop);
146
147
// inherited from NetDevice base class.
148
virtual
void
SetIfIndex
(
const
uint32_t index);
149
virtual
uint32_t
GetIfIndex
(
void
)
const
;
150
virtual
Ptr<Channel>
GetChannel
(
void
)
const
;
151
virtual
void
SetAddress
(
Address
address);
152
virtual
Address
GetAddress
(
void
)
const
;
153
virtual
bool
SetMtu
(
const
uint16_t mtu);
154
virtual
uint16_t
GetMtu
(
void
)
const
;
155
virtual
bool
IsLinkUp
(
void
)
const
;
156
virtual
void
AddLinkChangeCallback
(
Callback<void>
callback);
157
virtual
bool
IsBroadcast
(
void
)
const
;
158
virtual
Address
GetBroadcast
(
void
)
const
;
159
virtual
bool
IsMulticast
(
void
)
const
;
160
virtual
Address
GetMulticast
(
Ipv4Address
multicastGroup)
const
;
161
virtual
bool
IsPointToPoint
(
void
)
const
;
162
virtual
bool
IsBridge
(
void
)
const
;
163
virtual
bool
Send
(
Ptr<Packet>
packet,
const
Address
& dest, uint16_t protocolNumber);
164
virtual
bool
SendFrom
(
Ptr<Packet>
packet,
const
Address
& source,
const
Address
& dest, uint16_t protocolNumber);
165
virtual
Ptr<Node>
GetNode
(
void
)
const
;
166
virtual
void
SetNode
(
Ptr<Node>
node);
167
virtual
bool
NeedsArp
(
void
)
const
;
168
virtual
void
SetReceiveCallback
(
NetDevice::ReceiveCallback
cb);
169
virtual
void
SetPromiscReceiveCallback
(
NetDevice::PromiscReceiveCallback
cb);
170
virtual
bool
SupportsSendFrom
()
const
;
171
virtual
Address
GetMulticast
(
Ipv6Address
addr)
const
;
172
173
virtual
void
SetIsBroadcast
(
bool
broadcast);
174
virtual
void
SetIsMulticast
(
bool
multicast);
175
176
protected
:
177
virtual
void
DoDispose
(
void
);
178
179
private
:
180
// private copy constructor as sugested in:
181
// http://www.nsnam.org/wiki/index.php/NS-3_Python_Bindings#.22invalid_use_of_incomplete_type.22
182
FdNetDevice
(
FdNetDevice
const
&);
183
189
void
StartDevice
(
void
);
190
196
void
StopDevice
(
void
);
197
203
void
ReceiveCallback
(uint8_t *buf, ssize_t len);
204
210
void
ForwardUp
(uint8_t *buf, ssize_t len);
211
217
bool
TransmitStart
(
Ptr<Packet>
p);
218
219
void
NotifyLinkUp
(
void
);
220
226
Ptr<Node>
m_node
;
227
228
/*
229
* \internal
230
*
231
* a copy of the node id so the read thread doesn't have to GetNode() in
232
* in order to find the node ID. Thread unsafe reference counting in
233
* multithreaded apps is not a good thing.
234
*/
235
uint32_t
m_nodeId
;
236
242
uint32_t
m_ifIndex
;
243
249
uint16_t
m_mtu
;
250
256
int
m_fd
;
257
263
Ptr<FdNetDeviceFdReader>
m_fdReader
;
264
270
Mac48Address
m_address
;
271
277
EncapsulationMode
m_encapMode
;
278
285
bool
m_linkUp
;
286
292
TracedCallback<>
m_linkChangeCallbacks
;
293
300
bool
m_isBroadcast
;
301
308
bool
m_isMulticast
;
309
315
uint32_t
m_pendingReadCount
;
316
322
uint32_t
m_maxPendingReads
;
323
324
330
SystemMutex
m_pendingReadMutex
;
331
337
Time
m_tStart
;
338
344
Time
m_tStop
;
345
346
EventId
m_startEvent
;
347
EventId
m_stopEvent
;
348
352
NetDevice::ReceiveCallback
m_rxCallback
;
353
357
NetDevice::PromiscReceiveCallback
m_promiscRxCallback
;
358
365
TracedCallback<Ptr<const Packet>
>
m_macTxTrace
;
366
373
TracedCallback<Ptr<const Packet>
>
m_macTxDropTrace
;
374
382
TracedCallback<Ptr<const Packet>
>
m_macPromiscRxTrace
;
383
391
TracedCallback<Ptr<const Packet>
>
m_macRxTrace
;
392
400
TracedCallback<Ptr<const Packet>
>
m_macRxDropTrace
;
401
408
TracedCallback<Ptr<const Packet>
>
m_phyTxDropTrace
;
409
415
TracedCallback<Ptr<const Packet>
>
m_phyRxDropTrace
;
416
435
TracedCallback<Ptr<const Packet>
>
m_snifferTrace
;
436
455
TracedCallback<Ptr<const Packet>
>
m_promiscSnifferTrace
;
456
457
};
458
459
}
// namespace ns3
460
461
#endif
/* FD_NET_DEVICE_H */
462
src
fd-net-device
model
fd-net-device.h
Generated on Tue May 14 2013 11:08:21 for ns-3 by
1.8.1.2