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
csma-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) 2007 Emmanuelle Laprise
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: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca
19
*/
20
21
#ifndef CSMA_NET_DEVICE_H
22
#define CSMA_NET_DEVICE_H
23
24
#include <
string.h
>
25
#include "ns3/node.h"
26
#include "ns3/backoff.h"
27
#include "ns3/address.h"
28
#include "ns3/net-device.h"
29
#include "ns3/callback.h"
30
#include "ns3/packet.h"
31
#include "ns3/traced-callback.h"
32
#include "ns3/nstime.h"
33
#include "ns3/data-rate.h"
34
#include "ns3/ptr.h"
35
#include "ns3/mac48-address.h"
36
37
namespace
ns3 {
38
39
class
Queue;
40
class
CsmaChannel;
41
class
ErrorModel;
42
58
class
CsmaNetDevice
:
public
NetDevice
59
{
60
public
:
61
static
TypeId
GetTypeId
(
void
);
62
66
enum
EncapsulationMode
{
67
ILLEGAL
,
68
DIX
,
69
LLC
,
70
};
71
77
CsmaNetDevice
();
78
84
virtual
~CsmaNetDevice
();
85
93
void
SetInterframeGap
(
Time
t);
94
106
void
SetBackoffParams
(
Time
slotTime, uint32_t minSlots, uint32_t maxSlots,
107
uint32_t maxRetries, uint32_t ceiling);
108
118
bool
Attach
(
Ptr<CsmaChannel>
ch);
119
131
void
SetQueue
(
Ptr<Queue>
queue);
132
138
Ptr<Queue>
GetQueue
(
void
)
const
;
139
149
void
SetReceiveErrorModel
(
Ptr<ErrorModel>
em);
150
163
void
Receive
(
Ptr<Packet>
p,
Ptr<CsmaNetDevice>
sender);
164
170
bool
IsSendEnabled
(
void
);
171
177
void
SetSendEnable
(
bool
enable);
178
184
bool
IsReceiveEnabled
(
void
);
185
191
void
SetReceiveEnable
(
bool
enable);
192
199
void
SetEncapsulationMode
(
CsmaNetDevice::EncapsulationMode
mode);
200
206
CsmaNetDevice::EncapsulationMode
GetEncapsulationMode
(
void
);
207
208
//
209
// The following methods are inherited from NetDevice base class.
210
//
211
virtual
void
SetIfIndex
(
const
uint32_t index);
212
virtual
uint32_t
GetIfIndex
(
void
)
const
;
213
virtual
Ptr<Channel>
GetChannel
(
void
)
const
;
214
virtual
bool
SetMtu
(
const
uint16_t mtu);
215
virtual
uint16_t
GetMtu
(
void
)
const
;
216
virtual
void
SetAddress
(
Address
address);
217
virtual
Address
GetAddress
(
void
)
const
;
218
virtual
bool
IsLinkUp
(
void
)
const
;
219
virtual
void
AddLinkChangeCallback
(
Callback<void>
callback);
220
virtual
bool
IsBroadcast
(
void
)
const
;
221
virtual
Address
GetBroadcast
(
void
)
const
;
222
virtual
bool
IsMulticast
(
void
)
const
;
223
246
virtual
Address
GetMulticast
(
Ipv4Address
multicastGroup)
const
;
247
252
virtual
bool
IsPointToPoint
(
void
)
const
;
253
258
virtual
bool
IsBridge
(
void
)
const
;
259
267
virtual
bool
Send
(
Ptr<Packet>
packet,
const
Address
& dest,
268
uint16_t protocolNumber);
269
278
virtual
bool
SendFrom
(
Ptr<Packet>
packet,
const
Address
& source,
const
Address
& dest,
279
uint16_t protocolNumber);
280
286
virtual
Ptr<Node>
GetNode
(
void
)
const
;
287
293
virtual
void
SetNode
(
Ptr<Node>
node);
294
301
virtual
bool
NeedsArp
(
void
)
const
;
302
309
virtual
void
SetReceiveCallback
(
NetDevice::ReceiveCallback
cb);
310
318
virtual
Address
GetMulticast
(
Ipv6Address
addr)
const
;
319
320
321
virtual
void
SetPromiscReceiveCallback
(
PromiscReceiveCallback
cb);
322
virtual
bool
SupportsSendFrom
(
void
)
const
;
323
332
int64_t
AssignStreams
(int64_t stream);
333
334
protected
:
339
virtual
void
DoDispose
(
void
);
340
351
void
AddHeader
(
Ptr<Packet>
p,
Mac48Address
source,
Mac48Address
dest, uint16_t protocolNumber);
352
353
private
:
354
360
CsmaNetDevice
&
operator =
(
const
CsmaNetDevice
&o);
361
367
CsmaNetDevice
(
const
CsmaNetDevice
&o);
368
374
void
Init
(
bool
sendEnable,
bool
receiveEnable);
375
393
void
TransmitStart
();
394
411
void
TransmitCompleteEvent
(
void
);
412
427
void
TransmitReadyEvent
(
void
);
428
436
void
TransmitAbort
(
void
);
437
441
void
NotifyLinkUp
(
void
);
442
448
uint32_t
m_deviceId
;
449
453
bool
m_sendEnable
;
454
458
bool
m_receiveEnable
;
459
463
enum
TxMachineState
464
{
465
READY
,
466
BUSY
,
467
GAP
,
468
BACKOFF
469
};
470
475
TxMachineState
m_txMachineState
;
476
482
EncapsulationMode
m_encapMode
;
483
489
DataRate
m_bps
;
490
496
Time
m_tInterframeGap
;
497
503
Backoff
m_backoff
;
504
510
Ptr<Packet>
m_currentPkt
;
511
517
Ptr<CsmaChannel>
m_channel
;
518
526
Ptr<Queue>
m_queue
;
527
533
Ptr<ErrorModel>
m_receiveErrorModel
;
534
541
TracedCallback<Ptr<const Packet>
>
m_macTxTrace
;
542
549
TracedCallback<Ptr<const Packet>
>
m_macTxDropTrace
;
550
558
TracedCallback<Ptr<const Packet>
>
m_macPromiscRxTrace
;
559
567
TracedCallback<Ptr<const Packet>
>
m_macRxTrace
;
568
576
TracedCallback<Ptr<const Packet>
>
m_macRxDropTrace
;
577
585
TracedCallback<Ptr<const Packet>
>
m_macTxBackoffTrace
;
586
593
TracedCallback<Ptr<const Packet>
>
m_phyTxBeginTrace
;
594
601
TracedCallback<Ptr<const Packet>
>
m_phyTxEndTrace
;
602
609
TracedCallback<Ptr<const Packet>
>
m_phyTxDropTrace
;
610
617
TracedCallback<Ptr<const Packet>
>
m_phyRxBeginTrace
;
618
625
TracedCallback<Ptr<const Packet>
>
m_phyRxEndTrace
;
626
632
TracedCallback<Ptr<const Packet>
>
m_phyRxDropTrace
;
633
652
TracedCallback<Ptr<const Packet>
>
m_snifferTrace
;
653
672
TracedCallback<Ptr<const Packet>
>
m_promiscSnifferTrace
;
673
677
Ptr<Node>
m_node
;
678
682
Mac48Address
m_address
;
683
687
NetDevice::ReceiveCallback
m_rxCallback
;
688
692
NetDevice::PromiscReceiveCallback
m_promiscRxCallback
;
693
698
uint32_t
m_ifIndex
;
699
704
bool
m_linkUp
;
705
709
TracedCallback<>
m_linkChangeCallbacks
;
710
711
static
const
uint16_t
DEFAULT_MTU
= 1500;
712
719
uint32_t
m_mtu
;
720
};
721
722
}
// namespace ns3
723
724
#endif
/* CSMA_NET_DEVICE_H */
src
csma
model
csma-net-device.h
Generated on Tue Oct 9 2012 16:45:36 for ns-3 by
1.8.1.2