src/devices/point-to-point/point-to-point-net-device.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 26 Mar 2008 16:12:36 -0700
changeset 2759 942d60eb5b23
parent 2758 7f5763b97579
child 2834 1aab57845b07
permissions -rw-r--r--
use an attribute name which matches the member variable and method
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
/*
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     3
 * Copyright (c) 2005,2006 INRIA
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     4
 * All rights reserved.
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     5
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     6
 * 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
     7
 * 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
     8
 * published by the Free Software Foundation;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
     9
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    10
 * 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
    11
 * 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
    12
 * 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
    13
 * GNU General Public License for more details.
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    14
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    15
 * 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
    16
 * 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
    17
 * 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
    18
 *
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    19
 * Author:  Craig Dowell <craigdo@ee.washington.edu>
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    20
 * Revised: George Riley <riley@ece.gatech.edu>
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    21
 */
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    23
#include "ns3/log.h"
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    24
#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
    25
#include "ns3/simulator.h"
1494
c2985e1cd091 rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
    26
#include "ns3/mac48-address.h"
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
    27
#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
    28
#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
    29
#include "ns3/trace-source-accessor.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
    30
#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
    31
#include "point-to-point-channel.h"
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    32
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    33
NS_LOG_COMPONENT_DEFINE ("PointToPointNetDevice");
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
namespace ns3 {
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
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
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
    38
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
    39
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
    40
PointToPointNetDevice::GetTypeId (void)
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    41
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
    42
  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
    43
    .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
    44
    .AddConstructor<PointToPointNetDevice> ()
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
    45
    .AddAttribute ("Address", "The address of this device.",
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
                   Mac48Address ("ff:ff:ff:ff:ff:ff"),
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 ())
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
    49
    .AddAttribute ("DataRate", "The default data rate for point to point links",
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
    50
                   DataRate ("10Mb/s"),
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 ())
2759
942d60eb5b23 use an attribute name which matches the member variable and method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2758
diff changeset
    53
    .AddAttribute ("ReceiveErrorModel", "XXX",
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
    54
                   Ptr<ErrorModel> (0),
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
    55
                   MakePtrAccessor (&PointToPointNetDevice::m_receiveErrorModel),
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
    56
                   MakePtrChecker<ErrorModel> ())
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
    57
    .AddAttribute ("TxQueue", "XXX",
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
                   Ptr<Queue> (0),
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
                   MakePtrAccessor (&PointToPointNetDevice::m_queue),
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
    60
                   MakePtrChecker<Queue> ())
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
    61
    .AddAttribute ("InterframeGap", "XXX",
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
    62
                   Seconds (0.0),
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
    63
                   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
    64
                   MakeTimeChecker ())
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
    65
    .AddTraceSource ("Rx", "Receive MAC packet.",
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
                     MakeTraceSourceAccessor (&PointToPointNetDevice::m_rxTrace))
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
    .AddTraceSource ("Drop", "Drop MAC packet.",
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
                     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
    69
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
    ;
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
    71
  return tid;
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    72
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    73
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    74
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
    75
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
    76
: 
379
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    77
  m_txMachineState (READY),
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    78
  m_channel (0), 
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    79
  m_name (""),
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    80
  m_linkUp (false),
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    81
  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
    82
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    83
  NS_LOG_FUNCTION;
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
    84
  NS_LOG_PARAMS (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
    85
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    87
PointToPointNetDevice::~PointToPointNetDevice ()
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
    88
{}
379
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    89
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
    90
void 
2655
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    91
PointToPointNetDevice::SetAddress (Mac48Address self)
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    92
{
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    93
  m_address = self;
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
a71d888ca2e8 add SetAddress methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
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
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    99
  NS_LOG_FUNCTION;
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   100
  LlcSnapHeader llc;
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   101
  llc.SetType (protocolNumber);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   102
  p->AddHeader (llc);
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   103
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   104
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   105
bool 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   106
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
   107
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   108
  NS_LOG_FUNCTION;
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   109
  LlcSnapHeader llc;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   110
  p->RemoveHeader (llc);
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   111
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   112
  param = llc.GetType ();
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   113
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   114
  return true;
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   115
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   116
517
702e96b8960f finish Dispose -> DoDispose rework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 471
diff changeset
   117
void PointToPointNetDevice::DoDispose()
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   118
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   119
  NS_LOG_FUNCTION;
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
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   126
void PointToPointNetDevice::SetDataRate(const 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
   127
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   128
  NS_LOG_FUNCTION;
1825
1544b7c8aa18 minor fix for bug95; also const operators for DataRate
Tom Henderson <tomh@tomh.org>
parents: 1820
diff changeset
   129
  if (!m_channel || bps <= m_channel->GetDataRate ())
1544b7c8aa18 minor fix for bug95; also const operators for DataRate
Tom Henderson <tomh@tomh.org>
parents: 1820
diff changeset
   130
    {
1544b7c8aa18 minor fix for bug95; also const operators for DataRate
Tom Henderson <tomh@tomh.org>
parents: 1820
diff changeset
   131
      m_bps = bps;
1544b7c8aa18 minor fix for bug95; also const operators for DataRate
Tom Henderson <tomh@tomh.org>
parents: 1820
diff changeset
   132
    }
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   135
void PointToPointNetDevice::SetInterframeGap(const 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
   136
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   137
  NS_LOG_FUNCTION;
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   138
  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
   139
}
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   140
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   141
bool
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   142
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
   143
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   144
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1866
diff changeset
   145
  NS_LOG_PARAMS (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
   146
  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
   147
//
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   148
// 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
   149
// 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
   150
// 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
   151
//
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   152
  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
   153
  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
   154
  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
   155
  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
   156
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   157
  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
   158
    txCompleteTime.GetSeconds () << "sec");
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   159
  // Schedule the tx complete event
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   160
  Simulator::Schedule (txCompleteTime, 
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   161
                       &PointToPointNetDevice::TransmitComplete, 
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
                       this);
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   163
  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
   164
}
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   165
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   166
void 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
   167
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   168
  NS_LOG_FUNCTION;
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   169
//
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   170
// This function is called to finish 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
   171
// We need to tell the channel that we've stopped 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
   172
// get the next packet from the queue.  If the queue is empty, we are
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   173
// done, otherwise transmit the 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
   174
//
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   175
  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
   176
  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
   177
  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
   178
  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
   179
    {
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   180
      return; // Nothing to do at this point
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   181
    }
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   182
  TransmitStart(p);
773
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   183
}
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   184
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   185
bool 
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   186
PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   188
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1825
diff changeset
   189
  NS_LOG_PARAMS (this << &ch);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   190
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   191
  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
   192
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   193
  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
   194
  m_bps = m_channel->GetDataRate ();
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   195
  // GFR Comment.  Below is definitely wrong.  Interframe gap
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   196
  // is unrelated to channel delay.
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   197
  // -- unlesss you want to introduce a default gap which is there to avoid
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   198
  // parts of multiple packets flowing on the "wire" at the same time.
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   199
  //m_tInterframeGap = m_channel->GetDelay ();
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   200
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   201
  /* 
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   202
   * For now, this device is up whenever a channel is attached to it.
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   203
   * In fact, it should become up only when the second device
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   204
   * is attached to the channel. So, there should be a way for
369
29ea5d1a83c8 Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents: 368
diff changeset
   205
   * a PointToPointChannel to notify both of its attached devices
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   206
   * that the channel is 'complete', hence that the devices are
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   207
   * up, hence that they can call NotifyLinkUp. 
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   208
   */
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   209
  NotifyLinkUp ();
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   210
  return true;
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   211
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   213
void PointToPointNetDevice::AddQueue (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
   214
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   215
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1825
diff changeset
   216
  NS_LOG_PARAMS (this << q);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   217
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   218
  m_queue = q;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   219
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   220
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   221
void PointToPointNetDevice::AddReceiveErrorModel (Ptr<ErrorModel> em)
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   222
{
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   223
  NS_LOG_FUNCTION;
2203
a83b182ea948 Fix small typo
Tom Henderson <tomh@tomh.org>
parents: 1874
diff changeset
   224
  NS_LOG_PARAMS ("(" << 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
   225
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   226
  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
   227
}
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   228
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1508
diff changeset
   229
void PointToPointNetDevice::Receive (Ptr<Packet> packet)
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   230
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   231
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1866
diff changeset
   232
  NS_LOG_PARAMS (this << packet);
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   233
  uint16_t protocol = 0;
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   234
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1866
diff changeset
   235
  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
   236
    {
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   237
      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
   238
      // Do not forward up; let this packet go
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   239
    }
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   240
  else 
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   241
    {
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);
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
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
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   248
Ptr<Queue> PointToPointNetDevice::GetQueue(void) const 
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   249
{ 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   250
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   251
  return m_queue;
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   252
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   254
void
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   255
PointToPointNetDevice::NotifyLinkUp (void)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   256
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   257
  m_linkUp = true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   258
  if (!m_linkChangeCallback.IsNull ())
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   259
    {
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   260
      m_linkChangeCallback ();
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   261
    }
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   262
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   263
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   264
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   265
PointToPointNetDevice::SetName(const std::string name)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   266
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   267
  m_name = name;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   268
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   269
std::string 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   270
PointToPointNetDevice::GetName(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   271
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   272
  return m_name;
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
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   275
PointToPointNetDevice::SetIfIndex(const uint32_t index)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   276
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   277
  m_ifIndex = index;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   278
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   279
uint32_t 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   280
PointToPointNetDevice::GetIfIndex(void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   281
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   282
  return m_ifIndex;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   283
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   284
Ptr<Channel> 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   285
PointToPointNetDevice::GetChannel (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   286
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   287
  return m_channel;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   288
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   289
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   290
PointToPointNetDevice::GetAddress (void) const
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   291
{
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   292
  return m_address;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   293
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   294
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   295
PointToPointNetDevice::SetMtu (const uint16_t mtu)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   296
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   297
  m_mtu = mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   298
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   299
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   300
uint16_t 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   301
PointToPointNetDevice::GetMtu (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   302
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   303
  return m_mtu;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   304
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   305
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   306
PointToPointNetDevice::IsLinkUp (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   307
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   308
  return m_linkUp;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   309
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   310
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   311
PointToPointNetDevice::SetLinkChangeCallback (Callback<void> callback)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   312
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   313
  m_linkChangeCallback = callback;
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
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   316
PointToPointNetDevice::IsBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   317
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   318
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   319
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   320
Address
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   321
PointToPointNetDevice::GetBroadcast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   322
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   323
  return Mac48Address ("ff:ff:ff:ff:ff:ff");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   324
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   325
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   326
PointToPointNetDevice::IsMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   327
{
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   328
  return false;
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   329
}
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   330
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   331
PointToPointNetDevice::GetMulticast (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   332
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   333
  return Mac48Address ("01:00:5e:00:00:00");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   334
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   335
Address 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   336
PointToPointNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   337
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   338
  return Mac48Address ("01:00:5e:00:00:00");
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   339
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   340
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   341
PointToPointNetDevice::IsPointToPoint (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   342
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   343
  return true;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   344
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   345
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   346
PointToPointNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   347
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   348
    NS_LOG_FUNCTION;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   349
  NS_LOG_LOGIC ("p=" << packet << ", dest=" << &dest);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   350
  NS_LOG_LOGIC ("UID is " << packet->GetUid ());
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   351
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   352
  // GFR Comment. Why is this an assertion? Can't a link legitimately
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   353
  // "go down" during the simulation?  Shouldn't we just wait for it
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   354
  // to come back up?
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   355
  NS_ASSERT (IsLinkUp ());
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   356
  AddHeader(packet, protocolNumber);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   357
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   358
//
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   359
// This class simulates a point to point device.  In the case of a serial
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   360
// link, this means that we're simulating something like a UART.
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
//
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   363
// 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
   364
// transmission; otherwise we send it now.
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   365
  if (m_txMachineState == READY) 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   366
    {
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   367
// We still enqueue and dequeue it to hit the tracing hooks
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   368
      m_queue->Enqueue (packet);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   369
      packet = m_queue->Dequeue ();
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   370
      return TransmitStart (packet);
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
  else
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   373
    {
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   374
      return m_queue->Enqueue(packet);
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   375
    }
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
Ptr<Node> 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   378
PointToPointNetDevice::GetNode (void) const
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   379
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   380
  return m_node;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   381
}
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
   382
void 
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
   383
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
   384
{
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
   385
  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
   386
}
2470
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   387
bool 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   388
PointToPointNetDevice::NeedsArp (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 false;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   391
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   392
void 
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   393
PointToPointNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   394
{
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   395
  m_rxCallback = cb;
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   396
}
254581fb9e9c make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2424
diff changeset
   397
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   398
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   399
} // namespace ns3