author | Tom Henderson <tomh@tomh.org> |
Wed, 26 Jan 2011 09:53:49 -0800 | |
changeset 6786 | 17f9a64dd4f6 |
parent 6183 | 8a5e1f9db873 |
permissions | -rw-r--r-- |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
2 |
/* |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 Emmanuelle Laprise |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
4 |
* |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
8 |
* |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
13 |
* |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
17 |
* |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
18 |
* Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca> |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
19 |
*/ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
20 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
21 |
#include "ns3/log.h" |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
22 |
#include "ns3/queue.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
23 |
#include "ns3/simulator.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
24 |
#include "ns3/ethernet-header.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
25 |
#include "ns3/ethernet-trailer.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
26 |
#include "ns3/llc-snap-header.h" |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
27 |
#include "ns3/error-model.h" |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
28 |
#include "ns3/enum.h" |
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
29 |
#include "ns3/boolean.h" |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
30 |
#include "ns3/uinteger.h" |
2927
73b47ce1d805
get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
31 |
#include "ns3/pointer.h" |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
32 |
#include "ns3/trace-source-accessor.h" |
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
33 |
#include "csma-net-device.h" |
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
34 |
#include "csma-channel.h" |
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
35 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
36 |
NS_LOG_COMPONENT_DEFINE ("CsmaNetDevice"); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
37 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
38 |
namespace ns3 { |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
39 |
|
2501
3eaeac1dd5ed
add missing NS_OBJECT_ENSURE_REGISTERED calls.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
40 |
NS_OBJECT_ENSURE_REGISTERED (CsmaNetDevice); |
3eaeac1dd5ed
add missing NS_OBJECT_ENSURE_REGISTERED calls.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
41 |
|
3504 | 42 |
TypeId |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
43 |
CsmaNetDevice::GetTypeId (void) |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
44 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2600
diff
changeset
|
45 |
static TypeId tid = TypeId ("ns3::CsmaNetDevice") |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
46 |
.SetParent<NetDevice> () |
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
47 |
.AddConstructor<CsmaNetDevice> () |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
48 |
.AddAttribute ("Address", |
3504 | 49 |
"The MAC address of this device.", |
50 |
Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")), |
|
51 |
MakeMac48AddressAccessor (&CsmaNetDevice::m_address), |
|
52 |
MakeMac48AddressChecker ()) |
|
6183
8a5e1f9db873
[bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5894
diff
changeset
|
53 |
.AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit", |
8a5e1f9db873
[bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5894
diff
changeset
|
54 |
UintegerValue (DEFAULT_MTU), |
8a5e1f9db873
[bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5894
diff
changeset
|
55 |
MakeUintegerAccessor (&CsmaNetDevice::SetMtu, |
8a5e1f9db873
[bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5894
diff
changeset
|
56 |
&CsmaNetDevice::GetMtu), |
3504 | 57 |
MakeUintegerChecker<uint16_t> ()) |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
58 |
.AddAttribute ("EncapsulationMode", |
3504 | 59 |
"The link-layer encapsulation type to use.", |
3633 | 60 |
EnumValue (DIX), |
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
61 |
MakeEnumAccessor (&CsmaNetDevice::SetEncapsulationMode), |
3629 | 62 |
MakeEnumChecker (DIX, "Dix", |
3504 | 63 |
LLC, "Llc")) |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
64 |
.AddAttribute ("SendEnable", |
3504 | 65 |
"Enable or disable the transmitter section of the device.", |
66 |
BooleanValue (true), |
|
67 |
MakeBooleanAccessor (&CsmaNetDevice::m_sendEnable), |
|
68 |
MakeBooleanChecker ()) |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
69 |
.AddAttribute ("ReceiveEnable", |
3504 | 70 |
"Enable or disable the receiver section of the device.", |
71 |
BooleanValue (true), |
|
72 |
MakeBooleanAccessor (&CsmaNetDevice::m_receiveEnable), |
|
73 |
MakeBooleanChecker ()) |
|
3861
dacfd1f07538
change attribute ReceiveErrorModel in CSMA and rescan
Craig Dowell <craigdo@ee.washington.edu>
parents:
3852
diff
changeset
|
74 |
.AddAttribute ("ReceiveErrorModel", |
3504 | 75 |
"The receiver error model used to simulate packet loss", |
76 |
PointerValue (), |
|
77 |
MakePointerAccessor (&CsmaNetDevice::m_receiveErrorModel), |
|
78 |
MakePointerChecker<ErrorModel> ()) |
|
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
79 |
|
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
80 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
81 |
// Transmit queueing discipline for the device which includes its own set |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
82 |
// of trace hooks. |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
83 |
// |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
84 |
.AddAttribute ("TxQueue", |
3504 | 85 |
"A queue to use as the transmit queue in the device.", |
86 |
PointerValue (), |
|
87 |
MakePointerAccessor (&CsmaNetDevice::m_queue), |
|
88 |
MakePointerChecker<Queue> ()) |
|
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
89 |
|
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
90 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
91 |
// Trace sources at the "top" of the net device, where packets transition |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
92 |
// to/from higher layers. |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
93 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
94 |
.AddTraceSource ("MacTx", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
95 |
"Trace source indicating a packet has arrived for transmission by this device", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
96 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxTrace)) |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
97 |
.AddTraceSource ("MacTxDrop", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
98 |
"Trace source indicating a packet has been dropped by the device before transmission", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
99 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxDropTrace)) |
4272
b40ce56e0247
Add MacPromiscRx, make MacRx non-promisc
Craig Dowell <craigdo@ee.washington.edu>
parents:
4265
diff
changeset
|
100 |
.AddTraceSource ("MacPromiscRx", |
b40ce56e0247
Add MacPromiscRx, make MacRx non-promisc
Craig Dowell <craigdo@ee.washington.edu>
parents:
4265
diff
changeset
|
101 |
"A packet has been received by this device, has been passed up from the physical layer " |
b40ce56e0247
Add MacPromiscRx, make MacRx non-promisc
Craig Dowell <craigdo@ee.washington.edu>
parents:
4265
diff
changeset
|
102 |
"and is being forwarded up the local protocol stack. This is a promiscuous trace,", |
b40ce56e0247
Add MacPromiscRx, make MacRx non-promisc
Craig Dowell <craigdo@ee.washington.edu>
parents:
4265
diff
changeset
|
103 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macPromiscRxTrace)) |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
104 |
.AddTraceSource ("MacRx", |
4272
b40ce56e0247
Add MacPromiscRx, make MacRx non-promisc
Craig Dowell <craigdo@ee.washington.edu>
parents:
4265
diff
changeset
|
105 |
"A packet has been received by this device, has been passed up from the physical layer " |
b40ce56e0247
Add MacPromiscRx, make MacRx non-promisc
Craig Dowell <craigdo@ee.washington.edu>
parents:
4265
diff
changeset
|
106 |
"and is being forwarded up the local protocol stack. This is a non-promiscuous trace,", |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
107 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macRxTrace)) |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
108 |
#if 0 |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
109 |
// Not currently implemented in this device |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
110 |
.AddTraceSource ("MacRxDrop", |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
111 |
"Trace source indicating a packet was received, but dropped before being forwarded up the stack", |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
112 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macRxDropTrace)) |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
113 |
#endif |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
114 |
.AddTraceSource ("MacTxBackoff", |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
115 |
"Trace source indicating a packet has been delayed by the CSMA backoff process", |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
116 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxBackoffTrace)) |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
117 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
118 |
// Trace souces at the "bottom" of the net device, where packets transition |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
119 |
// to/from the channel. |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
120 |
// |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
121 |
.AddTraceSource ("PhyTxBegin", |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
122 |
"Trace source indicating a packet has begun transmitting over the channel", |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
123 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxBeginTrace)) |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
124 |
.AddTraceSource ("PhyTxEnd", |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
125 |
"Trace source indicating a packet has been completely transmitted over the channel", |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
126 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxEndTrace)) |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
127 |
.AddTraceSource ("PhyTxDrop", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
128 |
"Trace source indicating a packet has been dropped by the device during transmission", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
129 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxDropTrace)) |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
130 |
#if 0 |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
131 |
// Not currently implemented in this device |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
132 |
.AddTraceSource ("PhyRxBegin", |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
133 |
"Trace source indicating a packet has begun being received by the device", |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
134 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxBeginTrace)) |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
135 |
#endif |
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
136 |
.AddTraceSource ("PhyRxEnd", |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
137 |
"Trace source indicating a packet has been completely received by the device", |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
138 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxEndTrace)) |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
139 |
.AddTraceSource ("PhyRxDrop", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
140 |
"Trace source indicating a packet has been dropped by the device during reception", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
141 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxDropTrace)) |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
142 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
143 |
// Trace sources designed to simulate a packet sniffer facility (tcpdump). |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
144 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
145 |
.AddTraceSource ("Sniffer", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
146 |
"Trace source simulating a non-promiscuous packet sniffer attached to the device", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
147 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_snifferTrace)) |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
148 |
.AddTraceSource ("PromiscSniffer", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
149 |
"Trace source simulating a promiscuous packet sniffer attached to the device", |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
150 |
MakeTraceSourceAccessor (&CsmaNetDevice::m_promiscSnifferTrace)) |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
151 |
; |
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
152 |
return tid; |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1209
diff
changeset
|
153 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
154 |
|
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
155 |
CsmaNetDevice::CsmaNetDevice () |
4322
bad9eed19283
bug 498: Object Name Service Obsoletes Legacy Naming
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4272
diff
changeset
|
156 |
: m_linkUp (false) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
157 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
158 |
NS_LOG_FUNCTION (this); |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
159 |
m_txMachineState = READY; |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
160 |
m_tInterframeGap = Seconds (0); |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
161 |
m_channel = 0; |
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
162 |
|
3630
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
163 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
164 |
// We would like to let the attribute system take care of initializing the |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
165 |
// packet encapsulation stuff, but we also don't want to get caught up in |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
166 |
// initialization order changes. So we'll get the three problem variables |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
167 |
// into a consistent state here before the attribute calls, and then depend |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
168 |
// on the semantics of the setters to preserve a consistent state. This |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
169 |
// really doesn't have to be the same set of values as the initial values |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
170 |
// set by the attributes, but it does have to be a consistent set. That is, |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
171 |
// you can just change the default encapsulation mode above without having |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
172 |
// to change it here. |
3630
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
173 |
// |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
174 |
m_encapMode = DIX; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
175 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
176 |
|
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
177 |
CsmaNetDevice::~CsmaNetDevice() |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
178 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
179 |
NS_LOG_FUNCTION_NOARGS (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
180 |
m_queue = 0; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
181 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
182 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
183 |
void |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
184 |
CsmaNetDevice::DoDispose () |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
185 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
186 |
NS_LOG_FUNCTION_NOARGS (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
187 |
m_channel = 0; |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
188 |
m_node = 0; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
189 |
NetDevice::DoDispose (); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
190 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
191 |
|
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
192 |
void |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
193 |
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode) |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
194 |
{ |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
195 |
NS_LOG_FUNCTION (mode); |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
196 |
|
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
197 |
m_encapMode = mode; |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
198 |
|
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
199 |
NS_LOG_LOGIC ("m_encapMode = " << m_encapMode); |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
200 |
NS_LOG_LOGIC ("m_mtu = " << m_mtu); |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
201 |
} |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
202 |
|
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
203 |
CsmaNetDevice::EncapsulationMode |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
204 |
CsmaNetDevice::GetEncapsulationMode (void) |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
205 |
{ |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
206 |
NS_LOG_FUNCTION_NOARGS (); |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
207 |
return m_encapMode; |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
208 |
} |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
209 |
|
6183
8a5e1f9db873
[bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5894
diff
changeset
|
210 |
bool |
3629 | 211 |
CsmaNetDevice::SetMtu (uint16_t mtu) |
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
212 |
{ |
6183
8a5e1f9db873
[bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5894
diff
changeset
|
213 |
NS_LOG_FUNCTION (this << mtu); |
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
214 |
m_mtu = mtu; |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
215 |
|
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
216 |
NS_LOG_LOGIC ("m_encapMode = " << m_encapMode); |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
217 |
NS_LOG_LOGIC ("m_mtu = " << m_mtu); |
3629 | 218 |
|
219 |
return true; |
|
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
220 |
} |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
221 |
|
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
222 |
uint16_t |
3629 | 223 |
CsmaNetDevice::GetMtu (void) const |
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
224 |
{ |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
225 |
NS_LOG_FUNCTION_NOARGS (); |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
226 |
return m_mtu; |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
227 |
} |
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
228 |
|
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
229 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
230 |
void |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
231 |
CsmaNetDevice::SetSendEnable (bool sendEnable) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
232 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
233 |
NS_LOG_FUNCTION (sendEnable); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
234 |
m_sendEnable = sendEnable; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
235 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
236 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
237 |
void |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
238 |
CsmaNetDevice::SetReceiveEnable (bool receiveEnable) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
239 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
240 |
NS_LOG_FUNCTION (receiveEnable); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
241 |
m_receiveEnable = receiveEnable; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
242 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
243 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
244 |
bool |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
245 |
CsmaNetDevice::IsSendEnabled (void) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
246 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
247 |
NS_LOG_FUNCTION_NOARGS (); |
3504 | 248 |
return m_sendEnable; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
249 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
250 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
251 |
bool |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
252 |
CsmaNetDevice::IsReceiveEnabled (void) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
253 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
254 |
NS_LOG_FUNCTION_NOARGS (); |
3504 | 255 |
return m_receiveEnable; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
256 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
257 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
258 |
void |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
259 |
CsmaNetDevice::SetInterframeGap (Time t) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
260 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
261 |
NS_LOG_FUNCTION (t); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
262 |
m_tInterframeGap = t; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
263 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
264 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
265 |
void |
3504 | 266 |
CsmaNetDevice::SetBackoffParams (Time slotTime, uint32_t minSlots, uint32_t maxSlots, uint32_t ceiling, uint32_t maxRetries) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
267 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
268 |
NS_LOG_FUNCTION (slotTime << minSlots << maxSlots << ceiling << maxRetries); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
269 |
m_backoff.m_slotTime = slotTime; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
270 |
m_backoff.m_minSlots = minSlots; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
271 |
m_backoff.m_maxSlots = maxSlots; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
272 |
m_backoff.m_ceiling = ceiling; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
273 |
m_backoff.m_maxRetries = maxRetries; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
274 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
275 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
276 |
void |
3504 | 277 |
CsmaNetDevice::AddHeader (Ptr<Packet> p, Mac48Address source, Mac48Address dest, uint16_t protocolNumber) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
278 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
279 |
NS_LOG_FUNCTION (p << source << dest << protocolNumber); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
280 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
281 |
EthernetHeader header (false); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
282 |
header.SetSource (source); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
283 |
header.SetDestination (dest); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
284 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
285 |
EthernetTrailer trailer; |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
286 |
|
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
287 |
NS_LOG_LOGIC ("p->GetSize () = " << p->GetSize ()); |
3506
cba7b2b80fe8
sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents:
3504
diff
changeset
|
288 |
NS_LOG_LOGIC ("m_encapMode = " << m_encapMode); |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
289 |
NS_LOG_LOGIC ("m_mtu = " << m_mtu); |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
290 |
|
1001
33cf9c56e3cd
Fix lengthType initialization for optimized build
Tom Henderson <tomh@tomh.org>
parents:
997
diff
changeset
|
291 |
uint16_t lengthType = 0; |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
292 |
switch (m_encapMode) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
293 |
{ |
3629 | 294 |
case DIX: |
3630
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
295 |
NS_LOG_LOGIC ("Encapsulating packet as DIX (type interpretation)"); |
3504 | 296 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
297 |
// This corresponds to the type interpretation of the lengthType field as |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
298 |
// in the old Ethernet Blue Book. |
3504 | 299 |
// |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
300 |
lengthType = protocolNumber; |
5833
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
301 |
|
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
302 |
// |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
303 |
// All Ethernet frames must carry a minimum payload of 46 bytes. We need |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
304 |
// to pad out if we don't have enough bytes. These must be real bytes |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
305 |
// since they will be written to pcap files and compared in regression |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
306 |
// trace files. |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
307 |
// |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
308 |
if (p->GetSize () < 46) |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
309 |
{ |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
310 |
uint8_t buffer[46]; |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
311 |
memset (buffer, 0, 46); |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
312 |
Ptr<Packet> padd = Create<Packet> (buffer, 46 - p->GetSize ()); |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
313 |
p->AddAtEnd (padd); |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
314 |
} |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
315 |
break; |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
316 |
case LLC: |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
317 |
{ |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
318 |
NS_LOG_LOGIC ("Encapsulating packet as LLC (length interpretation)"); |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
319 |
|
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
320 |
LlcSnapHeader llc; |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
321 |
llc.SetType (protocolNumber); |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
322 |
p->AddHeader (llc); |
5833
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
323 |
|
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
324 |
// |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
325 |
// All Ethernet frames must carry a minimum payload of 46 bytes. The |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
326 |
// LLC SNAP header counts as part of this payload. We need to padd out |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
327 |
// if we don't have enough bytes. These must be real bytes since they |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
328 |
// will be written to pcap files and compared in regression trace files. |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
329 |
// |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
330 |
if (p->GetSize () < 46) |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
331 |
{ |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
332 |
uint8_t buffer[46]; |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
333 |
memset (buffer, 0, 46); |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
334 |
Ptr<Packet> padd = Create<Packet> (buffer, 46 - p->GetSize ()); |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
335 |
p->AddAtEnd (padd); |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
336 |
} |
aa78abc9c10d
padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents:
5832
diff
changeset
|
337 |
|
3504 | 338 |
// |
339 |
// This corresponds to the length interpretation of the lengthType field, |
|
3630
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
340 |
// but with an LLC/SNAP header added to the payload as in IEEE 802.2 |
3504 | 341 |
// |
3477
80aae4bb8c39
fix supidity in mtu stuff
Craig Dowell <craigdo@ee.washington.edu>
parents:
3476
diff
changeset
|
342 |
lengthType = p->GetSize (); |
6183
8a5e1f9db873
[bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5894
diff
changeset
|
343 |
NS_ASSERT_MSG (lengthType <= GetMtu (), |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
344 |
"CsmaNetDevice::AddHeader(): 802.3 Length/Type field with LLC/SNAP: " |
3629 | 345 |
"length interpretation must not exceed device frame size minus overhead"); |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
346 |
} |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
347 |
break; |
3630
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
348 |
case ILLEGAL: |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
349 |
default: |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
350 |
NS_FATAL_ERROR ("CsmaNetDevice::AddHeader(): Unknown packet encapsulation mode"); |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
351 |
break; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
352 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
353 |
|
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
354 |
NS_LOG_LOGIC ("header.SetLengthType (" << lengthType << ")"); |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
355 |
header.SetLengthType (lengthType); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
356 |
p->AddHeader (header); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
357 |
|
5831
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
358 |
if (Node::ChecksumEnabled ()) |
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
359 |
{ |
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
360 |
trailer.EnableFcs (true); |
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
361 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
362 |
trailer.CalcFcs (p); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
363 |
p->AddTrailer (trailer); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
364 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
365 |
|
5832
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
366 |
#if 0 |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
367 |
bool |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1504
diff
changeset
|
368 |
CsmaNetDevice::ProcessHeader (Ptr<Packet> p, uint16_t & param) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
369 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
370 |
NS_LOG_FUNCTION (p << param); |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
371 |
|
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
372 |
EthernetTrailer trailer; |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
373 |
p->RemoveTrailer (trailer); |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
374 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
375 |
EthernetHeader header (false); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
376 |
p->RemoveHeader (header); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
377 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
378 |
if ((header.GetDestination () != GetBroadcast ()) && |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
379 |
(header.GetDestination () != GetAddress ())) |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
380 |
{ |
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
381 |
return false; |
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
382 |
} |
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
383 |
|
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
384 |
switch (m_encapMode) |
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
385 |
{ |
3629 | 386 |
case DIX: |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
387 |
param = header.GetLengthType (); |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
388 |
break; |
3630
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
389 |
case LLC: |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
390 |
{ |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
391 |
LlcSnapHeader llc; |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
392 |
p->RemoveHeader (llc); |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
393 |
param = llc.GetType (); |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
394 |
} |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
395 |
break; |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
396 |
case ILLEGAL: |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
397 |
default: |
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
398 |
NS_FATAL_ERROR ("CsmaNetDevice::ProcessHeader(): Unknown packet encapsulation mode"); |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
399 |
break; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
400 |
} |
995
22821dd9152e
param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
993
diff
changeset
|
401 |
return true; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
402 |
} |
5832
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
403 |
#endif |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
404 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
405 |
void |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
406 |
CsmaNetDevice::TransmitStart (void) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
407 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
408 |
NS_LOG_FUNCTION_NOARGS (); |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
409 |
|
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
410 |
// |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
411 |
// This function is called to start the process of transmitting a packet. We |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
412 |
// expect that the packet to transmit will be found in m_currentPkt. |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
413 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
414 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitStart(): m_currentPkt not set"); |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
415 |
|
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
416 |
NS_LOG_LOGIC ("m_currentPkt = " << m_currentPkt); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
417 |
NS_LOG_LOGIC ("UID = " << m_currentPkt->GetUid ()); |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
418 |
|
3504 | 419 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
420 |
// Only transmit if the send side of net device is enabled |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
421 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
422 |
if (IsSendEnabled () == false) |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
423 |
{ |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
424 |
m_phyTxDropTrace (m_currentPkt); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
425 |
m_currentPkt = 0; |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
426 |
return; |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
427 |
} |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
428 |
|
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
429 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
430 |
// Somebody has called here telling us to start transmitting a packet. They |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
431 |
// can only do this if the state machine is in the READY or BACKOFF state. |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
432 |
// Specifically, if we are ready to start transmitting, we cannot already |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
433 |
// be transmitting (i.e., BUSY) |
3504 | 434 |
// |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
435 |
NS_ASSERT_MSG ((m_txMachineState == READY) || (m_txMachineState == BACKOFF), |
3504 | 436 |
"Must be READY to transmit. Tx state is: " << m_txMachineState); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
437 |
|
3504 | 438 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
439 |
// Now we have to sense the state of the medium and either start transmitting |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
440 |
// if it is idle, or backoff our transmission if someone else is on the wire. |
3504 | 441 |
// |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
442 |
if (m_channel->GetState () != IDLE) |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
443 |
{ |
3504 | 444 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
445 |
// The channel is busy -- backoff and rechedule TransmitStart() unless |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
446 |
// we have exhausted all of our retries. |
3504 | 447 |
// |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
448 |
m_txMachineState = BACKOFF; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
449 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
450 |
if (m_backoff.MaxRetriesReached ()) |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
451 |
{ |
3504 | 452 |
// |
453 |
// Too many retries, abort transmission of packet |
|
454 |
// |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
455 |
TransmitAbort (); |
997
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
456 |
} |
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
457 |
else |
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
458 |
{ |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
459 |
m_macTxBackoffTrace (m_currentPkt); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
460 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
461 |
m_backoff.IncrNumRetries (); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
462 |
Time backoffTime = m_backoff.GetBackoffTime (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
463 |
|
3504 | 464 |
NS_LOG_LOGIC ("Channel busy, backing off for " << backoffTime.GetSeconds () << " sec"); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
465 |
|
3504 | 466 |
Simulator::Schedule (backoffTime, &CsmaNetDevice::TransmitStart, this); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
467 |
} |
997
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
468 |
} |
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
469 |
else |
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
470 |
{ |
3504 | 471 |
// |
472 |
// The channel is free, transmit the packet |
|
473 |
// |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
474 |
if (m_channel->TransmitStart (m_currentPkt, m_deviceId) == false) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
475 |
{ |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
476 |
NS_LOG_WARN ("Channel TransmitStart returns an error"); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
477 |
m_phyTxDropTrace (m_currentPkt); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
478 |
m_currentPkt = 0; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
479 |
m_txMachineState = READY; |
997
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
480 |
} |
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
481 |
else |
d95ffcec6523
fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
995
diff
changeset
|
482 |
{ |
3504 | 483 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
484 |
// Transmission succeeded, reset the backoff time parameters and |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
485 |
// schedule a transmit complete event. |
3504 | 486 |
// |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
487 |
m_backoff.ResetBackoffTime (); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
488 |
m_txMachineState = BUSY; |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
489 |
m_phyTxBeginTrace (m_currentPkt); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
490 |
|
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
491 |
Time tEvent = Seconds (m_bps.CalculateTxTime (m_currentPkt->GetSize ())); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
492 |
NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << tEvent.GetSeconds () << "sec"); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
493 |
Simulator::Schedule (tEvent, &CsmaNetDevice::TransmitCompleteEvent, this); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
494 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
495 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
496 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
497 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
498 |
void |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
499 |
CsmaNetDevice::TransmitAbort (void) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
500 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
501 |
NS_LOG_FUNCTION_NOARGS (); |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
502 |
|
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
503 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
504 |
// When we started the process of transmitting the current packet, it was |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
505 |
// placed in m_currentPkt. So we had better find one there. |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
506 |
// |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
507 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitAbort(): m_currentPkt zero"); |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
508 |
NS_LOG_LOGIC ("m_currentPkt=" << m_currentPkt); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1504
diff
changeset
|
509 |
NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt->GetUid () << ")"); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
510 |
|
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
511 |
m_phyTxDropTrace (m_currentPkt); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
512 |
m_currentPkt = 0; |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
513 |
|
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
514 |
NS_ASSERT_MSG (m_txMachineState == BACKOFF, "Must be in BACKOFF state to abort. Tx state is: " << m_txMachineState); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
515 |
|
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
516 |
// |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
517 |
// We're done with that one, so reset the backoff algorithm and ready the |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
518 |
// transmit state machine. |
3504 | 519 |
// |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
520 |
m_backoff.ResetBackoffTime (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
521 |
m_txMachineState = READY; |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
522 |
|
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
523 |
// |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
524 |
// If there is another packet on the input queue, we need to start trying to |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
525 |
// get that out. If the queue is empty we just wait until someone puts one |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
526 |
// in. |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
527 |
// |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
528 |
if (m_queue->IsEmpty ()) |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
529 |
{ |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
530 |
return; |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
531 |
} |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
532 |
else |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
533 |
{ |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
534 |
m_currentPkt = m_queue->Dequeue (); |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
535 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitAbort(): IsEmpty false but no Packet on queue?"); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
536 |
m_snifferTrace (m_currentPkt); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
537 |
m_promiscSnifferTrace (m_currentPkt); |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
538 |
TransmitStart (); |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
539 |
} |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
540 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
541 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
542 |
void |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
543 |
CsmaNetDevice::TransmitCompleteEvent (void) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
544 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
545 |
NS_LOG_FUNCTION_NOARGS (); |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
546 |
|
3504 | 547 |
// |
548 |
// This function is called to finish the process of transmitting a packet. |
|
549 |
// We need to tell the channel that we've stopped wiggling the wire and |
|
550 |
// schedule an event that will be executed when it's time to re-enable |
|
551 |
// the transmitter after the interframe gap. |
|
552 |
// |
|
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
553 |
NS_ASSERT_MSG (m_txMachineState == BUSY, "CsmaNetDevice::transmitCompleteEvent(): Must be BUSY if transmitting"); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
554 |
NS_ASSERT (m_channel->GetState () == TRANSMITTING); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
555 |
m_txMachineState = GAP; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
556 |
|
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
557 |
// |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
558 |
// When we started transmitting the current packet, it was placed in |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
559 |
// m_currentPkt. So we had better find one there. |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
560 |
// |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
561 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitCompleteEvent(): m_currentPkt zero"); |
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
562 |
NS_LOG_LOGIC ("m_currentPkt=" << m_currentPkt); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1504
diff
changeset
|
563 |
NS_LOG_LOGIC ("Pkt UID is " << m_currentPkt->GetUid () << ")"); |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
564 |
|
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
565 |
m_channel->TransmitEnd (); |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
566 |
m_phyTxEndTrace (m_currentPkt); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
567 |
m_currentPkt = 0; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
568 |
|
3504 | 569 |
NS_LOG_LOGIC ("Schedule TransmitReadyEvent in " << m_tInterframeGap.GetSeconds () << "sec"); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
570 |
|
3504 | 571 |
Simulator::Schedule (m_tInterframeGap, &CsmaNetDevice::TransmitReadyEvent, this); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
572 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
573 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
574 |
void |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
575 |
CsmaNetDevice::TransmitReadyEvent (void) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
576 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
577 |
NS_LOG_FUNCTION_NOARGS (); |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
578 |
|
3504 | 579 |
// |
580 |
// This function is called to enable the transmitter after the interframe |
|
581 |
// gap has passed. If there are pending transmissions, we use this opportunity |
|
582 |
// to start the next transmit. |
|
583 |
// |
|
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
584 |
NS_ASSERT_MSG (m_txMachineState == GAP, "CsmaNetDevice::TransmitReadyEvent(): Must be in interframe gap"); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
585 |
m_txMachineState = READY; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
586 |
|
3504 | 587 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
588 |
// We expect that the packet we had been transmitting was cleared when the |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
589 |
// TransmitCompleteEvent() was executed. |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
590 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
591 |
NS_ASSERT_MSG (m_currentPkt == 0, "CsmaNetDevice::TransmitReadyEvent(): m_currentPkt nonzero"); |
4197
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
592 |
|
3aca059abe63
clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents:
4170
diff
changeset
|
593 |
// |
3504 | 594 |
// Get the next packet from the queue for transmitting |
595 |
// |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
596 |
if (m_queue->IsEmpty ()) |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
597 |
{ |
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
598 |
return; |
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
599 |
} |
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
600 |
else |
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
601 |
{ |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1504
diff
changeset
|
602 |
m_currentPkt = m_queue->Dequeue (); |
3504 | 603 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::TransmitReadyEvent(): IsEmpty false but no Packet on queue?"); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
604 |
m_snifferTrace (m_currentPkt); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
605 |
m_promiscSnifferTrace (m_currentPkt); |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
606 |
TransmitStart (); |
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
607 |
} |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
608 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
609 |
|
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
610 |
bool |
1276
e0b88ec7a6be
merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents:
1270
diff
changeset
|
611 |
CsmaNetDevice::Attach (Ptr<CsmaChannel> ch) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
612 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
613 |
NS_LOG_FUNCTION (this << &ch); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
614 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
615 |
m_channel = ch; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
616 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
617 |
m_deviceId = m_channel->Attach (this); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
618 |
|
3504 | 619 |
// |
620 |
// The channel provides us with the transmitter data rate. |
|
621 |
// |
|
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
622 |
m_bps = m_channel->GetDataRate (); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
623 |
|
3504 | 624 |
// |
625 |
// We use the Ethernet interframe gap of 96 bit times. |
|
626 |
// |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
627 |
m_tInterframeGap = Seconds (m_bps.CalculateTxTime (96/8)); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
628 |
|
3504 | 629 |
// |
630 |
// This device is up whenever a channel is attached to it. |
|
631 |
// |
|
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
632 |
NotifyLinkUp (); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
633 |
return true; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
634 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
635 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
636 |
void |
3011
2d507430219e
bug 153 applied to CSMA
Craig Dowell <craigdo@ee.washington.edu>
parents:
2989
diff
changeset
|
637 |
CsmaNetDevice::SetQueue (Ptr<Queue> q) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
638 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
639 |
NS_LOG_FUNCTION (q); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
640 |
m_queue = q; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
641 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
642 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
643 |
void |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
644 |
CsmaNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
645 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
646 |
NS_LOG_FUNCTION (em); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
647 |
m_receiveErrorModel = em; |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
648 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
649 |
|
3504 | 650 |
void |
3447
48f371a8ae8e
Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr<CsmaNetDevice> parameter in Receive(). As discussed in the mailing list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3446
diff
changeset
|
651 |
CsmaNetDevice::Receive (Ptr<Packet> packet, Ptr<CsmaNetDevice> senderDevice) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
652 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
653 |
NS_LOG_FUNCTION (packet << senderDevice); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
654 |
NS_LOG_LOGIC ("UID is " << packet->GetUid ()); |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
655 |
|
3504 | 656 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
657 |
// We never forward up packets that we sent. Real devices don't do this since |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
658 |
// their receivers are disabled during send, so we don't. |
3504 | 659 |
// |
3447
48f371a8ae8e
Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr<CsmaNetDevice> parameter in Receive(). As discussed in the mailing list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3446
diff
changeset
|
660 |
if (senderDevice == this) |
48f371a8ae8e
Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr<CsmaNetDevice> parameter in Receive(). As discussed in the mailing list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3446
diff
changeset
|
661 |
{ |
48f371a8ae8e
Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr<CsmaNetDevice> parameter in Receive(). As discussed in the mailing list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3446
diff
changeset
|
662 |
return; |
48f371a8ae8e
Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr<CsmaNetDevice> parameter in Receive(). As discussed in the mailing list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3446
diff
changeset
|
663 |
} |
48f371a8ae8e
Move the csma packet-from-self receive filtering away from the CsmaChannel into the CsmaNetDevice, with the help of an extra Ptr<CsmaNetDevice> parameter in Receive(). As discussed in the mailing list.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3446
diff
changeset
|
664 |
|
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
665 |
// |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
666 |
// Hit the trace hook. This trace will fire on all packets received from the |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
667 |
// channel except those originated by this device. |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
668 |
// |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4263
diff
changeset
|
669 |
m_phyRxEndTrace (packet); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
670 |
|
3504 | 671 |
// |
672 |
// Only receive if the send side of net device is enabled |
|
673 |
// |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
674 |
if (IsReceiveEnabled () == false) |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
675 |
{ |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
676 |
m_phyRxDropTrace (packet); |
1210
599a311daef6
fix opt warnings, let compiler do tail call optimization in csma nd, remove protected access from router iface
Craig Dowell <craigdo@ee.washington.edu>
parents:
1209
diff
changeset
|
677 |
return; |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
678 |
} |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
679 |
|
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
680 |
if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) ) |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
681 |
{ |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
682 |
NS_LOG_LOGIC ("Dropping pkt due to error model "); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
683 |
m_phyRxDropTrace (packet); |
6786
17f9a64dd4f6
bugfix: CsmaNetDevice ErrorModel not discarding packet (reported by Rafal Mielniczuk)
Tom Henderson <tomh@tomh.org>
parents:
6183
diff
changeset
|
684 |
return; |
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
685 |
} |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
686 |
|
3504 | 687 |
// |
688 |
// Trace sinks will expect complete packets, not packets without some of the |
|
689 |
// headers. |
|
690 |
// |
|
3326
239c4bc21ebf
reposition trace hook in csma to address bug 241.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3257
diff
changeset
|
691 |
Ptr<Packet> originalPacket = packet->Copy (); |
239c4bc21ebf
reposition trace hook in csma to address bug 241.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3257
diff
changeset
|
692 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
693 |
EthernetTrailer trailer; |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
694 |
packet->RemoveTrailer (trailer); |
5831
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
695 |
if (Node::ChecksumEnabled ()) |
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
696 |
{ |
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
697 |
trailer.EnableFcs (true); |
3fda006341e6
Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents:
4764
diff
changeset
|
698 |
} |
5832
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
699 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
700 |
trailer.CheckFcs (packet); |
5832
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
701 |
bool crcGood = trailer.CheckFcs (packet); |
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
702 |
if (!crcGood) |
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
703 |
{ |
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
704 |
NS_LOG_INFO ("CRC error on Packet " << packet); |
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
705 |
m_phyRxDropTrace (packet); |
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
706 |
return; |
2812b92d4888
Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents:
5831
diff
changeset
|
707 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
708 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
709 |
EthernetHeader header (false); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
710 |
packet->RemoveHeader (header); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
711 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
712 |
NS_LOG_LOGIC ("Pkt source is " << header.GetSource ()); |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
713 |
NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ()); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
714 |
|
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
715 |
uint16_t protocol; |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
716 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
717 |
// If the length/type is less than 1500, it corresponds to a length |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
718 |
// interpretation packet. In this case, it is an 802.3 packet and |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
719 |
// will also have an 802.2 LLC header. If greater than 1500, we |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
720 |
// find the protocol number (Ethernet type) directly. |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
721 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
722 |
if (header.GetLengthType () <= 1500) |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
723 |
{ |
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
724 |
LlcSnapHeader llc; |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
725 |
packet->RemoveHeader (llc); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
726 |
protocol = llc.GetType (); |
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
727 |
} |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
728 |
else |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
729 |
{ |
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
730 |
protocol = header.GetLengthType (); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
731 |
} |
3438
86e262420fbf
Implement the promiscuous receive callback for CsmaNetDevice.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3436
diff
changeset
|
732 |
|
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
733 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
734 |
// Classify the packet based on its destination. |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
735 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
736 |
PacketType packetType; |
4424
af26433b13bc
remove Mac48Address::IsMulticast
Fabian Mauchle <f1mauchl@hsr.ch>
parents:
4322
diff
changeset
|
737 |
|
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
738 |
if (header.GetDestination ().IsBroadcast ()) |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
739 |
{ |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
740 |
packetType = PACKET_BROADCAST; |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
741 |
} |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
742 |
else if (header.GetDestination ().IsGroup ()) |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
743 |
{ |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
744 |
packetType = PACKET_MULTICAST; |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
745 |
} |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
746 |
else if (header.GetDestination () == m_address) |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
747 |
{ |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
748 |
packetType = PACKET_HOST; |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
749 |
} |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
750 |
else |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
751 |
{ |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
752 |
packetType = PACKET_OTHERHOST; |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
753 |
} |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
754 |
|
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
755 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
756 |
// For all kinds of packetType we receive, we hit the promiscuous sniffer |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
757 |
// hook and pass a copy up to the promiscuous callback. Pass a copy to |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
758 |
// make sure that nobody messes with our packet. |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
759 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
760 |
m_promiscSnifferTrace (originalPacket); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
761 |
if (!m_promiscRxCallback.IsNull ()) |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
762 |
{ |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
763 |
m_macPromiscRxTrace (originalPacket); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
764 |
m_promiscRxCallback (this, packet, protocol, header.GetSource (), header.GetDestination (), packetType); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
765 |
} |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
766 |
|
5894
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
767 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
768 |
// If this packet is not destined for some other host, it must be for us |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
769 |
// as either a broadcast, multicast or unicast. We need to hit the mac |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
770 |
// packet received trace hook and forward the packet up the stack. |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
771 |
// |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
772 |
if (packetType != PACKET_OTHERHOST) |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
773 |
{ |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
774 |
m_snifferTrace (originalPacket); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
775 |
m_macRxTrace (originalPacket); |
7f709d2bdf84
Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents:
5833
diff
changeset
|
776 |
m_rxCallback (this, packet, protocol, header.GetSource ()); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
777 |
} |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
778 |
} |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
779 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
780 |
Ptr<Queue> |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
781 |
CsmaNetDevice::GetQueue (void) const |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
782 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
783 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
784 |
return m_queue; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
785 |
} |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
786 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
787 |
void |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
788 |
CsmaNetDevice::NotifyLinkUp (void) |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
789 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
790 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
791 |
m_linkUp = true; |
4764
e90e1ef585b0
[Bug 653] NetDevice link change callback (SetLinkChangeCallback -> AddLinkChangeCallback).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4578
diff
changeset
|
792 |
m_linkChangeCallbacks (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
793 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
794 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
795 |
void |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
796 |
CsmaNetDevice::SetIfIndex (const uint32_t index) |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
797 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
798 |
NS_LOG_FUNCTION (index); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
799 |
m_ifIndex = index; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
800 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
801 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
802 |
uint32_t |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
803 |
CsmaNetDevice::GetIfIndex (void) const |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
804 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
805 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
806 |
return m_ifIndex; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
807 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
808 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
809 |
Ptr<Channel> |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
810 |
CsmaNetDevice::GetChannel (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
811 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
812 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
813 |
return m_channel; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
814 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
815 |
|
4578
88434ff8f0a5
Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4444
diff
changeset
|
816 |
void |
88434ff8f0a5
Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4444
diff
changeset
|
817 |
CsmaNetDevice::SetAddress (Address address) |
88434ff8f0a5
Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4444
diff
changeset
|
818 |
{ |
88434ff8f0a5
Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4444
diff
changeset
|
819 |
NS_LOG_FUNCTION_NOARGS (); |
88434ff8f0a5
Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4444
diff
changeset
|
820 |
m_address = Mac48Address::ConvertFrom (address); |
88434ff8f0a5
Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4444
diff
changeset
|
821 |
} |
88434ff8f0a5
Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents:
4444
diff
changeset
|
822 |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
823 |
Address |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
824 |
CsmaNetDevice::GetAddress (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
825 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
826 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
827 |
return m_address; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
828 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
829 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
830 |
bool |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
831 |
CsmaNetDevice::IsLinkUp (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
832 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
833 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
834 |
return m_linkUp; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
835 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
836 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
837 |
void |
4764
e90e1ef585b0
[Bug 653] NetDevice link change callback (SetLinkChangeCallback -> AddLinkChangeCallback).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4578
diff
changeset
|
838 |
CsmaNetDevice::AddLinkChangeCallback (Callback<void> callback) |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
839 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
840 |
NS_LOG_FUNCTION (&callback); |
4764
e90e1ef585b0
[Bug 653] NetDevice link change callback (SetLinkChangeCallback -> AddLinkChangeCallback).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4578
diff
changeset
|
841 |
m_linkChangeCallbacks.ConnectWithoutContext (callback); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
842 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
843 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
844 |
bool |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
845 |
CsmaNetDevice::IsBroadcast (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
846 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
847 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
848 |
return true; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
849 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
850 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
851 |
Address |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
852 |
CsmaNetDevice::GetBroadcast (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
853 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
854 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
855 |
return Mac48Address ("ff:ff:ff:ff:ff:ff"); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
856 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
857 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
858 |
bool |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
859 |
CsmaNetDevice::IsMulticast (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
860 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
861 |
NS_LOG_FUNCTION_NOARGS (); |
2795 | 862 |
return true; |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
863 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
864 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
865 |
Address |
3841
1e7abf5fca79
Apply Patch to address bug 294 -- due to vincent
Craig Dowell <craigdo@ee.washington.edu>
parents:
3682
diff
changeset
|
866 |
CsmaNetDevice::GetMulticast (Ipv4Address multicastGroup) const |
1443
580ed7a4dd1e
Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents:
1442
diff
changeset
|
867 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
868 |
NS_LOG_FUNCTION (multicastGroup); |
1443
580ed7a4dd1e
Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents:
1442
diff
changeset
|
869 |
|
3549
4eaf02702f17
shared Mac48 multicast code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3506
diff
changeset
|
870 |
Mac48Address ad = Mac48Address::GetMulticast (multicastGroup); |
3504 | 871 |
|
872 |
// |
|
873 |
// Implicit conversion (operator Address ()) is defined for Mac48Address, so |
|
874 |
// use it by just returning the EUI-48 address which is automagically converted |
|
875 |
// to an Address. |
|
876 |
// |
|
3549
4eaf02702f17
shared Mac48 multicast code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3506
diff
changeset
|
877 |
NS_LOG_LOGIC ("multicast address is " << ad); |
1443
580ed7a4dd1e
Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents:
1442
diff
changeset
|
878 |
|
3549
4eaf02702f17
shared Mac48 multicast code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3506
diff
changeset
|
879 |
return ad; |
1443
580ed7a4dd1e
Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents:
1442
diff
changeset
|
880 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
881 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
882 |
bool |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
883 |
CsmaNetDevice::IsPointToPoint (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
884 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
885 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
886 |
return false; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
887 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
888 |
|
3936
e525995ce5dc
implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents:
3861
diff
changeset
|
889 |
bool |
e525995ce5dc
implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents:
3861
diff
changeset
|
890 |
CsmaNetDevice::IsBridge (void) const |
e525995ce5dc
implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents:
3861
diff
changeset
|
891 |
{ |
e525995ce5dc
implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents:
3861
diff
changeset
|
892 |
NS_LOG_FUNCTION_NOARGS (); |
e525995ce5dc
implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents:
3861
diff
changeset
|
893 |
return false; |
e525995ce5dc
implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents:
3861
diff
changeset
|
894 |
} |
e525995ce5dc
implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents:
3861
diff
changeset
|
895 |
|
3504 | 896 |
bool |
897 |
CsmaNetDevice::Send (Ptr<Packet> packet,const Address& dest, uint16_t protocolNumber) |
|
3442
8eef02250bc9
Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3438
diff
changeset
|
898 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
899 |
NS_LOG_FUNCTION (packet << dest << protocolNumber); |
3442
8eef02250bc9
Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3438
diff
changeset
|
900 |
return SendFrom (packet, m_address, dest, protocolNumber); |
8eef02250bc9
Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3438
diff
changeset
|
901 |
} |
8eef02250bc9
Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3438
diff
changeset
|
902 |
|
3504 | 903 |
bool |
904 |
CsmaNetDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber) |
|
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
905 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
906 |
NS_LOG_FUNCTION (packet << src << dest << protocolNumber); |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
907 |
NS_LOG_LOGIC ("packet =" << packet); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
908 |
NS_LOG_LOGIC ("UID is " << packet->GetUid () << ")"); |
1443
580ed7a4dd1e
Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents:
1442
diff
changeset
|
909 |
|
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
910 |
NS_ASSERT (IsLinkUp ()); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
911 |
|
3504 | 912 |
// |
913 |
// Only transmit if send side of net device is enabled |
|
914 |
// |
|
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
915 |
if (IsSendEnabled () == false) |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
916 |
{ |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
917 |
m_macTxDropTrace (packet); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
918 |
return false; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
919 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
920 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
921 |
Mac48Address destination = Mac48Address::ConvertFrom (dest); |
3442
8eef02250bc9
Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3438
diff
changeset
|
922 |
Mac48Address source = Mac48Address::ConvertFrom (src); |
8eef02250bc9
Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3438
diff
changeset
|
923 |
AddHeader (packet, source, destination, protocolNumber); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
924 |
|
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
925 |
m_macTxTrace (packet); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
926 |
|
3504 | 927 |
// |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
928 |
// Place the packet to be sent on the send queue. Note that the |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
929 |
// queue may fire a drop trace, but we will too. |
3504 | 930 |
// |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
931 |
if (m_queue->Enqueue(packet) == false) |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
932 |
{ |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
933 |
m_macTxDropTrace (packet); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
934 |
return false; |
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
935 |
} |
3504 | 936 |
|
937 |
// |
|
938 |
// If the device is idle, we need to start a transmission. Otherwise, |
|
939 |
// the transmission will be started when the current packet finished |
|
940 |
// transmission (see TransmitCompleteEvent) |
|
941 |
// |
|
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
942 |
if (m_txMachineState == READY) |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
943 |
{ |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
944 |
if (m_queue->IsEmpty () == false) |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
945 |
{ |
4263
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
946 |
m_currentPkt = m_queue->Dequeue (); |
fec2f830d015
trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents:
4197
diff
changeset
|
947 |
NS_ASSERT_MSG (m_currentPkt != 0, "CsmaNetDevice::SendFrom(): IsEmpty false but no Packet on queue?"); |
4444
d564db1f1566
fixed packet trace time bomb in csma
Adrian S. W. Tam <adrian.sw.tam@gmail.com>
parents:
4424
diff
changeset
|
948 |
m_promiscSnifferTrace (m_currentPkt); |
d564db1f1566
fixed packet trace time bomb in csma
Adrian S. W. Tam <adrian.sw.tam@gmail.com>
parents:
4424
diff
changeset
|
949 |
m_snifferTrace (m_currentPkt); |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
950 |
TransmitStart (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
951 |
} |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
952 |
} |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
953 |
return true; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
954 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
955 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
956 |
Ptr<Node> |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
957 |
CsmaNetDevice::GetNode (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
958 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
959 |
NS_LOG_FUNCTION_NOARGS (); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
960 |
return m_node; |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
961 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
962 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
963 |
void |
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2501
diff
changeset
|
964 |
CsmaNetDevice::SetNode (Ptr<Node> node) |
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2501
diff
changeset
|
965 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
966 |
NS_LOG_FUNCTION (node); |
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
967 |
|
2600
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2501
diff
changeset
|
968 |
m_node = node; |
6c389d0c717d
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2501
diff
changeset
|
969 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
970 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
971 |
bool |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
972 |
CsmaNetDevice::NeedsArp (void) const |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
973 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
974 |
NS_LOG_FUNCTION_NOARGS (); |
3630
0aa446f659d9
MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents:
3629
diff
changeset
|
975 |
return true; |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
976 |
} |
3257
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
977 |
|
ba198dad54a2
CSMA Cleanup, XXX in echo apps, clarification of point-to-point data rates in dox
Craig Dowell <craigdo@ee.washington.edu>
parents:
3011
diff
changeset
|
978 |
void |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
979 |
CsmaNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
980 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
981 |
NS_LOG_FUNCTION (&cb); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
982 |
m_rxCallback = cb; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
983 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
984 |
|
3852 | 985 |
Address CsmaNetDevice::GetMulticast (Ipv6Address addr) const |
986 |
{ |
|
987 |
Mac48Address ad = Mac48Address::GetMulticast (addr); |
|
988 |
||
989 |
NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad); |
|
990 |
return ad; |
|
991 |
} |
|
992 |
||
3504 | 993 |
void |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
994 |
CsmaNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
995 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
996 |
NS_LOG_FUNCTION (&cb); |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
997 |
m_promiscRxCallback = cb; |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
998 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
999 |
|
3504 | 1000 |
bool |
3584
4eb48239b4dc
bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3549
diff
changeset
|
1001 |
CsmaNetDevice::SupportsSendFrom () const |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
1002 |
{ |
3476
b834a9204124
begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents:
3460
diff
changeset
|
1003 |
NS_LOG_FUNCTION_NOARGS (); |
3460
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
1004 |
return true; |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
1005 |
} |
99698bc858e8
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3448
diff
changeset
|
1006 |
|
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
1007 |
} // namespace ns3 |