author | Tom Henderson <tomh@tomh.org> |
Wed, 14 Nov 2007 20:40:05 -0800 | |
changeset 1820 | 736919bd4874 |
parent 1508 | 081930e88b34 |
child 1825 | 1544b7c8aa18 |
permissions | -rw-r--r-- |
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 | 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 | 88 |
PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node, |
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 | 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 | 123 |
void |
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 | 132 |
bool |
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; |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
154 |
m_bps = bps; |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
155 |
} |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
156 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
157 |
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
|
158 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
159 |
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
|
160 |
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
|
161 |
} |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
162 |
|
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
163 |
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
|
164 |
uint16_t protocolNumber) |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
165 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
166 |
NS_LOG_FUNCTION; |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
167 |
Packet p = packet; |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
168 |
NS_LOG_LOGIC ("p=" << &p << ", dest=" << &dest); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
169 |
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
|
170 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
171 |
// 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
|
172 |
// "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
|
173 |
// to come back up? |
414 | 174 |
NS_ASSERT (IsLinkUp ()); |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
175 |
AddHeader(p, protocolNumber); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
176 |
|
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
177 |
// |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
178 |
// 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
|
179 |
// 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
|
180 |
// |
773
18ad0b94e2ae
back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents:
767
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 |
// 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
|
183 |
// transmission; otherwise we send it now. |
1167 | 184 |
if (m_txMachineState == READY) |
185 |
{ |
|
1508
081930e88b34
Enable enqueue/dequeue tracing for point-to-point links
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
186 |
// 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
|
187 |
m_queue->Enqueue (p); |
081930e88b34
Enable enqueue/dequeue tracing for point-to-point links
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
188 |
m_queue->Dequeue (p); |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
189 |
return TransmitStart (p); |
1167 | 190 |
} |
191 |
else |
|
192 |
{ |
|
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
193 |
return m_queue->Enqueue(p); |
1167 | 194 |
} |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
195 |
} |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
196 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
197 |
bool |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
198 |
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
|
199 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
200 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
201 |
NS_LOG_PARAM ("(" << &p << ")"); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
202 |
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
|
203 |
// |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
204 |
// 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
|
205 |
// 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
|
206 |
// 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
|
207 |
// |
414 | 208 |
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
|
209 |
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
|
210 |
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
|
211 |
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
|
212 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
213 |
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
|
214 |
txCompleteTime.GetSeconds () << "sec"); |
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
215 |
// 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
|
216 |
Simulator::Schedule (txCompleteTime, |
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
217 |
&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
|
218 |
this); |
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
219 |
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
|
220 |
} |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
221 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
222 |
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
|
223 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
224 |
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
|
225 |
// |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
226 |
// 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
|
227 |
// 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
|
228 |
// 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
|
229 |
// 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
|
230 |
// |
414 | 231 |
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
|
232 |
m_txMachineState = READY; |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
233 |
Packet p; |
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
234 |
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
|
235 |
TransmitStart(p); |
773
18ad0b94e2ae
back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents:
767
diff
changeset
|
236 |
} |
18ad0b94e2ae
back out unfinished p2p changes
Tom Henderson <tomh@tomh.org>
parents:
767
diff
changeset
|
237 |
|
1333
c0d66de933e9
convert TraceResolver * to Ptr<TraceResolver>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1325
diff
changeset
|
238 |
Ptr<TraceResolver> |
1383 | 239 |
PointToPointNetDevice::GetTraceResolver (void) const |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
240 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
241 |
NS_LOG_FUNCTION; |
1333
c0d66de933e9
convert TraceResolver * to Ptr<TraceResolver>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1325
diff
changeset
|
242 |
Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> (); |
1386
f2ee41c3e788
avoid method naming ambiguity in CompositeTraceResolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1383
diff
changeset
|
243 |
resolver->AddComposite ("queue", m_queue); |
1355
6289ac826830
CompositeTraceResolver::Add -> CompositeTraceResolver::AddSource
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1341
diff
changeset
|
244 |
resolver->AddSource ("rx", |
1379
f323d2dcdaf6
document trace source signatures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1376
diff
changeset
|
245 |
TraceDoc ("receive MAC packet", |
f323d2dcdaf6
document trace source signatures
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1376
diff
changeset
|
246 |
"const Packet &", "packet received"), |
1355
6289ac826830
CompositeTraceResolver::Add -> CompositeTraceResolver::AddSource
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1341
diff
changeset
|
247 |
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
|
248 |
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
|
249 |
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
|
250 |
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
|
251 |
"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
|
252 |
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
|
253 |
PointToPointTraceType (PointToPointTraceType::DROP)); |
1386
f2ee41c3e788
avoid method naming ambiguity in CompositeTraceResolver
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1383
diff
changeset
|
254 |
resolver->SetParentResolver (NetDevice::GetTraceResolver ()); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
255 |
return resolver; |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
256 |
} |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
257 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
258 |
bool |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
259 |
PointToPointNetDevice::Attach (Ptr<PointToPointChannel> ch) |
245
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 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
262 |
NS_LOG_PARAM ("(" << &ch << ")"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
263 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
264 |
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
|
265 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
371
diff
changeset
|
266 |
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
|
267 |
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
|
268 |
// 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
|
269 |
// is unrelated to channel delay. |
1443
580ed7a4dd1e
Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents:
1441
diff
changeset
|
270 |
// -- 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
|
271 |
// 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
|
272 |
//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
|
273 |
|
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
274 |
/* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
275 |
* 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
|
276 |
* 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
|
277 |
* 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
|
278 |
* 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
|
279 |
* 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
|
280 |
* up, hence that they can call NotifyLinkUp. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
281 |
*/ |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
282 |
NotifyLinkUp (); |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
283 |
return true; |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
284 |
} |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
285 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
286 |
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
|
287 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
288 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
289 |
NS_LOG_PARAM ("(" << q << ")"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
290 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
291 |
m_queue = q; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
292 |
} |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
293 |
|
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1508
diff
changeset
|
294 |
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
|
295 |
{ |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1508
diff
changeset
|
296 |
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
|
297 |
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
|
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 |
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
|
300 |
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
|
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 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
303 |
void PointToPointNetDevice::Receive (Packet& p) |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
304 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
305 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
306 |
NS_LOG_PARAM ("(" << &p << ")"); |
1186
909e9eb2124e
rework the NetDevice <-> Node interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
307 |
uint16_t protocol = 0; |
1308
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
308 |
Packet packet = p; |
5c5937a4150d
backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1303
diff
changeset
|
309 |
|
1820
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1508
diff
changeset
|
310 |
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
|
311 |
{ |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1508
diff
changeset
|
312 |
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
|
313 |
// 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
|
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 |
else |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1508
diff
changeset
|
316 |
{ |
736919bd4874
Add src/common/error-model implementation and example script, and add to NetDevices
Tom Henderson <tomh@tomh.org>
parents:
1508
diff
changeset
|
317 |
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
|
318 |
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
|
319 |
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
|
320 |
} |
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
|
321 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
322 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
323 |
Ptr<Queue> PointToPointNetDevice::GetQueue(void) const |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
324 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
325 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
326 |
return m_queue; |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
327 |
} |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
328 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
329 |
Ptr<Channel> PointToPointNetDevice::DoGetChannel(void) const |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
330 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
331 |
NS_LOG_FUNCTION; |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
332 |
return m_channel; |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
333 |
} |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
334 |
|
926
1fdec986d774
Simplifications to the point to point devices and channel
George F. Riley<riley@ece.gatech.edu>
parents:
773
diff
changeset
|
335 |
bool PointToPointNetDevice::DoNeedsArp (void) const |
445
10cd9049a0ad
add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
414
diff
changeset
|
336 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1494
diff
changeset
|
337 |
NS_LOG_FUNCTION; |
445
10cd9049a0ad
add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
414
diff
changeset
|
338 |
return false; |
10cd9049a0ad
add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
414
diff
changeset
|
339 |
} |
10cd9049a0ad
add NetDevice::NeedsArp method
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
414
diff
changeset
|
340 |
|
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
341 |
} // namespace ns3 |