src/devices/point-to-point/point-to-point-net-device.cc
author Tom Henderson <tomh@tomh.org>
Thu, 08 Nov 2007 23:08:00 -0800
changeset 1825 1544b7c8aa18
parent 1820 736919bd4874
child 1828 6ab68edddf45
permissions -rw-r--r--
minor fix for bug95; also const operators for DataRate
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"
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    26
#include "ns3/composite-trace-resolver.h"
1494
c2985e1cd091 rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
    27
#include "ns3/mac48-address.h"
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
    28
#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
    29
#include "ns3/error-model.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
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    37
DataRateDefaultValue PointToPointNetDevice::g_defaultRate(
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    38
           "PointToPointLinkDataRate", 
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    39
           "The default data rate for point to point links",
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    40
           DataRate ("10Mb/s"));
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    41
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    42
PointToPointTraceType::PointToPointTraceType (enum Type type)
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    43
  : m_type (type)
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    44
{
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    45
  NS_LOG_FUNCTION;
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    46
}
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    47
PointToPointTraceType::PointToPointTraceType ()
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    48
  : m_type (RX)
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    49
{
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    50
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    51
}
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    52
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    53
void 
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    54
PointToPointTraceType::Print (std::ostream &os) const
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    55
{
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    56
  switch (m_type) {
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    57
  case RX:
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    58
    os << "dev-rx";
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    59
    break;
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    60
  case DROP:
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    61
    os << "dev-drop";
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    62
    break;
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    63
  }
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    64
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    65
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    66
uint16_t 
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    67
PointToPointTraceType::GetUid (void)
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    68
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    69
  NS_LOG_FUNCTION;
1235
dc52ea3507ff TraceContextElement::Register -> TraceContextElement::AllocateUid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1230
diff changeset
    70
  static uint16_t uid = AllocateUid<PointToPointTraceType> ("PointToPointTraceType");
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    71
  return uid;
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
1364
7866d4dd9e64 add TraceContextElement::GetName method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1355
diff changeset
    74
std::string 
1401
96a21130865c GetName -> GetTypeName
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1386
diff changeset
    75
PointToPointTraceType::GetTypeName (void) const
1364
7866d4dd9e64 add TraceContextElement::GetName method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1355
diff changeset
    76
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
    77
  NS_LOG_FUNCTION;
1401
96a21130865c GetName -> GetTypeName
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1386
diff changeset
    78
  return "ns3::PointToPointTraceType";
1364
7866d4dd9e64 add TraceContextElement::GetName method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1355
diff changeset
    79
}
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    80
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    81
enum PointToPointTraceType::Type
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    82
PointToPointTraceType::Get (void) const
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    83
{
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    84
  NS_LOG_FUNCTION;
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    85
  return m_type;
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    86
}
1229
e4cfe4094c10 build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1208
diff changeset
    87
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
    88
PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node,
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
    89
                                              const DataRate& rate) 
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
    90
: 
1494
c2985e1cd091 rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
    91
  NetDevice(node, Mac48Address::Allocate ()), 
379
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    92
  m_txMachineState (READY),
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
    93
  m_bps (rate),
379
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    94
  m_tInterframeGap (Seconds(0)),
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    95
  m_channel (0), 
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
    96
  m_queue (0),
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    97
  m_rxTrace (),
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    98
  m_dropTrace (),
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
    99
  m_receiveErrorModel (0)
257
60d6d9bb4f9a make sure the MTU is correcrtly setup and the link is up.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 247
diff changeset
   100
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   101
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   102
  NS_LOG_PARAM ("(" << node << ")");
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   103
//
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   104
// XXX BUGBUG
1441
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1276
diff changeset
   105
//
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1276
diff changeset
   106
// You _must_ support broadcast to get any sort of packet from the ARP layer.
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   107
//
1494
c2985e1cd091 rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
   108
  EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
1441
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1276
diff changeset
   109
//
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   110
// We want to allow multicast packets to flow across this link
1441
d6f8a7546e7f semi-real multicast hardware addresses
Craig Dowell <craigdo@ee.washington.edu>
parents: 1276
diff changeset
   111
//
1494
c2985e1cd091 rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1451
diff changeset
   112
  EnableMulticast (Mac48Address ("01:00:5e:00:00:00"));
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   113
  EnablePointToPoint();
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
   114
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
369
29ea5d1a83c8 Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents: 368
diff changeset
   116
PointToPointNetDevice::~PointToPointNetDevice()
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   117
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   118
  NS_LOG_FUNCTION;
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   119
  m_queue = 0;
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   120
  m_receiveErrorModel = 0;
379
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
   121
}
ae74e8a7bb44 net device copy and assignment, reference counted channel.
Craig Dowell
parents: 378
diff changeset
   122
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   123
void 
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   124
PointToPointNetDevice::AddHeader(Packet& p, uint16_t protocolNumber)
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   125
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   126
  NS_LOG_FUNCTION;
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   127
  LlcSnapHeader llc;
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   128
  llc.SetType (protocolNumber);
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   129
  p.AddHeader (llc);
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   130
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   131
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   132
bool 
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   133
PointToPointNetDevice::ProcessHeader(Packet& p, uint16_t& param)
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   134
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   135
  NS_LOG_FUNCTION;
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   136
  LlcSnapHeader llc;
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   137
  p.RemoveHeader (llc);
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   138
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   139
  param = llc.GetType ();
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   140
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   141
  return true;
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   142
}
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   143
517
702e96b8960f finish Dispose -> DoDispose rework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 471
diff changeset
   144
void PointToPointNetDevice::DoDispose()
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   145
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   146
  NS_LOG_FUNCTION;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 543
diff changeset
   147
  m_channel = 0;
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 543
diff changeset
   148
  NetDevice::DoDispose ();
465
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   149
}
7f620ea278f4 merge in raj's dispose early work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 445
diff changeset
   150
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   151
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
   152
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   153
  NS_LOG_FUNCTION;
1825
1544b7c8aa18 minor fix for bug95; also const operators for DataRate
Tom Henderson <tomh@tomh.org>
parents: 1820
diff changeset
   154
  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
   155
    {
1544b7c8aa18 minor fix for bug95; also const operators for DataRate
Tom Henderson <tomh@tomh.org>
parents: 1820
diff changeset
   156
      m_bps = bps;
1544b7c8aa18 minor fix for bug95; also const operators for DataRate
Tom Henderson <tomh@tomh.org>
parents: 1820
diff changeset
   157
    }
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   160
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
   161
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   162
  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
   163
  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
   164
}
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   165
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   166
bool PointToPointNetDevice::SendTo (const Packet& packet, const Address& dest, 
975
98233c6c9c2e Move LLC encapsulation from NetDevice to subclasses.
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents: 973
diff changeset
   167
                                    uint16_t protocolNumber)
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   169
  NS_LOG_FUNCTION;
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   170
  Packet p = packet;
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   171
  NS_LOG_LOGIC ("p=" << &p << ", dest=" << &dest);
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   172
  NS_LOG_LOGIC ("UID is " << p.GetUid ());
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   173
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   174
  // GFR Comment. Why is this an assertion? Can't a link legitimately
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   175
  // "go down" during the simulation?  Shouldn't we just wait for it
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   176
  // to come back up?
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   177
  NS_ASSERT (IsLinkUp ());
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   178
  AddHeader(p, protocolNumber);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   179
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   180
//
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   181
// This class simulates a point to point device.  In the case of a serial
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   182
// link, this means that we're simulating something like a UART.
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   183
//
773
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   184
//
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   185
// If there's a transmission in progress, we enque the packet for later
1508
081930e88b34 Enable enqueue/dequeue tracing for point-to-point links
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   186
// transmission; otherwise we send it now.
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   187
  if (m_txMachineState == READY) 
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   188
    {
1508
081930e88b34 Enable enqueue/dequeue tracing for point-to-point links
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   189
// We still enqueue and dequeue it to hit the tracing hooks
081930e88b34 Enable enqueue/dequeue tracing for point-to-point links
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   190
      m_queue->Enqueue (p);
081930e88b34 Enable enqueue/dequeue tracing for point-to-point links
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   191
      m_queue->Dequeue (p);
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   192
      return TransmitStart (p);
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   193
    }
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   194
  else
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   195
    {
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   196
      return m_queue->Enqueue(p);
1167
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 996
diff changeset
   197
    }
378
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   198
}
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   199
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   200
  bool
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   201
PointToPointNetDevice::TransmitStart (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
   202
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   203
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   204
  NS_LOG_PARAM ("(" << &p << ")");
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   205
  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
   206
//
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   207
// 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
   208
// 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
   209
// 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
   210
//
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   211
  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
   212
  m_txMachineState = BUSY;
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   213
  Time txTime = Seconds (m_bps.CalculateTxTime(p.GetSize()));
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   214
  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
   215
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   216
  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
   217
    txCompleteTime.GetSeconds () << "sec");
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   218
  // 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
   219
  Simulator::Schedule (txCompleteTime, 
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   220
                       &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
   221
                       this);
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   222
  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
   223
}
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   224
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   225
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
   226
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   227
  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
   228
//
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   229
// 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
   230
// 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
   231
// 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
   232
// 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
   233
//
414
71babb829194 fix queue leak and add p2p net device dox
Craig Dowell
parents: 402
diff changeset
   234
  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
   235
  m_txMachineState = READY;
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   236
  Packet p;
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   237
  if (!m_queue->Dequeue(p)) return; // Nothing to do at this point
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   238
  TransmitStart(p);
773
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   239
}
18ad0b94e2ae back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents: 767
diff changeset
   240
1333
c0d66de933e9 convert TraceResolver * to Ptr<TraceResolver>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1325
diff changeset
   241
Ptr<TraceResolver> 
1383
12f30b7defb4 constify
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1379
diff changeset
   242
PointToPointNetDevice::GetTraceResolver (void) const
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   244
  NS_LOG_FUNCTION;
1333
c0d66de933e9 convert TraceResolver * to Ptr<TraceResolver>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1325
diff changeset
   245
  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
1386
f2ee41c3e788 avoid method naming ambiguity in CompositeTraceResolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1383
diff changeset
   246
  resolver->AddComposite ("queue", m_queue);
1355
6289ac826830 CompositeTraceResolver::Add -> CompositeTraceResolver::AddSource
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1341
diff changeset
   247
  resolver->AddSource ("rx",
1379
f323d2dcdaf6 document trace source signatures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1376
diff changeset
   248
                       TraceDoc ("receive MAC packet",
f323d2dcdaf6 document trace source signatures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1376
diff changeset
   249
                                 "const Packet &", "packet received"),
1355
6289ac826830 CompositeTraceResolver::Add -> CompositeTraceResolver::AddSource
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1341
diff changeset
   250
                       m_rxTrace,
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   251
                       PointToPointTraceType (PointToPointTraceType::RX));
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   252
  resolver->AddSource ("drop",
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   253
                       TraceDoc ("drop MAC packet",
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   254
                                 "const Packet &", "packet dropped"),
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   255
                       m_dropTrace,
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   256
                       PointToPointTraceType (PointToPointTraceType::DROP));
1386
f2ee41c3e788 avoid method naming ambiguity in CompositeTraceResolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1383
diff changeset
   257
  resolver->SetParentResolver (NetDevice::GetTraceResolver ());
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   258
  return resolver;
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   261
bool 
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   262
PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch)
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   264
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   265
  NS_LOG_PARAM ("(" << &ch << ")");
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   266
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   267
  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
   268
32bd402ea5ea remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents: 371
diff changeset
   269
  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
   270
  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
   271
  // 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
   272
  // is unrelated to channel delay.
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   273
  // -- 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
   274
  // 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
   275
  //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
   276
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   277
  /* 
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   278
   * 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
   279
   * 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
   280
   * 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
   281
   * 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
   282
   * 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
   283
   * up, hence that they can call NotifyLinkUp. 
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   284
   */
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   285
  NotifyLinkUp ();
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   286
  return true;
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   287
}
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   288
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   289
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
   290
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   291
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   292
  NS_LOG_PARAM ("(" << q << ")");
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   293
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   294
  m_queue = q;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   295
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   296
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   297
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
   298
{
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   299
  NS_LOG_FUNCTION;
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   300
  NS_LOG_PARAM ("(" << em << ")");
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   301
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   302
  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
   303
  AddInterface (em);
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   304
}
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   305
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   306
void PointToPointNetDevice::Receive (Packet& p)
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   307
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   308
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   309
  NS_LOG_PARAM ("(" << &p << ")");
1186
909e9eb2124e rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1167
diff changeset
   310
  uint16_t protocol = 0;
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   311
  Packet packet = p;
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   312
1820
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   313
  if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (p) ) 
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   314
    {
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   315
      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
   316
      // 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
   317
    }
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   318
  else 
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   319
    {
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   320
      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
   321
      ProcessHeader(packet, protocol);
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   322
      ForwardUp (packet, protocol, GetBroadcast ());
736919bd4874 Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents: 1508
diff changeset
   323
    }
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
   324
}
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 331
diff changeset
   325
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   326
Ptr<Queue> PointToPointNetDevice::GetQueue(void) const 
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   327
{ 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   328
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   329
  return m_queue;
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   330
}
245
28ba3a5cdff8 add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   331
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   332
Ptr<Channel> PointToPointNetDevice::DoGetChannel(void) const 
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   333
{ 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   334
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   335
  return m_channel;
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   336
}
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   337
926
1fdec986d774 Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents: 773
diff changeset
   338
bool PointToPointNetDevice::DoNeedsArp (void) const
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   339
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1494
diff changeset
   340
  NS_LOG_FUNCTION;
445
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   341
  return false;
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   342
}
10cd9049a0ad add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 414
diff changeset
   343
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   344
} // namespace ns3