src/csma/model/csma-net-device.cc
author Tom Henderson <tomh@tomh.org>
Mon, 28 Sep 2015 20:27:25 -0700
changeset 11676 05ea1489e509
parent 11261 844c0a62f232
permissions -rw-r--r--
bug 2184: Integer overflow in MacLow
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10652
diff changeset
    36
namespace ns3 {
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
    37
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10652
diff changeset
    38
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
    39
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10431
diff changeset
    40
NS_OBJECT_ENSURE_REGISTERED (CsmaNetDevice);
2501
3eaeac1dd5ed add missing NS_OBJECT_ENSURE_REGISTERED calls.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2500
diff changeset
    41
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
    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> ()
11261
844c0a62f232 SetGroupName for csma module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11226
diff changeset
    47
    .SetGroupName ("Csma")
2500
1fb9430f642d convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    48
    .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
    49
    .AddAttribute ("Address", 
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    50
                   "The MAC address of this device.",
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    51
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    52
                   MakeMac48AddressAccessor (&CsmaNetDevice::m_address),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    53
                   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
    54
    .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
    55
                   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
    56
                   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
    57
                                         &CsmaNetDevice::GetMtu),
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    58
                   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
    59
    .AddAttribute ("EncapsulationMode", 
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    60
                   "The link-layer encapsulation type to use.",
3633
fedc8b314171 flip LLC to DIX framing switch in csma
craigdo@ns-test
parents: 3632
diff changeset
    61
                   EnumValue (DIX),
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
    62
                   MakeEnumAccessor (&CsmaNetDevice::SetEncapsulationMode),
3629
367ae1cba60f further cleanup of MTU in CSMA
craigdo@ee.washington.edu
parents: 3584
diff changeset
    63
                   MakeEnumChecker (DIX, "Dix",
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    64
                                    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
    65
    .AddAttribute ("SendEnable", 
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    66
                   "Enable or disable the transmitter section of the device.",
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    67
                   BooleanValue (true),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    68
                   MakeBooleanAccessor (&CsmaNetDevice::m_sendEnable),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    69
                   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
    70
    .AddAttribute ("ReceiveEnable",
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    71
                   "Enable or disable the receiver section of the device.",
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    72
                   BooleanValue (true),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    73
                   MakeBooleanAccessor (&CsmaNetDevice::m_receiveEnable),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    74
                   MakeBooleanChecker ())
3861
dacfd1f07538 change attribute ReceiveErrorModel in CSMA and rescan
Craig Dowell <craigdo@ee.washington.edu>
parents: 3852
diff changeset
    75
    .AddAttribute ("ReceiveErrorModel", 
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    76
                   "The receiver error model used to simulate packet loss",
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    77
                   PointerValue (),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    78
                   MakePointerAccessor (&CsmaNetDevice::m_receiveErrorModel),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    79
                   MakePointerChecker<ErrorModel> ())
4263
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
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
    82
    // 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
    83
    // of trace hooks.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
    84
    //
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
    85
    .AddAttribute ("TxQueue", 
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    86
                   "A queue to use as the transmit queue in the device.",
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    87
                   PointerValue (),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    88
                   MakePointerAccessor (&CsmaNetDevice::m_queue),
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
    89
                   MakePointerChecker<Queue> ())
4263
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
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
    92
    // 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
    93
    // to/from higher layers.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
    94
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
    95
    .AddTraceSource ("MacTx", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    96
                     "Trace source indicating a packet has "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    97
                     "arrived for transmission by this device",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    98
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
    99
                     "ns3::Packet::TracedCallback")
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   100
    .AddTraceSource ("MacTxDrop", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   101
                     "Trace source indicating a packet has been "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   102
                     "dropped by the device before transmission",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   103
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxDropTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   104
                     "ns3::Packet::TracedCallback")
4272
b40ce56e0247 Add MacPromiscRx, make MacRx non-promisc
Craig Dowell <craigdo@ee.washington.edu>
parents: 4265
diff changeset
   105
    .AddTraceSource ("MacPromiscRx", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   106
                     "A packet has been received by this device, "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   107
                     "has been passed up from the physical layer "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   108
                     "and is being forwarded up the local protocol stack.  "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   109
                     "This is a promiscuous trace,",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   110
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_macPromiscRxTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   111
                     "ns3::Packet::TracedCallback")
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   112
    .AddTraceSource ("MacRx", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   113
                     "A packet has been received by this device, "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   114
                     "has been passed up from the physical layer "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   115
                     "and is being forwarded up the local protocol stack.  "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   116
                     "This is a non-promiscuous trace,",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   117
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_macRxTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   118
                     "ns3::Packet::TracedCallback")
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   119
#if 0
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   120
    // Not currently implemented in this device
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   121
    .AddTraceSource ("MacRxDrop", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   122
                     "Trace source indicating a packet was received, "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   123
                     "but dropped before being forwarded up the stack",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   124
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_macRxDropTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   125
                     "ns3::Packet::TracedCallback")
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   126
#endif
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   127
    .AddTraceSource ("MacTxBackoff", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   128
                     "Trace source indicating a packet has been "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   129
                     "delayed by the CSMA backoff process",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   130
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxBackoffTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   131
                     "ns3::Packet::TracedCallback")
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   132
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   133
    // 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
   134
    // to/from the channel.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   135
    //
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   136
    .AddTraceSource ("PhyTxBegin", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   137
                     "Trace source indicating a packet has "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   138
                     "begun transmitting over the channel",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   139
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxBeginTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   140
                     "ns3::Packet::TracedCallback")
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   141
    .AddTraceSource ("PhyTxEnd", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   142
                     "Trace source indicating a packet has been "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   143
                     "completely transmitted over the channel",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   144
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxEndTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   145
                     "ns3::Packet::TracedCallback")
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   146
    .AddTraceSource ("PhyTxDrop", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   147
                     "Trace source indicating a packet has been "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   148
                     "dropped by the device during transmission",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   149
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_phyTxDropTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   150
                     "ns3::Packet::TracedCallback")
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   151
#if 0
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   152
    // Not currently implemented in this device
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   153
    .AddTraceSource ("PhyRxBegin", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   154
                     "Trace source indicating a packet has "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   155
                     "begun being received by the device",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   156
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxBeginTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   157
                     "ns3::Packet::TracedCallback")
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   158
#endif
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   159
    .AddTraceSource ("PhyRxEnd", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   160
                     "Trace source indicating a packet has been "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   161
                     "completely received by the device",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   162
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxEndTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   163
                     "ns3::Packet::TracedCallback")
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   164
    .AddTraceSource ("PhyRxDrop", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   165
                     "Trace source indicating a packet has been "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   166
                     "dropped by the device during reception",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   167
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_phyRxDropTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   168
                     "ns3::Packet::TracedCallback")
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   169
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   170
    // Trace sources designed to simulate a packet sniffer facility (tcpdump). 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   171
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   172
    .AddTraceSource ("Sniffer", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   173
                     "Trace source simulating a non-promiscuous "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   174
                     "packet sniffer attached to the device",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   175
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_snifferTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   176
                     "ns3::Packet::TracedCallback")
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   177
    .AddTraceSource ("PromiscSniffer", 
11085
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   178
                     "Trace source simulating a promiscuous "
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   179
                     "packet sniffer attached to the device",
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   180
                     MakeTraceSourceAccessor (&CsmaNetDevice::m_promiscSnifferTrace),
6e4d08656d7c TracedCallback function signatures, the simple ones.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10968
diff changeset
   181
                     "ns3::Packet::TracedCallback")
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   182
  ;
2500
1fb9430f642d convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   183
  return tid;
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
   184
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   185
2500
1fb9430f642d convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   186
CsmaNetDevice::CsmaNetDevice ()
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   187
  : m_linkUp (false)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   188
{
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
   189
  NS_LOG_FUNCTION (this);
2500
1fb9430f642d convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   190
  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
   191
  m_tInterframeGap = Seconds (0);
2500
1fb9430f642d convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   192
  m_channel = 0; 
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   193
3630
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   194
  // 
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   195
  // 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
   196
  // 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
   197
  // 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
   198
  // 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
   199
  // 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
   200
  // 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
   201
  // 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
   202
  // 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
   203
  // to change it here.
3630
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   204
  //
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   205
  m_encapMode = DIX;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   206
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   207
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   208
CsmaNetDevice::~CsmaNetDevice()
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   209
{
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
   210
  NS_LOG_FUNCTION_NOARGS ();
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   211
  m_queue = 0;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   212
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   213
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   214
void
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   215
CsmaNetDevice::DoDispose ()
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   216
{
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
   217
  NS_LOG_FUNCTION_NOARGS ();
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   218
  m_channel = 0;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   219
  m_node = 0;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   220
  NetDevice::DoDispose ();
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   221
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   222
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   223
void
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   224
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode)
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   225
{
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   226
  NS_LOG_FUNCTION (mode);
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
  m_encapMode = mode;
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   229
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   230
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   231
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   232
}
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   233
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   234
CsmaNetDevice::EncapsulationMode
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   235
CsmaNetDevice::GetEncapsulationMode (void)
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   236
{
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   237
  NS_LOG_FUNCTION_NOARGS ();
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   238
  return m_encapMode;
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   239
}
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   240
6183
8a5e1f9db873 [bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5894
diff changeset
   241
bool
3629
367ae1cba60f further cleanup of MTU in CSMA
craigdo@ee.washington.edu
parents: 3584
diff changeset
   242
CsmaNetDevice::SetMtu (uint16_t mtu)
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   243
{
6183
8a5e1f9db873 [bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5894
diff changeset
   244
  NS_LOG_FUNCTION (this << mtu);
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   245
  m_mtu = mtu;
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   246
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   247
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   248
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
3629
367ae1cba60f further cleanup of MTU in CSMA
craigdo@ee.washington.edu
parents: 3584
diff changeset
   249
367ae1cba60f further cleanup of MTU in CSMA
craigdo@ee.washington.edu
parents: 3584
diff changeset
   250
  return true;
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   251
}
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   252
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   253
uint16_t
3629
367ae1cba60f further cleanup of MTU in CSMA
craigdo@ee.washington.edu
parents: 3584
diff changeset
   254
CsmaNetDevice::GetMtu (void) const
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   255
{
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   256
  NS_LOG_FUNCTION_NOARGS ();
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   257
  return m_mtu;
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   258
}
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   259
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   260
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   261
void
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   262
CsmaNetDevice::SetSendEnable (bool sendEnable)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   263
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   264
  NS_LOG_FUNCTION (sendEnable);
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   265
  m_sendEnable = sendEnable;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   266
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   267
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   268
void
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   269
CsmaNetDevice::SetReceiveEnable (bool receiveEnable)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   270
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   271
  NS_LOG_FUNCTION (receiveEnable);
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   272
  m_receiveEnable = receiveEnable;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   273
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   274
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   275
bool
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   276
CsmaNetDevice::IsSendEnabled (void)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   277
{
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
   278
  NS_LOG_FUNCTION_NOARGS ();
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   279
  return m_sendEnable;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   280
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   281
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   282
bool
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   283
CsmaNetDevice::IsReceiveEnabled (void)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   284
{
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
   285
  NS_LOG_FUNCTION_NOARGS ();
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   286
  return m_receiveEnable;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   287
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   288
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   289
void
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   290
CsmaNetDevice::SetInterframeGap (Time t)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   291
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   292
  NS_LOG_FUNCTION (t);
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   293
  m_tInterframeGap = t;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   294
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   295
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   296
void
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   297
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
   298
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   299
  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
   300
  m_backoff.m_slotTime = slotTime;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   301
  m_backoff.m_minSlots = minSlots;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   302
  m_backoff.m_maxSlots = maxSlots;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   303
  m_backoff.m_ceiling = ceiling;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   304
  m_backoff.m_maxRetries = maxRetries;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   305
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   306
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   307
void
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   308
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
   309
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   310
  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
   311
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
   312
  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
   313
  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
   314
  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
   315
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
   316
  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
   317
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   318
  NS_LOG_LOGIC ("p->GetSize () = " << p->GetSize ());
3506
cba7b2b80fe8 sort out various MTU options
Craig Dowell <craigdo@ee.washington.edu>
parents: 3504
diff changeset
   319
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   320
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   321
1001
33cf9c56e3cd Fix lengthType initialization for optimized build
Tom Henderson <tomh@tomh.org>
parents: 997
diff changeset
   322
  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
   323
  switch (m_encapMode) 
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   324
    {
3629
367ae1cba60f further cleanup of MTU in CSMA
craigdo@ee.washington.edu
parents: 3584
diff changeset
   325
    case DIX:
3630
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   326
      NS_LOG_LOGIC ("Encapsulating packet as DIX (type interpretation)");
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   327
      //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   328
      // 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
   329
      // in the old Ethernet Blue Book.
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   330
      //
995
22821dd9152e param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 993
diff changeset
   331
      lengthType = protocolNumber;
5833
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   332
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   333
      //
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   334
      // 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
   335
      // 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
   336
      // 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
   337
      // trace files.
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   338
      //
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   339
      if (p->GetSize () < 46)
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   340
        {
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   341
          uint8_t buffer[46];
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   342
          memset (buffer, 0, 46);
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   343
          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
   344
          p->AddAtEnd (padd);
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   345
        }
995
22821dd9152e param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 993
diff changeset
   346
      break;
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   347
    case LLC: 
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   348
      {
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   349
        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
   350
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   351
        LlcSnapHeader llc;
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   352
        llc.SetType (protocolNumber);
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   353
        p->AddHeader (llc);
5833
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   354
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   355
        //
7156
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   356
        // This corresponds to the length interpretation of the lengthType 
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   357
        // field but with an LLC/SNAP header added to the payload as in 
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   358
        // IEEE 802.2
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   359
        //
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   360
        lengthType = p->GetSize ();
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   361
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   362
        //
5833
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   363
        // 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
   364
        // 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
   365
        // 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
   366
        // 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
   367
        //
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   368
        if (p->GetSize () < 46)
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   369
          {
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   370
            uint8_t buffer[46];
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   371
            memset (buffer, 0, 46);
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   372
            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
   373
            p->AddAtEnd (padd);
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   374
          }
aa78abc9c10d padd out CSMA payloads to 46 bytes if needed
Craig Dowell <craigdo@ee.washington.edu>
parents: 5832
diff changeset
   375
7156
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   376
        NS_ASSERT_MSG (p->GetSize () <= GetMtu (),
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   377
                       "CsmaNetDevice::AddHeader(): 802.3 Length/Type field with LLC/SNAP: "
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   378
                       "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
   379
      }
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   380
      break;
3630
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   381
    case ILLEGAL:
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   382
    default:
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   383
      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
   384
      break;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   385
    }
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
   386
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   387
  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
   388
  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
   389
  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
   390
5831
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   391
  if (Node::ChecksumEnabled ())
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   392
    {
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   393
      trailer.EnableFcs (true);
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   394
    }
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
   395
  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
   396
  p->AddTrailer (trailer);
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   397
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   398
5832
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   399
#if 0
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   400
bool
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   401
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
   402
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   403
  NS_LOG_FUNCTION (p << param);
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   404
995
22821dd9152e param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 993
diff changeset
   405
  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
   406
  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
   407
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
   408
  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
   409
  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
   410
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
   411
  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
   412
      (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
   413
    {
22821dd9152e param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 993
diff changeset
   414
      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
   415
    }
22821dd9152e param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 993
diff changeset
   416
22821dd9152e param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 993
diff changeset
   417
  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
   418
    {
3629
367ae1cba60f further cleanup of MTU in CSMA
craigdo@ee.washington.edu
parents: 3584
diff changeset
   419
    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
   420
      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
   421
      break;
3630
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   422
    case LLC: 
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   423
      {
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   424
        LlcSnapHeader llc;
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   425
        p->RemoveHeader (llc);
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   426
        param = llc.GetType ();
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   427
      } 
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   428
      break;
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   429
    case ILLEGAL:
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   430
    default:
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
   431
      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
   432
      break;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   433
    }
995
22821dd9152e param is a 16 bit integer. implement proper llc encapsulation/decapsulation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 993
diff changeset
   434
  return true;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   435
}
5832
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   436
#endif
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   437
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   438
void
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   439
CsmaNetDevice::TransmitStart (void)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   440
{
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
   441
  NS_LOG_FUNCTION_NOARGS ();
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   442
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   443
  //
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   444
  // 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
   445
  // 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
   446
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   447
  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
   448
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   449
  NS_LOG_LOGIC ("m_currentPkt = " << m_currentPkt);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   450
  NS_LOG_LOGIC ("UID = " << m_currentPkt->GetUid ());
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   451
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   452
  //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   453
  // 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
   454
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   455
  if (IsSendEnabled () == false)
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   456
    {
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   457
      m_phyTxDropTrace (m_currentPkt);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   458
      m_currentPkt = 0;
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   459
      return;
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   460
    }
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   461
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   462
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   463
  // 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
   464
  // 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
   465
  // 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
   466
  // be transmitting (i.e., BUSY)
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   467
  //
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
   468
  NS_ASSERT_MSG ((m_txMachineState == READY) || (m_txMachineState == BACKOFF), 
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   469
                 "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
   470
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   471
  //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   472
  // 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
   473
  // if it is idle, or backoff our transmission if someone else is on the wire.
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   474
  //
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
   475
  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
   476
    {
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   477
      //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   478
      // The channel is busy -- backoff and rechedule TransmitStart() unless
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   479
      // we have exhausted all of our retries.
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   480
      //
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
   481
      m_txMachineState = BACKOFF;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   482
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
   483
      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
   484
        { 
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   485
          //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   486
          // Too many retries, abort transmission of packet
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   487
          //
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
   488
          TransmitAbort ();
997
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   489
        } 
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   490
      else 
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   491
        {
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   492
          m_macTxBackoffTrace (m_currentPkt);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   493
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
   494
          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
   495
          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
   496
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   497
          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
   498
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   499
          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
   500
        }
997
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   501
    } 
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   502
  else 
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   503
    {
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   504
      //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   505
      // The channel is free, transmit the packet
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   506
      //
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
   507
      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
   508
        {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   509
          NS_LOG_WARN ("Channel TransmitStart returns an error");
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   510
          m_phyTxDropTrace (m_currentPkt);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   511
          m_currentPkt = 0;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   512
          m_txMachineState = READY;
997
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   513
        } 
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   514
      else 
d95ffcec6523 fix indent, basic coding style issues
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 995
diff changeset
   515
        {
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   516
          //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   517
          // Transmission succeeded, reset the backoff time parameters and
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   518
          // schedule a transmit complete event.
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   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 ();
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   521
          m_txMachineState = BUSY;
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   522
          m_phyTxBeginTrace (m_currentPkt);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   523
11226
d1185f77286f Bug 1974 - CalculateTxTime should return a Time, not a double
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11085
diff changeset
   524
          Time tEvent = m_bps.CalculateBytesTxTime (m_currentPkt->GetSize ());
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   525
          NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << tEvent.GetSeconds () << "sec");
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   526
          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
   527
        }
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   528
    }
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   529
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   530
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   531
void
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   532
CsmaNetDevice::TransmitAbort (void)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   533
{
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
   534
  NS_LOG_FUNCTION_NOARGS ();
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   535
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   536
  //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   537
  // 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
   538
  // 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
   539
  //
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   540
  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
   541
  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
   542
  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
   543
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   544
  m_phyTxDropTrace (m_currentPkt);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   545
  m_currentPkt = 0;
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   546
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   547
  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
   548
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   549
  // 
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   550
  // 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
   551
  // transmit state machine.
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   552
  //
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
   553
  m_backoff.ResetBackoffTime ();
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   554
  m_txMachineState = READY;
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   555
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   556
  //
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   557
  // 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
   558
  // 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
   559
  // in.
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
  if (m_queue->IsEmpty ())
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   562
    {
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   563
      return;
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   564
    }
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   565
  else
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   566
    {
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   567
      m_currentPkt = m_queue->Dequeue ();
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   568
      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
   569
      m_snifferTrace (m_currentPkt);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   570
      m_promiscSnifferTrace (m_currentPkt);
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   571
      TransmitStart ();
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   572
    }
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   573
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   574
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   575
void
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   576
CsmaNetDevice::TransmitCompleteEvent (void)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   577
{
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
   578
  NS_LOG_FUNCTION_NOARGS ();
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   579
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   580
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   581
  // This function is called to finish the  process of transmitting a packet.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   582
  // We need to tell the channel that we've stopped wiggling the wire and
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   583
  // schedule an event that will be executed when it's time to re-enable
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   584
  // the transmitter after the interframe gap.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   585
  //
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   586
  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
   587
  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
   588
  m_txMachineState = GAP;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   589
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   590
  //
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   591
  // 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
   592
  // 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
   593
  //
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   594
  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
   595
  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
   596
  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
   597
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   598
  m_channel->TransmitEnd (); 
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   599
  m_phyTxEndTrace (m_currentPkt);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   600
  m_currentPkt = 0;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   601
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   602
  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
   603
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   604
  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
   605
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   606
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   607
void
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   608
CsmaNetDevice::TransmitReadyEvent (void)
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   609
{
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
   610
  NS_LOG_FUNCTION_NOARGS ();
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   611
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   612
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   613
  // This function is called to enable the transmitter after the interframe
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   614
  // gap has passed.  If there are pending transmissions, we use this opportunity
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   615
  // to start the next transmit.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   616
  //
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   617
  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
   618
  m_txMachineState = READY;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   619
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   620
  //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   621
  // 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
   622
  // TransmitCompleteEvent() was executed.
4197
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   623
  //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   624
  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
   625
3aca059abe63 clean up transmit abort nonsense
Craig Dowell <craigdo@ee.washington.edu>
parents: 4170
diff changeset
   626
  //
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   627
  // Get the next packet from the queue for transmitting
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   628
  //
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
   629
  if (m_queue->IsEmpty ())
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   630
    {
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   631
      return;
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   632
    }
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   633
  else
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   634
    {
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   635
      m_currentPkt = m_queue->Dequeue ();
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   636
      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
   637
      m_snifferTrace (m_currentPkt);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   638
      m_promiscSnifferTrace (m_currentPkt);
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   639
      TransmitStart ();
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   640
    }
977
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
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   643
bool
1276
e0b88ec7a6be merge ns-3-csma with tip
Craig Dowell <craigdo@ee.washington.edu>
parents: 1270
diff changeset
   644
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
   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 (this << &ch);
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   647
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   648
  m_channel = ch;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   649
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
   650
  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
   651
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   652
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   653
  // The channel provides us with the transmitter data rate.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   654
  //
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   655
  m_bps = m_channel->GetDataRate ();
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   656
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   657
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   658
  // We use the Ethernet interframe gap of 96 bit times.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   659
  //
11226
d1185f77286f Bug 1974 - CalculateTxTime should return a Time, not a double
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11085
diff changeset
   660
  m_tInterframeGap = m_bps.CalculateBytesTxTime (96/8);
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
   661
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   662
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   663
  // This device is up whenever a channel is attached to it.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   664
  //
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   665
  NotifyLinkUp ();
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   666
  return true;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   667
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   668
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   669
void
3011
2d507430219e bug 153 applied to CSMA
Craig Dowell <craigdo@ee.washington.edu>
parents: 2989
diff changeset
   670
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
   671
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   672
  NS_LOG_FUNCTION (q);
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   673
  m_queue = q;
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   674
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   675
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   676
void
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
   677
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
   678
{
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
   679
  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
   680
  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
   681
}
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   682
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   683
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
   684
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
   685
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   686
  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
   687
  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   688
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   689
  //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   690
  // 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
   691
  // their receivers are disabled during send, so we don't.
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   692
  // 
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
   693
  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
   694
    {
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
   695
      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
   696
    }
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
   697
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   698
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   699
  // 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
   700
  // channel except those originated by this device.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   701
  //
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   702
  m_phyRxEndTrace (packet);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   703
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   704
  // 
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   705
  // Only receive if the send side of net device is enabled
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   706
  //
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
   707
  if (IsReceiveEnabled () == false)
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   708
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   709
      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
   710
      return;
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   711
    }
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   712
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   713
  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
   714
    {
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   715
      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
   716
      m_phyRxDropTrace (packet);
6786
17f9a64dd4f6 bugfix: CsmaNetDevice ErrorModel not discarding packet (reported by Rafal Mielniczuk)
Tom Henderson <tomh@tomh.org>
parents: 6183
diff changeset
   717
      return;
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   718
    }
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   719
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   720
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   721
  // Trace sinks will expect complete packets, not packets without some of the
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   722
  // headers.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   723
  //
3326
239c4bc21ebf reposition trace hook in csma to address bug 241.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3257
diff changeset
   724
  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
   725
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
   726
  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
   727
  packet->RemoveTrailer (trailer);
5831
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   728
  if (Node::ChecksumEnabled ())
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   729
    {
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   730
      trailer.EnableFcs (true);
3fda006341e6 Add FCS capability to CSMA
Florian Schmidt <Florian.Schmidt@cs.rwth-aachen.de>
parents: 4764
diff changeset
   731
    }
5832
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   732
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   733
  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
   734
  if (!crcGood)
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   735
    {
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   736
      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
   737
      m_phyRxDropTrace (packet);
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   738
      return;
2812b92d4888 Drop CSMA packets with CRC errors, rescan, dox tweaks
Craig Dowell <craigdo@ee.washington.edu>
parents: 5831
diff changeset
   739
    }
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
   740
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
   741
  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
   742
  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
   743
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
   744
  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
   745
  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
   746
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   747
  uint16_t protocol;
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   748
  //
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   749
  // 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
   750
  // 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
   751
  // 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
   752
  // 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
   753
  //
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   754
  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
   755
    {
7156
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   756
      NS_ASSERT (packet->GetSize () >= header.GetLengthType ());
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   757
      uint32_t padlen = packet->GetSize () - header.GetLengthType ();
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   758
      NS_ASSERT (padlen <= 46);
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   759
      if (padlen > 0)
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   760
        {
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   761
          packet->RemoveAtEnd (padlen);
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   762
        }
2bdd52256e8a bug 1056: CSMA: padding not handled correctly for LLC encapsulation
Tom Goff <tgoff@tgoff.net>
parents: 6852
diff changeset
   763
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   764
      LlcSnapHeader llc;
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   765
      packet->RemoveHeader (llc);
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   766
      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
   767
    }
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   768
  else
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   769
    {
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   770
      protocol = header.GetLengthType ();
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   771
    }
3438
86e262420fbf Implement the promiscuous receive callback for CsmaNetDevice.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3436
diff changeset
   772
5894
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
  // 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
   775
  //
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   776
  PacketType packetType;
4424
af26433b13bc remove Mac48Address::IsMulticast
Fabian Mauchle <f1mauchl@hsr.ch>
parents: 4322
diff changeset
   777
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   778
  if (header.GetDestination ().IsBroadcast ())
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   779
    {
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   780
      packetType = PACKET_BROADCAST;
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   781
    }
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   782
  else if (header.GetDestination ().IsGroup ())
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   783
    {
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   784
      packetType = PACKET_MULTICAST;
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   785
    }
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   786
  else if (header.GetDestination () == m_address)
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   787
    {
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   788
      packetType = PACKET_HOST;
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   789
    }
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   790
  else
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   791
    {
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   792
      packetType = PACKET_OTHERHOST;
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   793
    }
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   794
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   795
  // 
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   796
  // 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
   797
  // 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
   798
  // 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
   799
  //
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   800
  m_promiscSnifferTrace (originalPacket);
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   801
  if (!m_promiscRxCallback.IsNull ())
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   802
    {
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   803
      m_macPromiscRxTrace (originalPacket);
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   804
      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
   805
    }
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
   806
5894
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   807
  //
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   808
  // 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
   809
  // 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
   810
  // 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
   811
  //
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   812
  if (packetType != PACKET_OTHERHOST)
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   813
    {
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   814
      m_snifferTrace (originalPacket);
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   815
      m_macRxTrace (originalPacket);
7f709d2bdf84 Fix bug 738 ReceiveErrorModel called too late
Craig Dowell <craigdo@ee.washington.edu>
parents: 5833
diff changeset
   816
      m_rxCallback (this, packet, protocol, header.GetSource ());
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   817
    }
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   818
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   819
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   820
Ptr<Queue>
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
   821
CsmaNetDevice::GetQueue (void) const 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   822
{ 
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
   823
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   824
  return m_queue;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   825
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   826
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   827
void
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   828
CsmaNetDevice::NotifyLinkUp (void)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   829
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   830
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   831
  m_linkUp = true;
4764
e90e1ef585b0 [Bug 653] NetDevice link change callback (SetLinkChangeCallback -> AddLinkChangeCallback).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4578
diff changeset
   832
  m_linkChangeCallbacks ();
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   833
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
   834
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   835
void
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
CsmaNetDevice::SetIfIndex (const uint32_t index)
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   837
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   838
  NS_LOG_FUNCTION (index);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   839
  m_ifIndex = index;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   840
}
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
   841
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   842
uint32_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
   843
CsmaNetDevice::GetIfIndex (void) const
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   844
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   845
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   846
  return m_ifIndex;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   847
}
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
   848
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   849
Ptr<Channel>
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   850
CsmaNetDevice::GetChannel (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   851
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   852
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   853
  return m_channel;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   854
}
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
   855
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   856
void
4578
88434ff8f0a5 Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4444
diff changeset
   857
CsmaNetDevice::SetAddress (Address address)
88434ff8f0a5 Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4444
diff changeset
   858
{
88434ff8f0a5 Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4444
diff changeset
   859
  NS_LOG_FUNCTION_NOARGS ();
88434ff8f0a5 Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4444
diff changeset
   860
  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
   861
}
88434ff8f0a5 Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4444
diff changeset
   862
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   863
Address
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   864
CsmaNetDevice::GetAddress (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   865
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   866
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   867
  return m_address;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   868
}
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
   869
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   870
bool
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   871
CsmaNetDevice::IsLinkUp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   872
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   873
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   874
  return m_linkUp;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   875
}
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
   876
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   877
void
4764
e90e1ef585b0 [Bug 653] NetDevice link change callback (SetLinkChangeCallback -> AddLinkChangeCallback).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4578
diff changeset
   878
CsmaNetDevice::AddLinkChangeCallback (Callback<void> callback)
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   879
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   880
  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
   881
  m_linkChangeCallbacks.ConnectWithoutContext (callback);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   882
}
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
   883
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   884
bool
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   885
CsmaNetDevice::IsBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   886
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   887
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   888
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   889
}
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
   890
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   891
Address
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   892
CsmaNetDevice::GetBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   893
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   894
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   895
  return Mac48Address ("ff:ff:ff:ff:ff:ff");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   896
}
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
   897
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   898
bool
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   899
CsmaNetDevice::IsMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   900
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   901
  NS_LOG_FUNCTION_NOARGS ();
2795
720104ef3fce enable csma multicast
Tom Henderson <tomh@tomh.org>
parents: 2777
diff changeset
   902
  return true;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   903
}
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
   904
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   905
Address
3841
1e7abf5fca79 Apply Patch to address bug 294 -- due to vincent
Craig Dowell <craigdo@ee.washington.edu>
parents: 3682
diff changeset
   906
CsmaNetDevice::GetMulticast (Ipv4Address multicastGroup) const
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   907
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   908
  NS_LOG_FUNCTION (multicastGroup);
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   909
3549
4eaf02702f17 shared Mac48 multicast code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3506
diff changeset
   910
  Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   911
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   912
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   913
  // Implicit conversion (operator Address ()) is defined for Mac48Address, so
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   914
  // use it by just returning the EUI-48 address which is automagically converted
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   915
  // to an Address.
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   916
  //
3549
4eaf02702f17 shared Mac48 multicast code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3506
diff changeset
   917
  NS_LOG_LOGIC ("multicast address is " << ad);
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   918
3549
4eaf02702f17 shared Mac48 multicast code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3506
diff changeset
   919
  return ad;
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   920
}
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
   921
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   922
bool
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   923
CsmaNetDevice::IsPointToPoint (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   924
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   925
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   926
  return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   927
}
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
   928
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   929
bool
3936
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3861
diff changeset
   930
CsmaNetDevice::IsBridge (void) const
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3861
diff changeset
   931
{
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3861
diff changeset
   932
  NS_LOG_FUNCTION_NOARGS ();
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3861
diff changeset
   933
  return false;
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3861
diff changeset
   934
}
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3861
diff changeset
   935
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   936
bool
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   937
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
   938
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   939
  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
   940
  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
   941
}
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
   942
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   943
bool
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   944
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
   945
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   946
  NS_LOG_FUNCTION (packet << src << dest << protocolNumber);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   947
  NS_LOG_LOGIC ("packet =" << packet);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   948
  NS_LOG_LOGIC ("UID is " << packet->GetUid () << ")");
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   949
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   950
  NS_ASSERT (IsLinkUp ());
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   951
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   952
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   953
  // Only transmit if send side of net device is enabled
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
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
  if (IsSendEnabled () == false)
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   956
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   957
      m_macTxDropTrace (packet);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   958
      return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   959
    }
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
   960
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
   961
  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
   962
  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
   963
  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
   964
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   965
  m_macTxTrace (packet);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   966
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   967
  //
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   968
  // 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
   969
  // queue may fire a drop trace, but we will too.
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   970
  //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7170
diff changeset
   971
  if (m_queue->Enqueue (packet) == false)
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
   972
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   973
      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
   974
      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
   975
    }
3504
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   976
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   977
  //
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   978
  // If the device is idle, we need to start a transmission. Otherwise,
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   979
  // the transmission will be started when the current packet finished
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   980
  // transmission (see TransmitCompleteEvent)
0261c789e17e 128 column pages
Craig Dowell <craigdo@ee.washington.edu>
parents: 3477
diff changeset
   981
  //
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   982
  if (m_txMachineState == READY) 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   983
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   984
      if (m_queue->IsEmpty () == false)
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   985
        {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   986
          m_currentPkt = m_queue->Dequeue ();
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4197
diff changeset
   987
          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
   988
          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
   989
          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
   990
          TransmitStart ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   991
        }
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   992
    }
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   993
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   994
}
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
   995
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
   996
Ptr<Node>
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   997
CsmaNetDevice::GetNode (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
   998
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
   999
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1000
  return m_node;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1001
}
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
  1002
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
  1003
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
  1004
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
  1005
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
  1006
  NS_LOG_FUNCTION (node);
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
  1007
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
  1008
  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
  1009
}
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
  1010
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
  1011
bool
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1012
CsmaNetDevice::NeedsArp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1013
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
  1014
  NS_LOG_FUNCTION_NOARGS ();
3630
0aa446f659d9 MTU, encap mode cleanup for csma
craigdo@ee.washington.edu
parents: 3629
diff changeset
  1015
  return true;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1016
}
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
  1017
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
  1018
void
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1019
CsmaNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1020
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
  1021
  NS_LOG_FUNCTION (&cb);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2258
diff changeset
  1022
  m_rxCallback = cb;
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
  1023
}
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
  1024
3852
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
  1025
Address CsmaNetDevice::GetMulticast (Ipv6Address addr) const
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
  1026
{
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
  1027
  Mac48Address ad = Mac48Address::GetMulticast (addr);
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
  1028
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7170
diff changeset
  1029
  NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad);
3852
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
  1030
  return ad;
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
  1031
}
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
  1032
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
  1033
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
  1034
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
  1035
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
  1036
  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
  1037
  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
  1038
}
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
  1039
7170
8417cff6e353 csma coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7156
diff changeset
  1040
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
  1041
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
  1042
{
3476
b834a9204124 begin sorting out mtu woes
Craig Dowell <craigdo@ee.washington.edu>
parents: 3460
diff changeset
  1043
  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
  1044
  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
  1045
}
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
  1046
8974
bfe1b44645d8 Replace src/csma usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
  1047
int64_t
bfe1b44645d8 Replace src/csma usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
  1048
CsmaNetDevice::AssignStreams (int64_t stream)
bfe1b44645d8 Replace src/csma usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
  1049
{
bfe1b44645d8 Replace src/csma usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
  1050
  return m_backoff.AssignStreams (stream);
bfe1b44645d8 Replace src/csma usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
  1051
}
bfe1b44645d8 Replace src/csma usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
  1052
977
09bf4e458015 a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff changeset
  1053
} // namespace ns3