|
tomh@368
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
tomh@368
|
2 |
/*
|
|
craigdo@3086
|
3 |
* Copyright (c) 2007, 2008 University of Washington
|
|
tomh@368
|
4 |
*
|
|
tomh@368
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
tomh@368
|
6 |
* it under the terms of the GNU General Public License version 2 as
|
|
tomh@368
|
7 |
* published by the Free Software Foundation;
|
|
tomh@368
|
8 |
*
|
|
tomh@368
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
tomh@368
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
tomh@368
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
tomh@368
|
12 |
* GNU General Public License for more details.
|
|
tomh@368
|
13 |
*
|
|
tomh@368
|
14 |
* You should have received a copy of the GNU General Public License
|
|
tomh@368
|
15 |
* along with this program; if not, write to the Free Software
|
|
tomh@368
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
tomh@368
|
17 |
*/
|
|
mathieu@245
|
18 |
|
|
tomh@369
|
19 |
#ifndef POINT_TO_POINT_NET_DEVICE_H
|
|
tomh@369
|
20 |
#define POINT_TO_POINT_NET_DEVICE_H
|
|
mathieu@245
|
21 |
|
|
tomh@368
|
22 |
#include <string.h>
|
|
mathieu@1167
|
23 |
#include "ns3/address.h"
|
|
mathieu@729
|
24 |
#include "ns3/node.h"
|
|
mathieu@331
|
25 |
#include "ns3/net-device.h"
|
|
tomh@368
|
26 |
#include "ns3/callback.h"
|
|
tomh@368
|
27 |
#include "ns3/packet.h"
|
|
mathieu@2502
|
28 |
#include "ns3/traced-callback.h"
|
|
Craig@378
|
29 |
#include "ns3/nstime.h"
|
|
Craig@378
|
30 |
#include "ns3/data-rate.h"
|
|
raj@543
|
31 |
#include "ns3/ptr.h"
|
|
mathieu@2470
|
32 |
#include "ns3/mac48-address.h"
|
|
mathieu@245
|
33 |
|
|
mathieu@245
|
34 |
namespace ns3 {
|
|
mathieu@245
|
35 |
|
|
mathieu@402
|
36 |
class Queue;
|
|
tomh@369
|
37 |
class PointToPointChannel;
|
|
tomh@1820
|
38 |
class ErrorModel;
|
|
mathieu@245
|
39 |
|
|
mathieu@1403
|
40 |
/**
|
|
Craig@414
|
41 |
* \class PointToPointNetDevice
|
|
Craig@414
|
42 |
* \brief A Device for a Point to Point Network Link.
|
|
mathieu@409
|
43 |
*
|
|
tomh@1793
|
44 |
* This PointToPointNetDevice class specializes the NetDevice abstract
|
|
tomh@1793
|
45 |
* base class. Together with a PointToPointChannel (and a peer
|
|
tomh@1793
|
46 |
* PointToPointNetDevice), the class models, with some level of
|
|
tomh@1793
|
47 |
* abstraction, a generic point-to-point or serial link.
|
|
tomh@1793
|
48 |
* Key parameters or objects that can be specified for this device
|
|
tomh@1793
|
49 |
* include a queue, data rate, and interframe transmission gap (the
|
|
tomh@1793
|
50 |
* propagation delay is set in the PointToPointChannel).
|
|
mathieu@409
|
51 |
*/
|
|
mathieu@2470
|
52 |
class PointToPointNetDevice : public NetDevice
|
|
mathieu@2470
|
53 |
{
|
|
mathieu@245
|
54 |
public:
|
|
mathieu@2502
|
55 |
static TypeId GetTypeId (void);
|
|
mathieu@2502
|
56 |
|
|
Craig@414
|
57 |
/**
|
|
Craig@414
|
58 |
* Construct a PointToPointNetDevice
|
|
Craig@414
|
59 |
*
|
|
Craig@414
|
60 |
* This is the constructor for the PointToPointNetDevice. It takes as a
|
|
tomh@1793
|
61 |
* parameter a pointer to the Node to which this device is connected,
|
|
tomh@1793
|
62 |
* as well as an optional DataRate object.
|
|
Craig@414
|
63 |
*/
|
|
mathieu@2502
|
64 |
PointToPointNetDevice ();
|
|
craigdo@3181
|
65 |
|
|
Craig@414
|
66 |
/**
|
|
Craig@414
|
67 |
* Destroy a PointToPointNetDevice
|
|
Craig@414
|
68 |
*
|
|
Craig@414
|
69 |
* This is the destructor for the PointToPointNetDevice.
|
|
Craig@414
|
70 |
*/
|
|
tomh@1793
|
71 |
virtual ~PointToPointNetDevice ();
|
|
craigdo@3181
|
72 |
|
|
Craig@414
|
73 |
/**
|
|
Craig@414
|
74 |
* Set the Data Rate used for transmission of packets. The data rate is
|
|
Craig@414
|
75 |
* set in the Attach () method from the corresponding field in the channel
|
|
Craig@414
|
76 |
* to which the device is attached. It can be overridden using this method.
|
|
Craig@414
|
77 |
*
|
|
Craig@414
|
78 |
* @see Attach ()
|
|
Craig@414
|
79 |
* @param bps the data rate at which this object operates
|
|
mathieu@409
|
80 |
*/
|
|
craigdo@3181
|
81 |
void SetDataRate (DataRate bps);
|
|
craigdo@3181
|
82 |
|
|
Craig@414
|
83 |
/**
|
|
Craig@414
|
84 |
* Set the inteframe gap used to separate packets. The interframe gap
|
|
Craig@414
|
85 |
* defines the minimum space required between packets sent by this device.
|
|
Craig@414
|
86 |
*
|
|
Craig@414
|
87 |
* @param t the interframe gap time
|
|
Craig@414
|
88 |
*/
|
|
craigdo@3181
|
89 |
void SetInterframeGap (Time t);
|
|
craigdo@3181
|
90 |
|
|
Craig@414
|
91 |
/**
|
|
Craig@414
|
92 |
* Attach the device to a channel.
|
|
Craig@414
|
93 |
*
|
|
craigdo@3181
|
94 |
* @param ch Ptr to the channel to which this object is being attached.
|
|
Craig@414
|
95 |
*/
|
|
tomh@1793
|
96 |
bool Attach (Ptr<PointToPointChannel> ch);
|
|
craigdo@3181
|
97 |
|
|
Craig@414
|
98 |
/**
|
|
Craig@414
|
99 |
* Attach a queue to the PointToPointNetDevice.
|
|
Craig@414
|
100 |
*
|
|
craigdo@3181
|
101 |
* The PointToPointNetDevice "owns" a queue that implements a queueing
|
|
craigdo@3181
|
102 |
* method such as DropTail or RED.
|
|
Craig@414
|
103 |
*
|
|
Craig@414
|
104 |
* @see Queue
|
|
Craig@414
|
105 |
* @see DropTailQueue
|
|
craigdo@3181
|
106 |
* @param queue Ptr to the new queue.
|
|
Craig@414
|
107 |
*/
|
|
craigdo@3010
|
108 |
void SetQueue (Ptr<Queue> queue);
|
|
craigdo@3181
|
109 |
|
|
Craig@414
|
110 |
/**
|
|
tomh@1820
|
111 |
* Attach a receive ErrorModel to the PointToPointNetDevice.
|
|
tomh@1820
|
112 |
*
|
|
tomh@1820
|
113 |
* The PointToPointNetDevice may optionally include an ErrorModel in
|
|
tomh@1820
|
114 |
* the packet receive chain.
|
|
tomh@1820
|
115 |
*
|
|
tomh@1820
|
116 |
* @see ErrorModel
|
|
craigdo@3181
|
117 |
* @param em Ptr to the ErrorModel.
|
|
tomh@1820
|
118 |
*/
|
|
craigdo@3010
|
119 |
void SetReceiveErrorModel(Ptr<ErrorModel> em);
|
|
craigdo@3181
|
120 |
|
|
tomh@1820
|
121 |
/**
|
|
Craig@414
|
122 |
* Receive a packet from a connected PointToPointChannel.
|
|
Craig@414
|
123 |
*
|
|
Craig@414
|
124 |
* The PointToPointNetDevice receives packets from its connected channel
|
|
Craig@414
|
125 |
* and forwards them up the protocol stack. This is the public method
|
|
Craig@414
|
126 |
* used by the channel to indicate that the last bit of a packet has
|
|
Craig@414
|
127 |
* arrived at the device.
|
|
Craig@414
|
128 |
*
|
|
Craig@414
|
129 |
* @see PointToPointChannel
|
|
craigdo@3181
|
130 |
* @param p Ptr to the received packet.
|
|
Craig@414
|
131 |
*/
|
|
mathieu@1866
|
132 |
void Receive (Ptr<Packet> p);
|
|
tomh@1793
|
133 |
|
|
craigdo@3181
|
134 |
/**
|
|
craigdo@3181
|
135 |
* Assign a MAC address to this device.
|
|
craigdo@3181
|
136 |
*
|
|
craigdo@3181
|
137 |
* @see Mac48Address
|
|
craigdo@3181
|
138 |
* @param addr The new address.
|
|
craigdo@3181
|
139 |
*/
|
|
craigdo@3181
|
140 |
void SetAddress (Mac48Address addr);
|
|
mathieu@2655
|
141 |
|
|
craigdo@3632
|
142 |
/**
|
|
craigdo@3632
|
143 |
* Set The max frame size of packets sent over this device.
|
|
craigdo@3632
|
144 |
*
|
|
craigdo@3632
|
145 |
* Okay, that was easy to say, but the details are a bit thorny. We have a MAC-level MTU that is the payload that higher
|
|
craigdo@3632
|
146 |
* level protocols see. We have a PHY-level MTU which is the maximum number of bytes we can send over the link
|
|
craigdo@3632
|
147 |
* (cf. 1500 bytes for Ethernet). We also have a frame size which is some total number of bytes in a packet which could
|
|
craigdo@3632
|
148 |
* or could not include any framing and overhead. There can be a lot of inconsistency in definitions of these terms. For
|
|
craigdo@3632
|
149 |
* example, RFC 1042 asserts that the terms maximum transmission unit and maximum packet size are equivalent. RFC 791,
|
|
craigdo@3632
|
150 |
* however, defines MTU as the maximum sized IP datagram that can be sent. Packet size and frame size are sometimes
|
|
craigdo@3632
|
151 |
* used interchangeably.
|
|
craigdo@3632
|
152 |
*
|
|
craigdo@3632
|
153 |
* So, some careful definitions are in order to avoid confusion:
|
|
craigdo@3632
|
154 |
*
|
|
craigdo@3632
|
155 |
* In real serial channel (HDLC, for example), the wire idles (sends all ones) until the channel begins sending a packet.
|
|
craigdo@3632
|
156 |
* A frame on the wire starts with a flag character (01111110). This is followed by what is usually called the packet:
|
|
craigdo@3632
|
157 |
* address, control, payload, and a Frame Check Sequence (FCS). This is followed by another flag character. If the flag
|
|
craigdo@3632
|
158 |
* characters are used, then bit stuffing must be used to prevent flag characters from appearing in the packet and confusing
|
|
craigdo@3632
|
159 |
* the link. Som to be strictly and pedantically correct the frame size is then necessarily larger than the packet size on
|
|
craigdo@3632
|
160 |
* a real link. But, this isn't a real link, it's a simulation of a device similar to a point-to-point device, and we have
|
|
craigdo@3632
|
161 |
* no good reason to add framing bits and therefore to do bit-stuffing. So, in the case of the point-to-point device, the
|
|
craigdo@3632
|
162 |
* frame size is equal to the packet size. Since these two values are defined to be equal, there is no danger in assuming
|
|
craigdo@3632
|
163 |
* they are identical. We define packet size to be equal to frame size and this excludes the flag characters. We define a
|
|
craigdo@3632
|
164 |
* single (MAC-level) MTU that coresponds to the payload size of the packet, which is the IP-centric view of the term as
|
|
craigdo@3632
|
165 |
* seen in RFC 791.
|
|
craigdo@3632
|
166 |
*
|
|
craigdo@3632
|
167 |
* To make this concrete, consider PPP framing on a synchronous link. In this framing scheme, a real serial frame on the
|
|
craigdo@3632
|
168 |
* wire starts with a flag character, address and control characters, then a 16-bit PPP protocol ID (0x21 = IP). Then we
|
|
craigdo@3632
|
169 |
* would see the actual payload we are supposed to send, presumably an IP datagram. At then we see the FCS and finally
|
|
craigdo@3632
|
170 |
* another flag character to end the frame. We ignore the flag bits on this device since it they are not needed. We
|
|
craigdo@3632
|
171 |
* aren't really using HDLC to send frames across the link, so we don't need the address and control bits either. In fact,
|
|
craigdo@3632
|
172 |
* to encapsulate using unframed PPP all we need to do is prepend the two-byte protocol ID.
|
|
craigdo@3632
|
173 |
*
|
|
craigdo@3632
|
174 |
* Typically the limiting factor in frame size is due to hardware limitations in the underlying HDLC controller receive
|
|
craigdo@3632
|
175 |
* FIFO buffer size. This number can vary widely. For example, the Motorola MC92460 has a 64 KByte maximum frame size;
|
|
craigdo@3632
|
176 |
* the Intel IXP4XX series has a 16 KByte size. Older USARTs have a maximum frame size around 2KBytes, and typical PPP
|
|
craigdo@3632
|
177 |
* links on the Internet have their MTU set to 1500 bytes since this is what will typically be used on Ethernet segments
|
|
craigdo@3632
|
178 |
* and will avoid path MTU issues. We choose to make the default MTU 1500 bytes which then fixes the maximum frame size
|
|
craigdo@3632
|
179 |
* as described below.
|
|
craigdo@3632
|
180 |
*
|
|
craigdo@3632
|
181 |
* So, there are really two related variables at work here. There is the maximum frame size that can be sent over the
|
|
craigdo@3632
|
182 |
* link and there is the MTU.
|
|
craigdo@3632
|
183 |
*
|
|
craigdo@3632
|
184 |
* So, what do we do since these values must always be consistent in the driver? We want to actually allow a user to change
|
|
craigdo@3632
|
185 |
* these variables, but we want the results (even at intermediate stages of her ultimate change) to be consistent. We
|
|
craigdo@3632
|
186 |
* certainly don't want to require that users must understand the details of PPP encapsulation in order to set these
|
|
craigdo@3632
|
187 |
* variables.
|
|
craigdo@3632
|
188 |
*
|
|
craigdo@3632
|
189 |
* Consider the following situation: A user wants to set the maximum frame size to 16 KBytes. This user shouldn't have to
|
|
craigdo@3632
|
190 |
* concern herself that the PPP encapsulation will consume six bytes. She should not have to figure out that the MTU needs
|
|
craigdo@3632
|
191 |
* to be set to 16K - 2 bytes to make things consistent.
|
|
craigdo@3632
|
192 |
*
|
|
craigdo@3632
|
193 |
* Similarly, a user who is interested in setting the MTU to 1500 bytes should not be forced to understand that the frame
|
|
craigdo@3632
|
194 |
* size will need to be set to 1502 bytes.
|
|
craigdo@3632
|
195 |
*
|
|
craigdo@3632
|
196 |
* We could play games trying to figure out what the user wants to do, but that is typically a bad plan and programmers
|
|
craigdo@3632
|
197 |
* have a long and distinguished history of guessing wrong. We'll avoid all of that and just define a flexible behavior
|
|
craigdo@3632
|
198 |
* that can be worked to get what you want. Here it is:
|
|
craigdo@3632
|
199 |
*
|
|
craigdo@3632
|
200 |
* - If the user is changing the MTU, she is interested in getting that part of the system set, so the frame size
|
|
craigdo@3632
|
201 |
* will be changed to make it consistent;
|
|
craigdo@3632
|
202 |
*
|
|
craigdo@3632
|
203 |
* - If the user is changing the frame size, he is interested in getting that part of the system set, so the MTU
|
|
craigdo@3632
|
204 |
* will be changed to make it consistent;
|
|
craigdo@3632
|
205 |
*
|
|
craigdo@3632
|
206 |
* - You cannot define the MTU and frame size separately -- they are always tied together by the overhead of the PPP
|
|
craigdo@3632
|
207 |
* encapsulation. This is not a restriction. Consider what this means. Perhaps you want to set the frame size to some
|
|
craigdo@3632
|
208 |
* large number and the MTU to some small number. The largest packet you can send is going to be limited by the MTU, so it
|
|
craigdo@3632
|
209 |
* is not possible to send a frame larger than the MTU plus overhead. Having the ability to set a larger frame size is not
|
|
craigdo@3632
|
210 |
* useful.
|
|
craigdo@3632
|
211 |
*
|
|
craigdo@3632
|
212 |
* So, if a user calls SetFrameSize, we assume that the maximum frame size is the interesting thing for that user and
|
|
craigdo@3632
|
213 |
* we just adjust the MTU to a new "correct value" based on the current encapsulation mode. If a user calls SetMtu, we
|
|
craigdo@3632
|
214 |
* assume that the MTU is the interesting property for that user, and we adjust the frame size to a new "correct value"
|
|
craigdo@3632
|
215 |
* for the current encapsulation mode. If a user calls SetEncapsulationMode, then we take the MTU as the free variable
|
|
craigdo@3632
|
216 |
* and set its value to match the current frame size.
|
|
craigdo@3632
|
217 |
*
|
|
craigdo@3632
|
218 |
* \param frameSize The max frame size of packets sent over this device.
|
|
craigdo@3632
|
219 |
*/
|
|
craigdo@3632
|
220 |
void SetFrameSize (uint16_t frameSize);
|
|
craigdo@3632
|
221 |
|
|
craigdo@3632
|
222 |
/**
|
|
craigdo@3632
|
223 |
* Get The max frame size of packets sent over this device.
|
|
craigdo@3632
|
224 |
*
|
|
craigdo@3632
|
225 |
* \returns The max frame size of packets sent over this device.
|
|
craigdo@3632
|
226 |
*/
|
|
craigdo@3632
|
227 |
uint16_t GetFrameSize (void) const;
|
|
craigdo@3632
|
228 |
|
|
craigdo@3181
|
229 |
//
|
|
craigdo@3181
|
230 |
// Pure virtual methods inherited from NetDevice we must implement.
|
|
craigdo@3181
|
231 |
//
|
|
mathieu@2470
|
232 |
virtual void SetName(const std::string name);
|
|
mathieu@2470
|
233 |
virtual std::string GetName(void) const;
|
|
craigdo@3181
|
234 |
|
|
mathieu@2470
|
235 |
virtual void SetIfIndex(const uint32_t index);
|
|
mathieu@2470
|
236 |
virtual uint32_t GetIfIndex(void) const;
|
|
craigdo@3181
|
237 |
|
|
mathieu@2470
|
238 |
virtual Ptr<Channel> GetChannel (void) const;
|
|
mathieu@2470
|
239 |
virtual Address GetAddress (void) const;
|
|
craigdo@3181
|
240 |
|
|
mathieu@2470
|
241 |
virtual bool SetMtu (const uint16_t mtu);
|
|
mathieu@2470
|
242 |
virtual uint16_t GetMtu (void) const;
|
|
craigdo@3181
|
243 |
|
|
mathieu@2470
|
244 |
virtual bool IsLinkUp (void) const;
|
|
craigdo@3181
|
245 |
|
|
mathieu@2470
|
246 |
virtual void SetLinkChangeCallback (Callback<void> callback);
|
|
craigdo@3181
|
247 |
|
|
mathieu@2470
|
248 |
virtual bool IsBroadcast (void) const;
|
|
mathieu@2470
|
249 |
virtual Address GetBroadcast (void) const;
|
|
craigdo@3181
|
250 |
|
|
mathieu@2470
|
251 |
virtual bool IsMulticast (void) const;
|
|
craigdo@3841
|
252 |
virtual Address GetMulticast (Ipv4Address multicastGroup) const;
|
|
craigdo@3181
|
253 |
|
|
mathieu@2470
|
254 |
virtual bool IsPointToPoint (void) const;
|
|
craigdo@3181
|
255 |
|
|
gjc@3442
|
256 |
virtual bool Send(Ptr<Packet> packet, const Address &dest, uint16_t protocolNumber);
|
|
gjc@3442
|
257 |
virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
|
|
craigdo@3181
|
258 |
|
|
mathieu@2470
|
259 |
virtual Ptr<Node> GetNode (void) const;
|
|
mathieu@2600
|
260 |
virtual void SetNode (Ptr<Node> node);
|
|
craigdo@3181
|
261 |
|
|
mathieu@2470
|
262 |
virtual bool NeedsArp (void) const;
|
|
craigdo@3181
|
263 |
|
|
mathieu@2470
|
264 |
virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
|
|
mathieu@2470
|
265 |
|
|
vincent@3852
|
266 |
virtual Address GetMulticast (Ipv6Address addr) const;
|
|
vincent@3852
|
267 |
|
|
gjc@3480
|
268 |
virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
|
|
mathieu@3584
|
269 |
virtual bool SupportsSendFrom (void) const;
|
|
gjc@3480
|
270 |
|
|
tomh@1793
|
271 |
private:
|
|
tomh@1793
|
272 |
|
|
mathieu@517
|
273 |
virtual void DoDispose (void);
|
|
craigdo@3181
|
274 |
|
|
Craig@414
|
275 |
/**
|
|
Craig@414
|
276 |
* Get a copy of the attached Queue.
|
|
Craig@414
|
277 |
*
|
|
Craig@414
|
278 |
* This method is provided for any derived class that may need to get
|
|
Craig@414
|
279 |
* direct access to the underlying queue.
|
|
Craig@414
|
280 |
*
|
|
craigdo@3181
|
281 |
* @returns Ptr to the queue.
|
|
Craig@414
|
282 |
*/
|
|
mathieu@581
|
283 |
Ptr<Queue> GetQueue(void) const;
|
|
tomh@1793
|
284 |
|
|
tomh@368
|
285 |
private:
|
|
emmanuelle@975
|
286 |
/**
|
|
craigdo@3632
|
287 |
* Calculate the value for the MTU that would result from
|
|
craigdo@3632
|
288 |
* setting the frame size to the given value.
|
|
craigdo@3632
|
289 |
*/
|
|
craigdo@3682
|
290 |
uint32_t MtuFromFrameSize (uint32_t frameSize);
|
|
craigdo@3632
|
291 |
|
|
craigdo@3632
|
292 |
/**
|
|
craigdo@3632
|
293 |
* Calculate the value for the frame size that would be required
|
|
craigdo@3632
|
294 |
* to be able to set the MTU to the given value.
|
|
craigdo@3632
|
295 |
*/
|
|
craigdo@3682
|
296 |
uint32_t FrameSizeFromMtu (uint32_t mtu);
|
|
craigdo@3632
|
297 |
|
|
craigdo@3632
|
298 |
/**
|
|
mathieu@3584
|
299 |
* \returns the address of the remote device connected to this device
|
|
mathieu@3584
|
300 |
* through the point to point channel.
|
|
mathieu@3584
|
301 |
*/
|
|
mathieu@3584
|
302 |
Address GetRemote (void) const;
|
|
craigdo@3632
|
303 |
|
|
mathieu@3584
|
304 |
/**
|
|
emmanuelle@975
|
305 |
* Adds the necessary headers and trailers to a packet of data in order to
|
|
emmanuelle@975
|
306 |
* respect the protocol implemented by the agent.
|
|
emmanuelle@975
|
307 |
*/
|
|
mathieu@1866
|
308 |
void AddHeader(Ptr<Packet> p, uint16_t protocolNumber);
|
|
craigdo@3181
|
309 |
|
|
emmanuelle@975
|
310 |
/**
|
|
emmanuelle@975
|
311 |
* Removes, from a packet of data, all headers and trailers that
|
|
emmanuelle@975
|
312 |
* relate to the protocol implemented by the agent
|
|
emmanuelle@975
|
313 |
* \return Returns true if the packet should be forwarded up the
|
|
emmanuelle@975
|
314 |
* protocol stack.
|
|
emmanuelle@975
|
315 |
*/
|
|
mathieu@1866
|
316 |
bool ProcessHeader(Ptr<Packet> p, uint16_t& param);
|
|
craigdo@3181
|
317 |
|
|
Craig@414
|
318 |
/**
|
|
Craig@414
|
319 |
* Start Sending a Packet Down the Wire.
|
|
Craig@414
|
320 |
*
|
|
Craig@414
|
321 |
* The TransmitStart method is the method that is used internally in the
|
|
Craig@414
|
322 |
* PointToPointNetDevice to begin the process of sending a packet out on
|
|
Craig@414
|
323 |
* the channel. The corresponding method is called on the channel to let
|
|
Craig@414
|
324 |
* it know that the physical device this class represents has virually
|
|
Craig@414
|
325 |
* started sending signals. An event is scheduled for the time at which
|
|
Craig@414
|
326 |
* the bits have been completely transmitted.
|
|
Craig@414
|
327 |
*
|
|
Craig@414
|
328 |
* @see PointToPointChannel::TransmitStart ()
|
|
Craig@414
|
329 |
* @see TransmitCompleteEvent ()
|
|
Craig@414
|
330 |
* @param p a reference to the packet to send
|
|
Craig@414
|
331 |
* @returns true if success, false on failure
|
|
Craig@414
|
332 |
*/
|
|
mathieu@1866
|
333 |
bool TransmitStart (Ptr<Packet> p);
|
|
craigdo@3181
|
334 |
|
|
Craig@414
|
335 |
/**
|
|
Craig@414
|
336 |
* Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
|
|
Craig@414
|
337 |
*
|
|
riley@926
|
338 |
* The TransmitComplete method is used internally to finish the process
|
|
riley@926
|
339 |
* of sending a packet out on the channel.
|
|
Craig@414
|
340 |
*/
|
|
riley@926
|
341 |
void TransmitComplete(void);
|
|
craigdo@3181
|
342 |
|
|
mathieu@2470
|
343 |
void NotifyLinkUp (void);
|
|
mathieu@2470
|
344 |
|
|
Craig@414
|
345 |
/**
|
|
Craig@414
|
346 |
* Enumeration of the states of the transmit machine of the net device.
|
|
Craig@414
|
347 |
*/
|
|
Craig@378
|
348 |
enum TxMachineState
|
|
Craig@378
|
349 |
{
|
|
Craig@414
|
350 |
READY, /**< The transmitter is ready to begin transmission of a packet */
|
|
riley@926
|
351 |
BUSY /**< The transmitter is busy transmitting a packet */
|
|
Craig@378
|
352 |
};
|
|
Craig@414
|
353 |
/**
|
|
Craig@414
|
354 |
* The state of the Net Device transmit state machine.
|
|
Craig@414
|
355 |
* @see TxMachineState
|
|
Craig@414
|
356 |
*/
|
|
Craig@378
|
357 |
TxMachineState m_txMachineState;
|
|
craigdo@3181
|
358 |
|
|
Craig@414
|
359 |
/**
|
|
Craig@414
|
360 |
* The data rate that the Net Device uses to simulate packet transmission
|
|
Craig@414
|
361 |
* timing.
|
|
Craig@414
|
362 |
* @see class DataRate
|
|
Craig@414
|
363 |
*/
|
|
Craig@378
|
364 |
DataRate m_bps;
|
|
craigdo@3181
|
365 |
|
|
Craig@414
|
366 |
/**
|
|
Craig@414
|
367 |
* The interframe gap that the Net Device uses to throttle packet
|
|
Craig@414
|
368 |
* transmission
|
|
Craig@414
|
369 |
* @see class Time
|
|
Craig@414
|
370 |
*/
|
|
Craig@378
|
371 |
Time m_tInterframeGap;
|
|
craigdo@3181
|
372 |
|
|
Craig@414
|
373 |
/**
|
|
Craig@414
|
374 |
* The PointToPointChannel to which this PointToPointNetDevice has been
|
|
Craig@414
|
375 |
* attached.
|
|
Craig@414
|
376 |
* @see class PointToPointChannel
|
|
Craig@414
|
377 |
*/
|
|
mathieu@568
|
378 |
Ptr<PointToPointChannel> m_channel;
|
|
craigdo@3181
|
379 |
|
|
Craig@414
|
380 |
/**
|
|
Craig@414
|
381 |
* The Queue which this PointToPointNetDevice uses as a packet source.
|
|
Craig@414
|
382 |
* Management of this Queue has been delegated to the PointToPointNetDevice
|
|
Craig@414
|
383 |
* and it has the responsibility for deletion.
|
|
Craig@414
|
384 |
* @see class Queue
|
|
Craig@414
|
385 |
* @see class DropTailQueue
|
|
Craig@414
|
386 |
*/
|
|
mathieu@581
|
387 |
Ptr<Queue> m_queue;
|
|
craigdo@3181
|
388 |
|
|
Craig@414
|
389 |
/**
|
|
Craig@414
|
390 |
* The trace source for the packet reception events that the device can
|
|
Craig@414
|
391 |
* fire.
|
|
Craig@414
|
392 |
*
|
|
Craig@414
|
393 |
* @see class CallBackTraceSource
|
|
Craig@414
|
394 |
*/
|
|
mathieu@2502
|
395 |
TracedCallback<Ptr<const Packet> > m_rxTrace;
|
|
craigdo@3181
|
396 |
|
|
tomh@1820
|
397 |
/**
|
|
tomh@1820
|
398 |
* The trace source for the packet drop events that the device can
|
|
tomh@1820
|
399 |
* fire.
|
|
tomh@1820
|
400 |
*
|
|
tomh@1820
|
401 |
* @see class CallBackTraceSource
|
|
tomh@1820
|
402 |
*/
|
|
mathieu@2502
|
403 |
TracedCallback<Ptr<const Packet> > m_dropTrace;
|
|
riley@926
|
404 |
|
|
tomh@1820
|
405 |
/**
|
|
tomh@1820
|
406 |
* Error model for receive packet events
|
|
tomh@1820
|
407 |
*/
|
|
tomh@1820
|
408 |
Ptr<ErrorModel> m_receiveErrorModel;
|
|
mathieu@2470
|
409 |
|
|
mathieu@2470
|
410 |
Ptr<Node> m_node;
|
|
mathieu@2470
|
411 |
Mac48Address m_address;
|
|
mathieu@2470
|
412 |
NetDevice::ReceiveCallback m_rxCallback;
|
|
mathieu@3584
|
413 |
NetDevice::PromiscReceiveCallback m_promiscCallback;
|
|
mathieu@2470
|
414 |
uint32_t m_ifIndex;
|
|
mathieu@2470
|
415 |
std::string m_name;
|
|
mathieu@2470
|
416 |
bool m_linkUp;
|
|
mathieu@2470
|
417 |
Callback<void> m_linkChangeCallback;
|
|
craigdo@3632
|
418 |
|
|
craigdo@3632
|
419 |
static const uint16_t DEFAULT_MTU = 1500;
|
|
craigdo@3632
|
420 |
static const uint16_t PPP_OVERHEAD = 2;
|
|
craigdo@3632
|
421 |
static const uint16_t DEFAULT_FRAME_SIZE = DEFAULT_MTU + PPP_OVERHEAD;
|
|
craigdo@3632
|
422 |
|
|
craigdo@3632
|
423 |
/**
|
|
craigdo@3632
|
424 |
* The frame size/packet size. This corresponds to the maximum
|
|
craigdo@3632
|
425 |
* number of bytes that can be transmitted as a packet without framing.
|
|
craigdo@3632
|
426 |
* This corresponds to the 1518 byte packet size often seen on Ethernet.
|
|
craigdo@3632
|
427 |
*/
|
|
craigdo@3632
|
428 |
uint32_t m_frameSize;
|
|
craigdo@3632
|
429 |
|
|
craigdo@3632
|
430 |
/**
|
|
craigdo@3632
|
431 |
* The Maxmimum Transmission Unit. This corresponds to the maximum
|
|
craigdo@3632
|
432 |
* number of bytes that can be transmitted as seen from higher layers.
|
|
craigdo@3632
|
433 |
* This corresponds to the 1500 byte MTU size often seen on IP over
|
|
craigdo@3632
|
434 |
* Ethernet.
|
|
craigdo@3632
|
435 |
*/
|
|
craigdo@3632
|
436 |
uint32_t m_mtu;
|
|
mathieu@245
|
437 |
};
|
|
mathieu@245
|
438 |
|
|
mathieu@2502
|
439 |
} // namespace ns3
|
|
mathieu@245
|
440 |
|
|
tomh@369
|
441 |
#endif // POINT_TO_POINT_NET_DEVICE_H
|
|
mathieu@245
|
442 |
|