author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 10 May 2007 20:19:26 +0200 | |
changeset 568 | e1660959ecbb |
parent 378 | 32bd402ea5ea |
child 767 | c36570ed4f5e |
permissions | -rw-r--r-- |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
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:
331
diff
changeset
|
2 |
/* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
3 |
* Copyright (c) 2007 University of Washington |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
4 |
* All rights reserved. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
5 |
* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
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:
331
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:
331
diff
changeset
|
8 |
* published by the Free Software Foundation; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
9 |
* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
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:
331
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:
331
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:
331
diff
changeset
|
13 |
* GNU General Public License for more details. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
14 |
* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
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:
331
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:
331
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:
331
diff
changeset
|
18 |
* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
19 |
* Author: Craig Dowell <craigdo@ee.washington.edu> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
20 |
*/ |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
|
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include "p2p-channel.h" |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include "p2p-net-device.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
24 |
#include "ns3/packet.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
25 |
#include "ns3/simulator.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
26 |
#include "ns3/debug.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
27 |
|
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
28 |
NS_DEBUG_COMPONENT_DEFINE ("PointToPointChannel"); |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
namespace ns3 { |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
32 |
// |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
33 |
// By default, you get a channel with the name "PointToPoint Channel" that |
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
34 |
// has an "infitely" fast transmission speed and zero delay. |
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
35 |
PointToPointChannel::PointToPointChannel() |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
36 |
: |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
37 |
Channel ("PointToPoint Channel"), |
373
960c8e8721de
Move simple-p2p.cc to DataRate; fix small bug in DataRate and add include guards
Tom Henderson <tomh@tomh.org>
parents:
369
diff
changeset
|
38 |
m_bps (DataRate(0xffffffff)), |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
39 |
m_delay (Seconds(0)), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
40 |
m_nDevices(0) |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
{ |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
42 |
NS_DEBUG("PointToPointChannel::PointToPointChannel ()"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
43 |
} |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
44 |
|
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
45 |
PointToPointChannel::PointToPointChannel( |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
46 |
const DataRate& bps, |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
47 |
const Time& delay) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
48 |
: |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
49 |
Channel ("PointToPoint Channel"), |
373
960c8e8721de
Move simple-p2p.cc to DataRate; fix small bug in DataRate and add include guards
Tom Henderson <tomh@tomh.org>
parents:
369
diff
changeset
|
50 |
m_bps (bps), |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
51 |
m_delay (delay), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
52 |
m_nDevices(0) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
53 |
{ |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
54 |
NS_DEBUG("PointToPointChannel::PointToPointChannel (" << Channel::GetName() |
373
960c8e8721de
Move simple-p2p.cc to DataRate; fix small bug in DataRate and add include guards
Tom Henderson <tomh@tomh.org>
parents:
369
diff
changeset
|
55 |
<< ", " << bps.GetBitRate() << ", " << delay << ")"); |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
} |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
|
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
58 |
PointToPointChannel::PointToPointChannel( |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
59 |
const std::string& name, |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
60 |
const DataRate& bps, |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
61 |
const Time& delay) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
62 |
: |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
63 |
Channel (name), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
64 |
m_bps (bps), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
65 |
m_delay (delay), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
66 |
m_nDevices(0) |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
{ |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
68 |
NS_DEBUG("PointToPointChannel::PointToPointChannel (" << name << ", " << |
373
960c8e8721de
Move simple-p2p.cc to DataRate; fix small bug in DataRate and add include guards
Tom Henderson <tomh@tomh.org>
parents:
369
diff
changeset
|
69 |
bps.GetBitRate() << ", " << delay << ")"); |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
} |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
|
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
72 |
void |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
378
diff
changeset
|
73 |
PointToPointChannel::Attach(Ptr<PointToPointNetDevice> device) |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
74 |
{ |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
75 |
NS_DEBUG("PointToPointChannel::Attach (" << device << ")"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
76 |
NS_ASSERT(m_nDevices < N_DEVICES && "Only two devices permitted"); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
378
diff
changeset
|
77 |
NS_ASSERT(device != 0); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
78 |
|
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
79 |
m_link[m_nDevices].m_src = device; |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
80 |
++m_nDevices; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
81 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
82 |
// If we have both devices connected to the channel, then finish introducing |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
83 |
// the two halves and set the links to IDLE. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
84 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
85 |
if (m_nDevices == N_DEVICES) |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
{ |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
87 |
m_link[0].m_dst = m_link[1].m_src; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
88 |
m_link[1].m_dst = m_link[0].m_src; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
89 |
m_link[0].m_state = IDLE; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
90 |
m_link[1].m_state = IDLE; |
245
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
} |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
} |
28ba3a5cdff8
add p2p netdevice and channel
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
|
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
94 |
bool |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
378
diff
changeset
|
95 |
PointToPointChannel::TransmitStart(Packet& p, Ptr<PointToPointNetDevice> src) |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
96 |
{ |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
97 |
NS_DEBUG ("PointToPointChannel::TransmitStart (" << &p << ", " << src << |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
98 |
")"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
99 |
NS_DEBUG ("PointToPointChannel::TransmitStart (): UID is " << |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
100 |
p.GetUid () << ")"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
101 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
102 |
NS_ASSERT(m_link[0].m_state != INITIALIZING); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
103 |
NS_ASSERT(m_link[1].m_state != INITIALIZING); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
104 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
105 |
uint32_t wire = src == m_link[0].m_src ? 0 : 1; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
106 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
107 |
if (m_link[wire].m_state == TRANSMITTING) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
108 |
{ |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
109 |
NS_DEBUG("PointToPointChannel::TransmitStart (): **** ERROR ****"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
110 |
NS_DEBUG("PointToPointChannel::TransmitStart (): state TRANSMITTING"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
111 |
return false; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
112 |
} |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
113 |
|
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
114 |
NS_DEBUG("PointToPointChannel::TransmitStart (): switch to TRANSMITTING"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
115 |
m_link[wire].m_state = TRANSMITTING; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
116 |
return true; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
117 |
} |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
118 |
|
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
119 |
bool |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
378
diff
changeset
|
120 |
PointToPointChannel::TransmitEnd(Packet& p, Ptr<PointToPointNetDevice> src) |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
121 |
{ |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
122 |
NS_DEBUG("PointToPointChannel::TransmitEnd (" << &p << ", " << src << ")"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
123 |
NS_DEBUG ("PointToPointChannel::TransmitEnd (): UID is " << |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
124 |
p.GetUid () << ")"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
125 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
126 |
NS_ASSERT(m_link[0].m_state != INITIALIZING); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
127 |
NS_ASSERT(m_link[1].m_state != INITIALIZING); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
128 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
129 |
uint32_t wire = src == m_link[0].m_src ? 0 : 1; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
130 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
131 |
NS_ASSERT(m_link[wire].m_state == TRANSMITTING); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
132 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
133 |
m_link[wire].m_state = PROPAGATING; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
134 |
// |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
135 |
// The sender is going to free the packet as soon as it has been transmitted. |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
136 |
// We need to copy it to get a reference so it won't e deleted. |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
137 |
// |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
138 |
Packet packet = p; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
139 |
NS_DEBUG ("PointToPointChannel::TransmitEnd (): Schedule event in " << |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
140 |
m_delay.GetSeconds () << "sec"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
141 |
Simulator::Schedule (m_delay, |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
142 |
&PointToPointChannel::PropagationCompleteEvent, |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
143 |
this, packet, src); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
144 |
return true; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
145 |
} |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
146 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
147 |
void |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
148 |
PointToPointChannel::PropagationCompleteEvent( |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
149 |
Packet p, |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
378
diff
changeset
|
150 |
Ptr<PointToPointNetDevice> src) |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
151 |
{ |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
152 |
NS_DEBUG("PointToPointChannel::PropagationCompleteEvent (" << &p << ", " << |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
153 |
src << ")"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
154 |
NS_DEBUG ("PointToPointChannel::PropagationCompleteEvent (): UID is " << |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
155 |
p.GetUid () << ")"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
156 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
157 |
uint32_t wire = src == m_link[0].m_src ? 0 : 1; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
158 |
NS_ASSERT(m_link[wire].m_state == PROPAGATING); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
159 |
m_link[wire].m_state = IDLE; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
160 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
161 |
NS_DEBUG ("PointToPointChannel::PropagationCompleteEvent (): Receive"); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
162 |
m_link[wire].m_dst->Receive (p); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
163 |
} |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
164 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
165 |
|
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
166 |
uint32_t |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
167 |
PointToPointChannel::GetNDevices (void) const |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
168 |
{ |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
169 |
return m_nDevices; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
170 |
} |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
171 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
378
diff
changeset
|
172 |
Ptr<NetDevice> |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
173 |
PointToPointChannel::GetDevice (uint32_t i) const |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
174 |
{ |
378
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
175 |
NS_ASSERT(i < 2); |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
176 |
return m_link[i].m_src; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
177 |
} |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
178 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
179 |
DataRate |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
180 |
PointToPointChannel::GetDataRate (void) |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
181 |
{ |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
182 |
return m_bps; |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
183 |
} |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
184 |
|
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
185 |
Time |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
186 |
PointToPointChannel::GetDelay (void) |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
187 |
{ |
32bd402ea5ea
remove unused files, remove notion of PHY, make more realistic p2p-net-device and p2p-channel
Craig Dowell
parents:
373
diff
changeset
|
188 |
return m_delay; |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
189 |
} |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
190 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
191 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
331
diff
changeset
|
192 |
} // namespace ns3 |