src/devices/point-to-point/point-to-point-net-device.cc
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 16 Jul 2008 16:06:50 +0100
changeset 3460 99698bc858e8
parent 3448 0bd851bb1225
child 3480 a920df6b9f02
permissions -rw-r--r--
New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
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"
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
    26
#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
    27
#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
    28
#include "point-to-point-channel.h"
3012
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
    29
#include "ppp-header.h"
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    30
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    31
NS_LOG_COMPONENT_DEFINE ("PointToPointNetDevice");
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
namespace ns3 {
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
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
    35
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
    36
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
    37
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
    38
PointToPointNetDevice::GetTypeId (void)
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    39
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    40
  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
    41
    .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
    42
    .AddConstructor<PointToPointNetDevice> ()
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    43
    .AddAttribute ("Address", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    44
                   "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
    45
                   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
    46
                   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
    47
                   MakeMac48AddressChecker ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    48
    .AddAttribute ("DataRate", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    49
                   "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
    50
                   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
    51
                   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
    52
                   MakeDataRateChecker ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    53
    .AddAttribute ("ReceiveErrorModel", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    54
                   "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
    55
                   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
    56
                   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
    57
                   MakePointerChecker<ErrorModel> ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    58
    .AddAttribute ("TxQueue",
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    59
                   "A queue to use as the transmit queue in the device.",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2927
diff changeset
    60
                   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
    61
                   MakePointerAccessor (&PointToPointNetDevice::m_queue),
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
    62
                   MakePointerChecker<Queue> ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    63
    .AddAttribute ("InterframeGap", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    64
                   "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
    65
                   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
    66
                   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
    67
                   MakeTimeChecker ())
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    68
    .AddTraceSource ("Rx", 
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    69
                     "Trace source to fire on reception of a MAC packet.",
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
    70
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_rxTrace))
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    71
    .AddTraceSource ("Drop",
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    72
                     "Trace source to fire on when a MAC packet is dropped.",
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    73
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
    74
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_dropTrace))
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    75
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
    76
    ;
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
    77
  return tid;
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    78
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    79
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    80
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
    81
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
    82
: 
379
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    83
  m_txMachineState (READY),
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    84
  m_channel (0), 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    85
  m_name (""),
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    86
  m_linkUp (false),
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    87
  m_mtu (0xffff)
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
    88
{
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
    89
  NS_LOG_FUNCTION (this);
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
    90
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    92
PointToPointNetDevice::~PointToPointNetDevice ()
2655
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    93
{
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    94
}
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    95
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
    96
  void 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
    97
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
    98
{
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
    99
  NS_LOG_FUNCTION_NOARGS ();
3012
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   100
  NS_ASSERT_MSG (protocolNumber == 0x800,
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   101
    "PointToPointNetDevice::AddHeader(): protocolNumber must be 0x800");
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   102
  PppHeader ppp;
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   103
  p->AddHeader (ppp);
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   104
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   105
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   106
  bool 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   107
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
   108
{
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
   109
  NS_LOG_FUNCTION_NOARGS ();
3012
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   110
  PppHeader ppp;
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   111
  p->RemoveHeader (ppp);
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
   112
  param = 0x800;
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   113
  return true;
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   114
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   115
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   116
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   117
PointToPointNetDevice::DoDispose()
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   118
{
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
   119
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   120
  m_node = 0;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 543
diff changeset
   121
  m_channel = 0;
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   122
  m_receiveErrorModel = 0;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 543
diff changeset
   123
  NetDevice::DoDispose ();
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   124
}
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   125
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   126
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   127
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
   128
{
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
   129
  NS_LOG_FUNCTION_NOARGS ();
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   130
  m_bps = bps;
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   133
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   134
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
   135
{
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
   136
  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
   137
  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
   138
}
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   139
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   140
  bool
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   141
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
   142
{
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
   143
  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
   144
  NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   145
//
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   146
// This function is called to start the process of transmitting a packet.
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   147
// We need to tell the channel that we've started wiggling the wire and
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   148
// schedule an event that will be executed when the transmission is complete.
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   149
//
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   150
  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
   151
  m_txMachineState = BUSY;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   152
  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
   153
  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
   154
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   155
  NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << 
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   156
    txCompleteTime.GetSeconds () << "sec");
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   157
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   158
  Simulator::Schedule (txCompleteTime, 
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   159
    &PointToPointNetDevice::TransmitComplete, this);
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   160
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   161
  return m_channel->TransmitStart(p, this, txTime); 
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   162
}
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   163
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   164
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   165
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
   166
{
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
   167
  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
   168
//
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   169
// This function is called to when we're all done transmitting a packet.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   170
// We try and pull another packet off of the transmit queue.  If the queue
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   171
// is empty, we are done, otherwise we need to start transmitting the
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   172
// next packet.
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   173
//
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   174
  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
   175
  m_txMachineState = READY;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   176
  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
   177
  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
   178
    {
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   179
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   180
// No packet was on the queue, so we just exit.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   181
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   182
      return;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   183
    }
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   184
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   185
// Got another packet off of the queue, so start the transmit process agin.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   186
//
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   187
  TransmitStart(p);
773
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   188
}
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   189
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   190
  bool 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   191
PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   192
{
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
   193
  NS_LOG_FUNCTION (this << &ch);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   194
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   195
  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
   196
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   197
  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
   198
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   199
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   200
// This device is up whenever it is attached to a channel.  A better plan
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   201
// would be to have the link come up when both devices are attached, but this
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   202
// is not done for now.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   203
//
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   204
  NotifyLinkUp ();
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   205
  return true;
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   208
  void
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   209
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
   210
{
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
   211
  NS_LOG_FUNCTION (this << q);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   212
  m_queue = q;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   213
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   214
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   215
  void
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   216
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
   217
{
3321
f3c86a2d4082 bug 233
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
   218
  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
   219
  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
   220
}
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   221
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   222
 void
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   223
PointToPointNetDevice::Receive (Ptr<Packet> packet)
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   224
{
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
   225
  NS_LOG_FUNCTION (this << packet);
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   226
  uint16_t protocol = 0;
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   227
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1866
diff changeset
   228
  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
   229
    {
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   230
// 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   231
// If we have an error model and it indicates that it is time to lose a
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   232
// corrupted packet, don't forward this packet up, let it go.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   233
//
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   234
      m_dropTrace (packet);
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   235
    }
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   236
  else 
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   237
    {
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   238
// 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   239
// Hit the receive trace hook, strip off the point-to-point protocol header
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   240
// and forward this packet up the protocol stack.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   241
//
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   242
      m_rxTrace (packet);
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   243
      ProcessHeader(packet, protocol);
3460
99698bc858e8 New API considering comments from Craig: NetDevice->Node uses two callbacks; Node->ProtocolHandlers uses a single API with a promiscuous flag.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3448
diff changeset
   244
      m_rxCallback (this, packet, protocol, GetBroadcast ());
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   245
    }
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
   246
}
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 331
diff changeset
   247
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   248
  Ptr<Queue> 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   249
PointToPointNetDevice::GetQueue(void) const 
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   250
{ 
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
   251
  NS_LOG_FUNCTION_NOARGS ();
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   252
  return m_queue;
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   253
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   254
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   255
  void
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   256
PointToPointNetDevice::NotifyLinkUp (void)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   257
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   258
  m_linkUp = true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   259
  if (!m_linkChangeCallback.IsNull ())
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   260
    {
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   261
      m_linkChangeCallback ();
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   262
    }
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   263
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   264
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   265
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   266
PointToPointNetDevice::SetName(const std::string name)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   267
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   268
  m_name = name;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   269
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   270
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   271
  std::string 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   272
PointToPointNetDevice::GetName(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   273
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   274
  return m_name;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   275
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   276
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   277
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   278
PointToPointNetDevice::SetIfIndex(const uint32_t index)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   279
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   280
  m_ifIndex = index;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   281
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   282
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   283
  uint32_t 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   284
PointToPointNetDevice::GetIfIndex(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   285
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   286
  return m_ifIndex;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   287
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   288
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   289
  Ptr<Channel> 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   290
PointToPointNetDevice::GetChannel (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   291
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   292
  return m_channel;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   293
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   294
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   295
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   296
// 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
   297
// 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
   298
// 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
   299
// 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
   300
  void 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   301
PointToPointNetDevice::SetAddress (Mac48Address addr)
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   302
{
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   303
  m_address = addr;
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   304
}
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   305
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   306
  Address 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   307
PointToPointNetDevice::GetAddress (void) const
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   308
{
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   309
  return m_address;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   310
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   311
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   312
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   313
PointToPointNetDevice::SetMtu (const uint16_t mtu)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   314
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   315
  m_mtu = mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   316
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   317
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   318
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   319
  uint16_t 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   320
PointToPointNetDevice::GetMtu (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   321
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   322
  return m_mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   323
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   324
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   325
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   326
PointToPointNetDevice::IsLinkUp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   327
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   328
  return m_linkUp;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   329
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   330
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   331
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   332
PointToPointNetDevice::SetLinkChangeCallback (Callback<void> callback)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   333
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   334
  m_linkChangeCallback = callback;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   335
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   336
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   337
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   338
// 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
   339
// all of the devices on the network.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   340
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   341
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   342
PointToPointNetDevice::IsBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   343
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   344
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   345
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   346
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   347
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   348
// 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
   349
// 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
   350
// broadcast address, so we make up something reasonable.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   351
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   352
  Address
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   353
PointToPointNetDevice::GetBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   354
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   355
  return Mac48Address ("ff:ff:ff:ff:ff:ff");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   356
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   357
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   358
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   359
// 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
   360
// 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
   361
//
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   362
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   363
PointToPointNetDevice::IsMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   364
{
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   365
  return false;
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   366
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   367
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   368
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   369
// Since we return false in the IsMulticast call, calls to other multicast
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   370
// related methods returns are undefined according to the base class.  So we
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   371
// can freely make something up, which is the base of the MAC multicast
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   372
// address space.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   373
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   374
  Address 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   375
PointToPointNetDevice::GetMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   376
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   377
  return Mac48Address ("01:00:5e:00:00:00");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   378
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   379
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   380
  Address 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   381
PointToPointNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   382
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   383
  return Mac48Address ("01:00:5e:00:00:00");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   384
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   385
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   386
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   387
PointToPointNetDevice::IsPointToPoint (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   388
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   389
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   390
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   391
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   392
  bool 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   393
PointToPointNetDevice::Send(
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   394
  Ptr<Packet> packet, 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   395
  const Address &dest, 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   396
  uint16_t protocolNumber)
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   397
{
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
   398
  NS_LOG_FUNCTION_NOARGS ();
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   399
  NS_LOG_LOGIC ("p=" << packet << ", dest=" << &dest);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   400
  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   401
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   402
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   403
// If IsLinkUp() is false it means there is no channel to send any packet 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   404
// over so we just return an error.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   405
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   406
  if (IsLinkUp () == false)
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   407
    {
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   408
      return false;
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
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   411
//
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   412
// Stick a point to point protocol header on the packet in preparation for
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   413
// shoving it out the door.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   414
//
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   415
  AddHeader(packet, protocolNumber);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   416
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   417
//
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   418
// If there's a transmission in progress, we enque the packet for later
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   419
// transmission; otherwise we send it now.
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   420
//
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   421
  if (m_txMachineState == READY) 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   422
    {
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   423
// 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   424
// Even if the transmitter is immediately available, we still enqueue and 
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   425
// dequeue the packet to hit the tracing hooks.
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   426
//
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   427
      m_queue->Enqueue (packet);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   428
      packet = m_queue->Dequeue ();
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   429
      return TransmitStart (packet);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   430
    }
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   431
  else
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   432
    {
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   433
      return m_queue->Enqueue(packet);
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
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   436
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
   437
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
   438
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
   439
                                 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
   440
                                 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
   441
                                 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
   442
{
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
   443
  return Send (packet, dest, protocolNumber);
8eef02250bc9 Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3435
diff changeset
   444
}
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
   445
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   446
  Ptr<Node> 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   447
PointToPointNetDevice::GetNode (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   448
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   449
  return m_node;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   450
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   451
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   452
  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
   453
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
   454
{
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
   455
  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
   456
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   457
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   458
  bool 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   459
PointToPointNetDevice::NeedsArp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   460
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   461
  return false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   462
}
3181
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   463
26e7f865c548 point-to-point cleanup
Craig Dowell <craigdo@ee.washington.edu>
parents: 3086
diff changeset
   464
  void 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   465
PointToPointNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   466
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   467
  m_rxCallback = cb;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   468
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   469
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   470
} // namespace ns3