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
emu-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) 2008 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
19
#ifndef EMU_NET_DEVICE_H
20
#define EMU_NET_DEVICE_H
21
22
#include <
string.h
>
23
#include "ns3/address.h"
24
#include "ns3/net-device.h"
25
#include "ns3/node.h"
26
#include "ns3/callback.h"
27
#include "ns3/packet.h"
28
#include "ns3/traced-callback.h"
29
#include "ns3/event-id.h"
30
#include "ns3/nstime.h"
31
#include "ns3/data-rate.h"
32
#include "ns3/ptr.h"
33
#include "ns3/mac48-address.h"
34
#include "ns3/system-thread.h"
35
#include "ns3/system-mutex.h"
36
37
namespace
ns3 {
38
39
class
Queue;
40
51
class
EmuNetDevice
:
public
NetDevice
52
{
53
public
:
54
static
TypeId
GetTypeId
(
void
);
55
59
enum
EncapsulationMode
{
60
ILLEGAL
,
61
DIX
,
62
LLC
,
63
};
64
70
EmuNetDevice
();
71
77
virtual
~EmuNetDevice
();
78
85
void
SetDataRate
(
DataRate
bps);
86
92
void
Start
(
Time
tStart);
93
99
void
Stop
(
Time
tStop);
100
111
void
SetQueue
(
Ptr<Queue>
queue);
112
118
Ptr<Queue>
GetQueue
(
void
)
const
;
119
120
121
//
122
// Pure virtual methods inherited from NetDevice we must implement.
123
//
124
virtual
void
SetIfIndex
(
const
uint32_t index);
125
virtual
uint32_t
GetIfIndex
(
void
)
const
;
126
127
virtual
Ptr<Channel>
GetChannel
(
void
)
const
;
128
129
virtual
void
SetAddress
(
Address
address);
130
virtual
Address
GetAddress
(
void
)
const
;
131
132
virtual
bool
SetMtu
(
const
uint16_t mtu);
133
virtual
uint16_t
GetMtu
(
void
)
const
;
134
135
virtual
bool
IsLinkUp
(
void
)
const
;
136
137
virtual
void
AddLinkChangeCallback
(
Callback<void>
callback);
138
139
virtual
bool
IsBroadcast
(
void
)
const
;
140
virtual
Address
GetBroadcast
(
void
)
const
;
141
142
virtual
bool
IsMulticast
(
void
)
const
;
143
166
virtual
Address
GetMulticast
(
Ipv4Address
multicastGroup)
const
;
167
175
virtual
Address
GetMulticast
(
Ipv6Address
addr)
const
;
176
181
virtual
bool
IsPointToPoint
(
void
)
const
;
182
187
virtual
bool
IsBridge
(
void
)
const
;
188
189
virtual
bool
Send
(
Ptr<Packet>
packet,
const
Address
&dest, uint16_t protocolNumber);
190
191
virtual
bool
SendFrom
(
Ptr<Packet>
packet,
const
Address
& source,
const
Address
& dest, uint16_t protocolNumber);
192
193
virtual
Ptr<Node>
GetNode
(
void
)
const
;
194
virtual
void
SetNode
(
Ptr<Node>
node);
195
196
virtual
bool
NeedsArp
(
void
)
const
;
197
198
virtual
void
SetReceiveCallback
(
NetDevice::ReceiveCallback
cb);
199
virtual
void
SetPromiscReceiveCallback
(
PromiscReceiveCallback
cb);
200
201
virtual
bool
SupportsSendFrom
(
void
)
const
;
202
210
void
SetEncapsulationMode
(
EmuNetDevice::EncapsulationMode
mode);
211
217
EmuNetDevice::EncapsulationMode
GetEncapsulationMode
(
void
)
const
;
218
219
private
:
220
EmuNetDevice
(
const
EmuNetDevice
&);
221
EmuNetDevice
&
operator=
(
const
EmuNetDevice
&);
222
223
virtual
void
DoDispose
(
void
);
224
230
void
CreateSocket
(
void
);
231
235
std::string
FindCreator
(std::string creatorName);
236
240
void
StartDevice
(
void
);
241
245
void
StopDevice
(
void
);
246
250
void
ReadThread
(
void
);
251
255
void
ForwardUp
(uint8_t *buf, uint32_t len);
256
263
void
AddHeader
(
Ptr<Packet>
p, uint16_t protocolNumber);
264
273
bool
ProcessHeader
(
Ptr<Packet>
p, uint16_t& param);
274
280
bool
TransmitStart
(
Ptr<Packet>
p);
281
282
void
NotifyLinkUp
(
void
);
283
291
Ptr<Queue>
m_queue
;
292
299
TracedCallback<Ptr<const Packet>
>
m_macTxTrace
;
300
307
TracedCallback<Ptr<const Packet>
>
m_macTxDropTrace
;
308
316
TracedCallback<Ptr<const Packet>
>
m_macPromiscRxTrace
;
317
325
TracedCallback<Ptr<const Packet>
>
m_macRxTrace
;
326
334
TracedCallback<Ptr<const Packet>
>
m_macRxDropTrace
;
335
342
TracedCallback<Ptr<const Packet>
>
m_phyTxBeginTrace
;
343
350
TracedCallback<Ptr<const Packet>
>
m_phyTxEndTrace
;
351
358
TracedCallback<Ptr<const Packet>
>
m_phyTxDropTrace
;
359
366
TracedCallback<Ptr<const Packet>
>
m_phyRxTrace
;
367
374
TracedCallback<Ptr<const Packet>
>
m_phyRxBeginTrace
;
375
382
TracedCallback<Ptr<const Packet>
>
m_phyRxEndTrace
;
383
389
TracedCallback<Ptr<const Packet>
>
m_phyRxDropTrace
;
390
409
TracedCallback<Ptr<const Packet>
>
m_snifferTrace
;
410
429
TracedCallback<Ptr<const Packet>
>
m_promiscSnifferTrace
;
430
434
Time
m_tStart
;
435
439
Time
m_tStop
;
440
441
EventId
m_startEvent
;
442
EventId
m_stopEvent
;
443
444
int32_t
m_sock
;
445
446
Ptr<SystemThread>
m_readThread
;
447
451
Ptr<Node>
m_node
;
452
456
Mac48Address
m_address
;
457
461
NetDevice::ReceiveCallback
m_rxCallback
;
462
466
NetDevice::PromiscReceiveCallback
m_promiscRxCallback
;
467
471
uint32_t
m_ifIndex
;
472
477
int32_t
m_sll_ifindex
;
478
484
EncapsulationMode
m_encapMode
;
485
490
bool
m_linkUp
;
491
496
bool
m_isBroadcast
;
497
502
bool
m_isMulticast
;
503
507
TracedCallback<>
m_linkChangeCallbacks
;
508
512
std::string
m_deviceName
;
513
517
uint8_t *
m_packetBuffer
;
518
519
/*
520
* a copy of the node id so the read thread doesn't have to GetNode() in
521
* in order to find the node ID. Thread unsafe reference counting in
522
* multithreaded apps is not a good thing.
523
*/
524
uint32_t
m_nodeId
;
525
526
uint32_t
m_maxPendingReads
;
527
uint32_t
m_pendingReadCount
;
528
SystemMutex
m_pendingReadMutex
;
529
};
530
531
}
// namespace ns3
532
533
#endif
/* EMU_NET_DEVICE_H */
src
emu
model
emu-net-device.h
Generated on Tue Oct 9 2012 16:45:37 for ns-3 by
1.8.1.2