src/devices/point-to-point/point-to-point-net-device.cc
author Craig Dowell <craigdo@ee.washington.edu>
Tue, 10 Mar 2009 23:47:55 -0700
changeset 4264 9d2e96c4e6e4
parent 4263 fec2f830d015
child 4265 5f837915710a
permissions -rw-r--r--
Piles of changes for tracing rework
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     2
/*
3086
5370849d0b76 ppp model description
Craig Dowell <craigdo@ee.washington.edu>
parents: 3012
diff changeset
     3
 * Copyright (c) 2007, 2008 University of Washington
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     4
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     7
 * published by the Free Software Foundation;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     8
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    12
 * GNU General Public License for more details.
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    13
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    14
 * You should have received a copy of the GNU General Public License
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    15
 * along with this program; if not, write to the Free Software
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    17
 */
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    19
#include "ns3/log.h"
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    20
#include "ns3/queue.h"
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
    21
#include "ns3/simulator.h"
1494
c2985e1cd091 rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
    22
#include "ns3/mac48-address.h"
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
    23
#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: 1508
diff changeset
    24
#include "ns3/error-model.h"
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    25
#include "ns3/trace-source-accessor.h"
3632
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
    26
#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
    27
#include "ns3/pointer.h"
973
2aea9e9f698c src/devices/point-to-point/p2p-* -> src/devices/point-to-point/point-to-point-*
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 972
diff changeset
    28
#include "point-to-point-net-device.h"
2aea9e9f698c src/devices/point-to-point/p2p-* -> src/devices/point-to-point/point-to-point-*
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 972
diff changeset
    29
#include "point-to-point-channel.h"
3012
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
    30
#include "ppp-header.h"
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    31
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    32
NS_LOG_COMPONENT_DEFINE ("PointToPointNetDevice");
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
namespace ns3 {
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    36
NS_OBJECT_ENSURE_REGISTERED (PointToPointNetDevice);
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    37
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    38
TypeId 
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    39
PointToPointNetDevice::GetTypeId (void)
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    40
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    41
  static TypeId tid = TypeId ("ns3::PointToPointNetDevice")
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    42
    .SetParent<NetDevice> ()
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    43
    .AddConstructor<PointToPointNetDevice> ()
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    44
    .AddAttribute ("Address", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    45
                   "The MAC address of this device.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    46
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    47
                   MakeMac48AddressAccessor (&PointToPointNetDevice::m_address),
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    48
                   MakeMac48AddressChecker ())
3632
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
    49
    .AddAttribute ("FrameSize", 
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
    50
                   "The maximum size of a packet sent over this device.",
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
    51
                   UintegerValue (DEFAULT_FRAME_SIZE),
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
    52
                   MakeUintegerAccessor (&PointToPointNetDevice::SetFrameSize,
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
    53
                                         &PointToPointNetDevice::GetFrameSize),
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
    54
                   MakeUintegerChecker<uint16_t> ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    55
    .AddAttribute ("DataRate", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    56
                   "The default data rate for point to point links",
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
    57
                   DataRateValue (DataRate ("32768b/s")),
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    58
                   MakeDataRateAccessor (&PointToPointNetDevice::m_bps),
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    59
                   MakeDataRateChecker ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    60
    .AddAttribute ("ReceiveErrorModel", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    61
                   "The receiver error model used to simulate packet loss",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    62
                   PointerValue (),
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
    63
                   MakePointerAccessor (&PointToPointNetDevice::m_receiveErrorModel),
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
    64
                   MakePointerChecker<ErrorModel> ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    65
    .AddAttribute ("InterframeGap", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    66
                   "The time to wait between packet (frame) transmissions",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    67
                   TimeValue (Seconds (0.0)),
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    68
                   MakeTimeAccessor (&PointToPointNetDevice::m_tInterframeGap),
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    69
                   MakeTimeChecker ())
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    70
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    71
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    72
    // Transmit queueing discipline for the device which includes its own set
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    73
    // of trace hooks.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    74
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    75
    .AddAttribute ("TxQueue", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    76
                   "A queue to use as the transmit queue in the device.",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    77
                   PointerValue (),
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    78
                   MakePointerAccessor (&PointToPointNetDevice::m_queue),
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    79
                   MakePointerChecker<Queue> ())
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    80
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    81
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    82
    // Trace sources at the "top" of the net device, where packets transition
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    83
    // to/from higher layers.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    84
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    85
    .AddTraceSource ("MacTx", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    86
                     "Trace source indicating a packet has arrived for transmission by this device",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    87
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_macTxTrace))
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    88
    .AddTraceSource ("MacTxDrop", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    89
                     "Trace source indicating a packet has been dropped by the device before transmission",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    90
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_macTxDropTrace))
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    91
    .AddTraceSource ("MacRx", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    92
                     "Trace source indicating a packet has been received by this device and is being forwarded up the stack",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
    93
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_macRxTrace))
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    94
#if 0
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    95
    // Not currently implemented for this device
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    96
    .AddTraceSource ("MacRxDrop", 
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    97
                     "Trace source indicating a packet was dropped before being forwarded up the stack",
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    98
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_macRxDropTrace))
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    99
#endif
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   100
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   101
    // Trace souces at the "bottom" of the net device, where packets transition
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   102
    // to/from the channel.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   103
    //
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   104
    .AddTraceSource ("PhyTxBegin", 
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   105
                     "Trace source indicating a packet has begun transmitting over the channel",
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   106
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_phyTxBeginTrace))
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   107
    .AddTraceSource ("PhyTxEnd", 
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   108
                     "Trace source indicating a packet has been completely transmitted over the channel",
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   109
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_phyTxEndTrace))
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   110
    .AddTraceSource ("PhyTxDrop", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   111
                     "Trace source indicating a packet has been dropped by the device during transmission",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   112
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_phyTxDropTrace))
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   113
#if 0
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   114
    // Not currently implemented for this device
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   115
    .AddTraceSource ("PhyRxBegin", 
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   116
                     "Trace source indicating a packet has begun being received by the device",
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   117
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_phyRxBeginTrace))
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   118
#endif
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   119
    .AddTraceSource ("PhyRxEnd", 
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   120
                     "Trace source indicating a packet has been completely received by the device",
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   121
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_phyRxEndTrace))
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   122
    .AddTraceSource ("PhyRxDrop", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   123
                     "Trace source indicating a packet has been dropped by the device during reception",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   124
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_phyRxDropTrace))
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   125
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   126
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   127
    // Trace sources designed to simulate a packet sniffer facility (tcpdump).
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   128
    // Note that there is really no difference between promiscuous and 
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   129
    // non-promiscuous traces in a point-to-point link.
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   130
    //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   131
    .AddTraceSource ("Sniffer", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   132
                     "Trace source simulating a non-promiscuous packet sniffer attached to the device",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   133
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_snifferTrace))
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   134
    .AddTraceSource ("PromiscSniffer", 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   135
                     "Trace source simulating a promiscuous packet sniffer attached to the device",
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   136
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_promiscSnifferTrace))
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   137
    ;
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   138
  return tid;
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
   139
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   140
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   141
2502
50d0da37f02f introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   142
PointToPointNetDevice::PointToPointNetDevice () 
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   143
: 
379
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
   144
  m_txMachineState (READY),
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
   145
  m_channel (0), 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   146
  m_name (""),
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   147
  m_linkUp (false),
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   148
  m_currentPkt (0)
257
60d6d9bb4f9a make sure the MTU is correcrtly setup and the link is up.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
   149
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   150
  NS_LOG_FUNCTION (this);
3632
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   151
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   152
  //
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   153
  // A quick sanity check to ensure consistent constants.
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   154
  //
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   155
  PppHeader ppp;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   156
  NS_ASSERT_MSG (PPP_OVERHEAD == ppp.GetSerializedSize (), 
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   157
                 "PointToPointNetDevice::PointToPointNetDevice(): PPP_OVERHEAD inconsistent");
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   158
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   159
  m_frameSize = DEFAULT_FRAME_SIZE;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   160
  m_mtu = MtuFromFrameSize (m_frameSize);
257
60d6d9bb4f9a make sure the MTU is correcrtly setup and the link is up.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
   161
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   163
PointToPointNetDevice::~PointToPointNetDevice ()
2655
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
   164
{
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
   165
}
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
   166
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   167
  void 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   168
PointToPointNetDevice::AddHeader(Ptr<Packet> p, uint16_t protocolNumber)
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   169
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   170
  NS_LOG_FUNCTION_NOARGS ();
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   171
  NS_ASSERT_MSG (protocolNumber == 0x800, "PointToPointNetDevice::AddHeader(): protocolNumber must be 0x800");
3012
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   172
  PppHeader ppp;
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   173
  p->AddHeader (ppp);
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   174
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   175
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   176
  bool 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   177
PointToPointNetDevice::ProcessHeader(Ptr<Packet> p, uint16_t& param)
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   178
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   179
  NS_LOG_FUNCTION_NOARGS ();
3012
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   180
  PppHeader ppp;
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   181
  p->RemoveHeader (ppp);
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   182
  param = 0x800;
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   183
  return true;
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   184
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   185
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   186
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   187
PointToPointNetDevice::DoDispose()
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
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: 2834
diff changeset
   189
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   190
  m_node = 0;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 543
diff changeset
   191
  m_channel = 0;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   192
  m_receiveErrorModel = 0;
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   193
  m_currentPkt = 0;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 543
diff changeset
   194
  NetDevice::DoDispose ();
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   195
}
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   196
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   197
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   198
PointToPointNetDevice::SetDataRate(DataRate bps)
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   199
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   200
  NS_LOG_FUNCTION_NOARGS ();
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   201
  m_bps = bps;
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   204
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   205
PointToPointNetDevice::SetInterframeGap(Time t)
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   206
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   207
  NS_LOG_FUNCTION_NOARGS ();
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   208
  m_tInterframeGap = t;
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   209
}
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   210
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   211
  bool
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   212
PointToPointNetDevice::TransmitStart (Ptr<Packet> p)
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   213
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   214
  NS_LOG_FUNCTION (this << p);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   215
  NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   216
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   217
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   218
  // This function is called to start the process of transmitting a packet.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   219
  // We need to tell the channel that we've started wiggling the wire and
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   220
  // schedule an event that will be executed when the transmission is complete.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   221
  //
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   222
  NS_ASSERT_MSG(m_txMachineState == READY, "Must be READY to transmit");
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   223
  m_txMachineState = BUSY;
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   224
  m_phyTxBeginTrace (m_currentPkt);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   225
  m_currentPkt = p;
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   226
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   227
  Time txTime = Seconds (m_bps.CalculateTxTime(p->GetSize()));
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   228
  Time txCompleteTime = txTime + m_tInterframeGap;
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   229
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   230
  NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec");
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   231
  Simulator::Schedule (txCompleteTime, &PointToPointNetDevice::TransmitComplete, this);
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   232
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   233
  bool result = m_channel->TransmitStart(p, this, txTime); 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   234
  if (result == false)
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   235
    {
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   236
      m_phyTxDropTrace (p);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   237
    }
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   238
  return result;
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   239
}
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   240
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   241
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   242
PointToPointNetDevice::TransmitComplete (void)
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   243
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   244
  NS_LOG_FUNCTION_NOARGS ();
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   245
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   246
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   247
  // This function is called to when we're all done transmitting a packet.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   248
  // We try and pull another packet off of the transmit queue.  If the queue
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   249
  // is empty, we are done, otherwise we need to start transmitting the
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   250
  // next packet.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   251
  //
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   252
  NS_ASSERT_MSG(m_txMachineState == BUSY, "Must be BUSY if transmitting");
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   253
  m_txMachineState = READY;
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   254
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   255
  NS_ASSERT_MSG (m_currentPkt != 0, "PointToPointNetDevice::TransmitComplete(): m_currentPkt zero");
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   256
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   257
  m_phyTxEndTrace (m_currentPkt);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   258
  m_currentPkt = 0;
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   259
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   260
  Ptr<Packet> p = m_queue->Dequeue ();
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   261
  if (p == 0)
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   262
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   263
      //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   264
      // No packet was on the queue, so we just exit.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   265
      //
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   266
      return;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   267
    }
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   268
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   269
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   270
  // Got another packet off of the queue, so start the transmit process agin.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   271
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   272
  m_snifferTrace (p);
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   273
  m_promiscSnifferTrace (p);
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   274
  TransmitStart(p);
773
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   275
}
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   276
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   277
  bool 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   278
PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   279
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   280
  NS_LOG_FUNCTION (this << &ch);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   281
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   282
  m_channel = ch;
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   283
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   284
  m_channel->Attach(this);
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   285
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   286
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   287
  // This device is up whenever it is attached to a channel.  A better plan
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   288
  // would be to have the link come up when both devices are attached, but this
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   289
  // is not done for now.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   290
  //
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   291
  NotifyLinkUp ();
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   292
  return true;
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   293
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   294
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   295
  void
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   296
PointToPointNetDevice::SetQueue (Ptr<Queue> q)
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 331
diff changeset
   297
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   298
  NS_LOG_FUNCTION (this << q);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   299
  m_queue = q;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   300
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   301
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   302
  void
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   303
PointToPointNetDevice::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: 1508
diff changeset
   304
{
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
   305
  NS_LOG_FUNCTION (this << em);
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   306
  m_receiveErrorModel = em;
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   307
}
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   308
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   309
 void
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   310
PointToPointNetDevice::Receive (Ptr<Packet> packet)
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   311
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   312
  NS_LOG_FUNCTION (this << packet);
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   313
  uint16_t protocol = 0;
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   314
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1866
diff changeset
   315
  if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) ) 
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   316
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   317
      // 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   318
      // If we have an error model and it indicates that it is time to lose a
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   319
      // corrupted packet, don't forward this packet up, let it go.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   320
      //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   321
      m_phyRxDropTrace (packet);
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   322
    }
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   323
  else 
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   324
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   325
      // 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   326
      // Hit the trace hooks.  All of these hooks are in the same place in this 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   327
      // device becuase it is so simple, but this is not usually the case.  
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   328
      //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   329
      m_snifferTrace (packet);
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   330
      m_promiscSnifferTrace (packet);
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   331
      m_phyRxEndTrace (packet);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   332
      m_macRxTrace (packet);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   333
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   334
      //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   335
      // Strip off the point-to-point protocol header and forward this packet
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   336
      // up the protocol stack.  Since this is a simple point-to-point link,
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   337
      // there is no difference in what the promisc callback sees and what the
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   338
      // normal receive callback sees.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   339
      //
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   340
      ProcessHeader(packet, protocol);
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   341
3584
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   342
      if (!m_promiscCallback.IsNull ())
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   343
        {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   344
          Ptr<Packet> pktCopy = packet->Copy ();
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   345
          m_promiscCallback (this, pktCopy, protocol, GetRemote (), GetAddress (), NetDevice::PACKET_HOST);
3584
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   346
        }
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   347
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   348
      m_rxCallback (this, packet, protocol, GetRemote ());
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   349
    }
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 331
diff changeset
   350
}
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 331
diff changeset
   351
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   352
  Ptr<Queue> 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   353
PointToPointNetDevice::GetQueue(void) const 
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   354
{ 
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   355
  NS_LOG_FUNCTION_NOARGS ();
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   356
  return m_queue;
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   357
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   358
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   359
  void
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   360
PointToPointNetDevice::NotifyLinkUp (void)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   361
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   362
  m_linkUp = true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   363
  if (!m_linkChangeCallback.IsNull ())
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   364
    {
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   365
      m_linkChangeCallback ();
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   366
    }
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   367
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   368
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   369
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   370
PointToPointNetDevice::SetName(const std::string name)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   371
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   372
  m_name = name;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   373
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   374
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   375
  std::string 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   376
PointToPointNetDevice::GetName(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   377
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   378
  return m_name;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   379
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   380
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   381
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   382
PointToPointNetDevice::SetIfIndex(const uint32_t index)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   383
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   384
  m_ifIndex = index;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   385
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   386
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   387
  uint32_t 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   388
PointToPointNetDevice::GetIfIndex(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   389
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   390
  return m_ifIndex;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   391
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   392
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   393
  Ptr<Channel> 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   394
PointToPointNetDevice::GetChannel (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   395
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   396
  return m_channel;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   397
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   398
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   399
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   400
// This is a point-to-point device, so we really don't need any kind of address
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   401
// information.  However, the base class NetDevice wants us to define the
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   402
// methods to get and set the address.  Rather than be rude and assert, we let
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   403
// clients get and set the address, but simply ignore them.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   404
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   405
PointToPointNetDevice::SetAddress (Mac48Address addr)
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   406
{
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   407
  m_address = addr;
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   408
}
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   409
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   410
  Address 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   411
PointToPointNetDevice::GetAddress (void) const
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   412
{
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   413
  return m_address;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   414
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   415
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   416
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   417
PointToPointNetDevice::IsLinkUp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   418
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   419
  return m_linkUp;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   420
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   421
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   422
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   423
PointToPointNetDevice::SetLinkChangeCallback (Callback<void> callback)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   424
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   425
  m_linkChangeCallback = callback;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   426
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   427
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   428
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   429
// This is a point-to-point device, so every transmission is a broadcast to
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   430
// all of the devices on the network.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   431
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   432
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   433
PointToPointNetDevice::IsBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   434
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   435
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   436
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   437
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   438
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   439
// We don't really need any addressing information since this is a 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   440
// point-to-point device.  The base class NetDevice wants us to return a
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   441
// broadcast address, so we make up something reasonable.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   442
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   443
  Address
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   444
PointToPointNetDevice::GetBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   445
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   446
  return Mac48Address ("ff:ff:ff:ff:ff:ff");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   447
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   448
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   449
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   450
// We don't deal with multicast here.  It doesn't make sense to include some
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   451
// of the one destinations on the network but exclude some of the others.
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
   452
//
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   453
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   454
PointToPointNetDevice::IsMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   455
{
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   456
  return false;
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   457
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   458
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   459
  Address 
3841
1e7abf5fca79 Apply Patch to address bug 294 -- due to vincent
Craig Dowell <craigdo@ee.washington.edu>
parents: 3682
diff changeset
   460
PointToPointNetDevice::GetMulticast (Ipv4Address multicastGroup) const
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   461
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   462
  return Mac48Address ("01:00:5e:00:00:00");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   463
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   464
3852
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
   465
Address
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
   466
PointToPointNetDevice::GetMulticast (Ipv6Address addr) const
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
   467
{
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
   468
  NS_LOG_FUNCTION(this << addr);
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
   469
  return Mac48Address ("33:33:00:00:00:00");
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
   470
}
9cf7ad0cac85 Initial IPv6 capability
vincent@clarinet.u-strasbg.fr
parents: 3841
diff changeset
   471
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   472
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   473
PointToPointNetDevice::IsPointToPoint (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   474
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   475
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   476
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   477
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   478
  bool 
3936
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3852
diff changeset
   479
PointToPointNetDevice::IsBridge (void) const
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3852
diff changeset
   480
{
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3852
diff changeset
   481
  return false;
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3852
diff changeset
   482
}
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3852
diff changeset
   483
e525995ce5dc implement IsBridged for net devices
Craig Dowell <craigdo@ee.washington.edu>
parents: 3852
diff changeset
   484
  bool 
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   485
PointToPointNetDevice::Send(
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   486
  Ptr<Packet> packet, 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   487
  const Address &dest, 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   488
  uint16_t protocolNumber)
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   489
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
   490
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   491
  NS_LOG_LOGIC ("p=" << packet << ", dest=" << &dest);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   492
  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   493
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   494
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   495
  // If IsLinkUp() is false it means there is no channel to send any packet 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   496
  // over so we just hit the drop trace on the packet and return an error.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   497
  //
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   498
  if (IsLinkUp () == false)
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   499
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   500
      m_macTxDropTrace (packet);
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   501
      return false;
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   502
    }
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   503
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   504
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   505
  // Stick a point to point protocol header on the packet in preparation for
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   506
  // shoving it out the door.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   507
  //
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   508
  AddHeader(packet, protocolNumber);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   509
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   510
  m_macTxTrace (packet);
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   511
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   512
  //
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   513
  // If there's a transmission in progress, we enque the packet for later
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   514
  // transmission; otherwise we send it now.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   515
  //
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   516
  if (m_txMachineState == READY) 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   517
    {
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   518
      // 
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   519
      // Even if the transmitter is immediately available, we still enqueue and
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   520
      // dequeue the packet to hit the tracing hooks.
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   521
      //
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   522
      m_queue->Enqueue (packet);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   523
      packet = m_queue->Dequeue ();
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4011
diff changeset
   524
      m_snifferTrace (packet);
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   525
      m_promiscSnifferTrace (packet);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   526
      return TransmitStart (packet);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   527
    }
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   528
  else
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   529
    {
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   530
      return m_queue->Enqueue(packet);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   531
    }
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   532
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   533
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: 3435
diff changeset
   534
bool
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: 3435
diff changeset
   535
PointToPointNetDevice::SendFrom (Ptr<Packet> packet, 
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: 3435
diff changeset
   536
                                 const Address &source, 
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: 3435
diff changeset
   537
                                 const Address &dest, 
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: 3435
diff changeset
   538
                                 uint16_t 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: 3435
diff changeset
   539
{
3584
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   540
  return false;
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: 3435
diff changeset
   541
}
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: 3435
diff changeset
   542
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   543
  Ptr<Node> 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   544
PointToPointNetDevice::GetNode (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   545
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   546
  return m_node;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   547
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   548
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   549
  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: 2502
diff changeset
   550
PointToPointNetDevice::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: 2502
diff changeset
   551
{
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: 2502
diff changeset
   552
  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: 2502
diff changeset
   553
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   554
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   555
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   556
PointToPointNetDevice::NeedsArp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   557
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   558
  return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   559
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   560
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   561
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   562
PointToPointNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   563
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   564
  m_rxCallback = cb;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   565
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   566
3584
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   567
void
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   568
PointToPointNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb)
3480
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   569
{
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   570
  NS_FATAL_ERROR ("not implemented");
3584
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   571
  m_promiscCallback = cb;
3480
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   572
}
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   573
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   574
  bool
3584
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   575
PointToPointNetDevice::SupportsSendFrom (void) const
3480
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   576
{
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   577
  return false;
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   578
}
a920df6b9f02 Make the new NetDevice APIs pure virtual methods, by Mathieu's insistence.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3460
diff changeset
   579
3584
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   580
Address 
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   581
PointToPointNetDevice::GetRemote (void) const
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   582
{
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   583
  NS_ASSERT (m_channel->GetNDevices () == 2);
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   584
  for (uint32_t i = 0; i < m_channel->GetNDevices (); ++i)
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   585
    {
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   586
      Ptr<NetDevice> tmp = m_channel->GetDevice (i);
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   587
      if (tmp != this)
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   588
        {
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   589
          return tmp->GetAddress ();
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   590
        }
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   591
    }
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   592
  NS_ASSERT (false);
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   593
  // quiet compiler.
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   594
  return Address ();
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   595
}
4eb48239b4dc bug 274: bridge must detect compatibility of devices with bridging mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3480
diff changeset
   596
3682
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   597
  uint32_t
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   598
PointToPointNetDevice::MtuFromFrameSize (uint32_t frameSize)
3632
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   599
{
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   600
  NS_LOG_FUNCTION (frameSize);
3682
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   601
  NS_ASSERT_MSG (frameSize <= std::numeric_limits<uint16_t>::max (), 
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   602
                 "PointToPointNetDevice::MtuFromFrameSize(): Frame size should be derived from 16-bit quantity: " << 
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   603
                 frameSize);
3632
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   604
  PppHeader ppp;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   605
  NS_ASSERT_MSG ((uint32_t)frameSize >= ppp.GetSerializedSize (), 
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   606
                 "PointToPointNetDevice::MtuFromFrameSize(): Given frame size too small to support PPP");
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   607
  return frameSize - ppp.GetSerializedSize ();
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   608
}
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   609
  
3682
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   610
  uint32_t
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   611
PointToPointNetDevice::FrameSizeFromMtu (uint32_t mtu)
3632
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   612
{
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   613
  NS_LOG_FUNCTION (mtu);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   614
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   615
  PppHeader ppp;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   616
  return mtu + ppp.GetSerializedSize ();
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   617
}
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   618
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   619
  void 
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   620
PointToPointNetDevice::SetFrameSize (uint16_t frameSize)
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   621
{
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   622
  NS_LOG_FUNCTION (frameSize);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   623
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   624
  m_frameSize = frameSize;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   625
  m_mtu = MtuFromFrameSize (frameSize);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   626
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   627
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   628
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   629
}
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   630
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   631
  uint16_t
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   632
PointToPointNetDevice::GetFrameSize (void) const
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   633
{
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   634
  return m_frameSize;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   635
}
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   636
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   637
  bool
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   638
PointToPointNetDevice::SetMtu (uint16_t mtu)
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   639
{
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   640
  NS_LOG_FUNCTION (mtu);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   641
3682
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   642
  uint32_t newFrameSize = FrameSizeFromMtu (mtu);
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   643
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   644
  if (newFrameSize > std::numeric_limits<uint16_t>::max ())
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   645
    {
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   646
      NS_LOG_WARN ("PointToPointNetDevice::SetMtu(): Frame size overflow, MTU not set.");
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   647
      return false;
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   648
    }
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   649
cef8288d30ae fix bug 338, MTU overflows frameSize
Craig Dowell <craigdo@ee.washington.edu>
parents: 3632
diff changeset
   650
  m_frameSize = newFrameSize;
3632
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   651
  m_mtu = mtu;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   652
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   653
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   654
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   655
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   656
  return true;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   657
}
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   658
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   659
  uint16_t
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   660
PointToPointNetDevice::GetMtu (void) const
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   661
{
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   662
  NS_LOG_FUNCTION_NOARGS ();
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   663
  return m_mtu;
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   664
}
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   665
aa1fb0f43571 apply MTU/FrameSize treatment to point-to-point
craigdo@ns-test
parents: 3584
diff changeset
   666
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   667
} // namespace ns3