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 <cstring>
23
24
#include "ns3/address.h"
25
#include "ns3/net-device.h"
26
#include "ns3/node.h"
27
#include "ns3/callback.h"
28
#include "ns3/packet.h"
29
#include "ns3/traced-callback.h"
30
#include "ns3/event-id.h"
31
#include "ns3/nstime.h"
32
#include "ns3/data-rate.h"
33
#include "ns3/ptr.h"
34
#include "ns3/mac48-address.h"
35
#include "ns3/system-thread.h"
36
#include "ns3/system-mutex.h"
37
38
namespace
ns3 {
39
40
class
Queue;
41
52
class
EmuNetDevice
:
public
NetDevice
53
{
54
public
:
55
static
TypeId
GetTypeId
(
void
);
56
60
enum
EncapsulationMode
{
61
ILLEGAL
,
62
DIX
,
63
LLC
,
64
};
65
71
EmuNetDevice
();
72
78
virtual
~EmuNetDevice
();
79
86
void
SetDataRate
(
DataRate
bps);
87
93
void
Start
(
Time
tStart);
94
100
void
Stop
(
Time
tStop);
101
112
void
SetQueue
(
Ptr<Queue>
queue);
113
119
Ptr<Queue>
GetQueue
(
void
)
const
;
120
121
122
//
123
// Pure virtual methods inherited from NetDevice we must implement.
124
//
125
virtual
void
SetIfIndex
(
const
uint32_t index);
126
virtual
uint32_t
GetIfIndex
(
void
)
const
;
127
128
virtual
Ptr<Channel>
GetChannel
(
void
)
const
;
129
130
virtual
void
SetAddress
(
Address
address);
131
virtual
Address
GetAddress
(
void
)
const
;
132
133
virtual
bool
SetMtu
(
const
uint16_t mtu);
134
virtual
uint16_t
GetMtu
(
void
)
const
;
135
136
virtual
bool
IsLinkUp
(
void
)
const
;
137
138
virtual
void
AddLinkChangeCallback
(
Callback<void>
callback);
139
140
virtual
bool
IsBroadcast
(
void
)
const
;
141
virtual
Address
GetBroadcast
(
void
)
const
;
142
143
virtual
bool
IsMulticast
(
void
)
const
;
144
167
virtual
Address
GetMulticast
(
Ipv4Address
multicastGroup)
const
;
168
176
virtual
Address
GetMulticast
(
Ipv6Address
addr)
const
;
177
182
virtual
bool
IsPointToPoint
(
void
)
const
;
183
188
virtual
bool
IsBridge
(
void
)
const
;
189
190
virtual
bool
Send
(
Ptr<Packet>
packet,
const
Address
&dest, uint16_t protocolNumber);
191
192
virtual
bool
SendFrom
(
Ptr<Packet>
packet,
const
Address
& source,
const
Address
& dest, uint16_t protocolNumber);
193
194
virtual
Ptr<Node>
GetNode
(
void
)
const
;
195
virtual
void
SetNode
(
Ptr<Node>
node);
196
197
virtual
bool
NeedsArp
(
void
)
const
;
198
199
virtual
void
SetReceiveCallback
(
NetDevice::ReceiveCallback
cb);
200
virtual
void
SetPromiscReceiveCallback
(
PromiscReceiveCallback
cb);
201
202
virtual
bool
SupportsSendFrom
(
void
)
const
;
203
211
void
SetEncapsulationMode
(
EmuNetDevice::EncapsulationMode
mode);
212
218
EmuNetDevice::EncapsulationMode
GetEncapsulationMode
(
void
)
const
;
219
220
private
:
221
EmuNetDevice
(
const
EmuNetDevice
&);
222
EmuNetDevice
&
operator=
(
const
EmuNetDevice
&);
223
224
virtual
void
DoDispose
(
void
);
225
231
void
CreateSocket
(
void
);
232
236
std::string
FindCreator
(std::string creatorName);
237
241
void
StartDevice
(
void
);
242
246
void
StopDevice
(
void
);
247
251
void
ReadThread
(
void
);
252
256
void
ForwardUp
(uint8_t *buf, uint32_t len);
257
264
void
AddHeader
(
Ptr<Packet>
p, uint16_t protocolNumber);
265
274
bool
ProcessHeader
(
Ptr<Packet>
p, uint16_t& param);
275
281
bool
TransmitStart
(
Ptr<Packet>
p);
282
283
void
NotifyLinkUp
(
void
);
284
292
Ptr<Queue>
m_queue
;
293
300
TracedCallback<Ptr<const Packet>
>
m_macTxTrace
;
301
308
TracedCallback<Ptr<const Packet>
>
m_macTxDropTrace
;
309
317
TracedCallback<Ptr<const Packet>
>
m_macPromiscRxTrace
;
318
326
TracedCallback<Ptr<const Packet>
>
m_macRxTrace
;
327
335
TracedCallback<Ptr<const Packet>
>
m_macRxDropTrace
;
336
343
TracedCallback<Ptr<const Packet>
>
m_phyTxBeginTrace
;
344
351
TracedCallback<Ptr<const Packet>
>
m_phyTxEndTrace
;
352
359
TracedCallback<Ptr<const Packet>
>
m_phyTxDropTrace
;
360
367
TracedCallback<Ptr<const Packet>
>
m_phyRxTrace
;
368
375
TracedCallback<Ptr<const Packet>
>
m_phyRxBeginTrace
;
376
383
TracedCallback<Ptr<const Packet>
>
m_phyRxEndTrace
;
384
390
TracedCallback<Ptr<const Packet>
>
m_phyRxDropTrace
;
391
410
TracedCallback<Ptr<const Packet>
>
m_snifferTrace
;
411
430
TracedCallback<Ptr<const Packet>
>
m_promiscSnifferTrace
;
431
435
Time
m_tStart
;
436
440
Time
m_tStop
;
441
442
EventId
m_startEvent
;
443
EventId
m_stopEvent
;
444
445
int32_t
m_sock
;
446
447
Ptr<SystemThread>
m_readThread
;
448
452
Ptr<Node>
m_node
;
453
457
Mac48Address
m_address
;
458
462
NetDevice::ReceiveCallback
m_rxCallback
;
463
467
NetDevice::PromiscReceiveCallback
m_promiscRxCallback
;
468
472
uint32_t
m_ifIndex
;
473
478
int32_t
m_sll_ifindex
;
479
485
EncapsulationMode
m_encapMode
;
486
491
bool
m_linkUp
;
492
497
bool
m_isBroadcast
;
498
503
bool
m_isMulticast
;
504
508
TracedCallback<>
m_linkChangeCallbacks
;
509
513
std::string
m_deviceName
;
514
518
uint8_t *
m_packetBuffer
;
519
520
/*
521
* a copy of the node id so the read thread doesn't have to GetNode() in
522
* in order to find the node ID. Thread unsafe reference counting in
523
* multithreaded apps is not a good thing.
524
*/
525
uint32_t
m_nodeId
;
526
527
uint32_t
m_maxPendingReads
;
528
uint32_t
m_pendingReadCount
;
529
SystemMutex
m_pendingReadMutex
;
530
};
531
532
}
// namespace ns3
533
534
#endif
/* EMU_NET_DEVICE_H */
src
emu
model
emu-net-device.h
Generated on Tue May 14 2013 11:08:20 for ns-3 by
1.8.1.2