View | Details | Raw Unified | Return to bug 822
Collapse All | Expand All

(-)a/src/applications/udp-client-server/udp-client-server-test.cc (-1 / +1 lines)
 Lines 161-167    Link Here 
161
  apps.Start (Seconds (1.0));
161
  apps.Start (Seconds (1.0));
162
  apps.Stop (Seconds (10.0));
162
  apps.Stop (Seconds (10.0));
163
163
164
  uint32_t MaxPacketSize = 1400;
164
  uint32_t MaxPacketSize = 1400-28; // ip/udp header
165
  UdpTraceClientHelper client (i.GetAddress (1), port,"");
165
  UdpTraceClientHelper client (i.GetAddress (1), port,"");
166
  client.SetAttribute ("MaxPacketSize", UintegerValue (MaxPacketSize));
166
  client.SetAttribute ("MaxPacketSize", UintegerValue (MaxPacketSize));
167
  apps = client.Install (n.Get (0));
167
  apps = client.Install (n.Get (0));
(-)a/src/devices/bridge/bridge-net-device.cc (-2 / +7 lines)
 Lines 22-27    Link Here 
22
#include "ns3/log.h"
22
#include "ns3/log.h"
23
#include "ns3/boolean.h"
23
#include "ns3/boolean.h"
24
#include "ns3/simulator.h"
24
#include "ns3/simulator.h"
25
#include "ns3/uinteger.h"
25
26
26
NS_LOG_COMPONENT_DEFINE ("BridgeNetDevice");
27
NS_LOG_COMPONENT_DEFINE ("BridgeNetDevice");
27
28
 Lines 36-41    Link Here 
36
  static TypeId tid = TypeId ("ns3::BridgeNetDevice")
37
  static TypeId tid = TypeId ("ns3::BridgeNetDevice")
37
    .SetParent<NetDevice> ()
38
    .SetParent<NetDevice> ()
38
    .AddConstructor<BridgeNetDevice> ()
39
    .AddConstructor<BridgeNetDevice> ()
40
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
41
                   UintegerValue (0xffff),
42
                   MakeUintegerAccessor (&BridgeNetDevice::SetMtu,
43
                                         &BridgeNetDevice::GetMtu),
44
                   MakeUintegerChecker<uint16_t> ())                   
39
    .AddAttribute ("EnableLearning",
45
    .AddAttribute ("EnableLearning",
40
                   "Enable the learning mode of the Learning Bridge",
46
                   "Enable the learning mode of the Learning Bridge",
41
                   BooleanValue (true),
47
                   BooleanValue (true),
 Lines 53-60    Link Here 
53
59
54
BridgeNetDevice::BridgeNetDevice ()
60
BridgeNetDevice::BridgeNetDevice ()
55
  : m_node (0),
61
  : m_node (0),
56
    m_ifIndex (0),
62
    m_ifIndex (0)
57
    m_mtu (0xffff)
58
{
63
{
59
  NS_LOG_FUNCTION_NOARGS ();
64
  NS_LOG_FUNCTION_NOARGS ();
60
  m_channel = CreateObject<BridgeChannel> ();
65
  m_channel = CreateObject<BridgeChannel> ();
(-)a/src/devices/csma/csma-net-device.cc (-102 / +7 lines)
 Lines 50-60    Link Here 
50
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
50
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
51
                   MakeMac48AddressAccessor (&CsmaNetDevice::m_address),
51
                   MakeMac48AddressAccessor (&CsmaNetDevice::m_address),
52
                   MakeMac48AddressChecker ())
52
                   MakeMac48AddressChecker ())
53
    .AddAttribute ("FrameSize", 
53
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
54
                   "The maximum size of a packet sent over this device.",
54
                   UintegerValue (0xffff),
55
                   UintegerValue (DEFAULT_FRAME_SIZE),
55
                   MakeUintegerAccessor (&CsmaNetDevice::SetMtu,
56
                   MakeUintegerAccessor (&CsmaNetDevice::SetFrameSize,
56
                                         &CsmaNetDevice::GetMtu),
57
                                         &CsmaNetDevice::GetFrameSize),
58
                   MakeUintegerChecker<uint16_t> ())
57
                   MakeUintegerChecker<uint16_t> ())
59
    .AddAttribute ("EncapsulationMode", 
58
    .AddAttribute ("EncapsulationMode", 
60
                   "The link-layer encapsulation type to use.",
59
                   "The link-layer encapsulation type to use.",
 Lines 173-180    Link Here 
173
  // to change it here.
172
  // to change it here.
174
  //
173
  //
175
  m_encapMode = DIX;
174
  m_encapMode = DIX;
176
  m_frameSize = DEFAULT_FRAME_SIZE;
177
  m_mtu = MtuFromFrameSize (m_frameSize);
178
}
175
}
179
176
180
CsmaNetDevice::~CsmaNetDevice()
177
CsmaNetDevice::~CsmaNetDevice()
 Lines 192-267    Link Here 
192
  NetDevice::DoDispose ();
189
  NetDevice::DoDispose ();
193
}
190
}
194
191
195
  uint32_t
196
CsmaNetDevice::MtuFromFrameSize (uint32_t frameSize)
197
{
198
  NS_LOG_FUNCTION (frameSize);
199
200
  NS_ASSERT_MSG (frameSize <= std::numeric_limits<uint16_t>::max (), 
201
                 "CsmaNetDevice::MtuFromFrameSize(): Frame size should be derived from 16-bit quantity: " << frameSize);
202
203
  uint32_t newSize;
204
205
  switch (m_encapMode) 
206
    {
207
    case DIX:
208
      newSize = frameSize - ETHERNET_OVERHEAD;
209
      break;
210
    case LLC: 
211
      {
212
        LlcSnapHeader llc;
213
214
        NS_ASSERT_MSG ((uint32_t)(frameSize - ETHERNET_OVERHEAD) >= llc.GetSerializedSize (), 
215
                       "CsmaNetDevice::MtuFromFrameSize(): Given frame size too small to support LLC mode");
216
        newSize = frameSize - ETHERNET_OVERHEAD - llc.GetSerializedSize ();
217
      }
218
      break;
219
    case ILLEGAL:
220
    default:
221
      NS_FATAL_ERROR ("CsmaNetDevice::MtuFromFrameSize(): Unknown packet encapsulation mode");
222
      return 0;
223
    }
224
225
  return newSize;
226
}
227
  
228
  uint32_t
229
CsmaNetDevice::FrameSizeFromMtu (uint32_t mtu)
230
{
231
  NS_LOG_FUNCTION (mtu);
232
233
  uint32_t newSize;
234
235
  switch (m_encapMode) 
236
    {
237
    case DIX:
238
      newSize = mtu + ETHERNET_OVERHEAD;
239
      break;
240
    case LLC: 
241
      {
242
        LlcSnapHeader llc;
243
        newSize = mtu + ETHERNET_OVERHEAD + llc.GetSerializedSize ();
244
      }
245
      break;
246
    case ILLEGAL:
247
    default:
248
      NS_FATAL_ERROR ("CsmaNetDevice::FrameSizeFromMtu(): Unknown packet encapsulation mode");
249
      return 0;
250
    }
251
252
  return newSize;
253
}
254
255
  void 
192
  void 
256
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode)
193
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode)
257
{
194
{
258
  NS_LOG_FUNCTION (mode);
195
  NS_LOG_FUNCTION (mode);
259
196
260
  m_encapMode = mode;
197
  m_encapMode = mode;
261
  m_mtu = MtuFromFrameSize (m_frameSize);
262
198
263
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
199
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
264
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
265
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
200
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
266
}
201
}
267
202
 Lines 272-295    Link Here 
272
  return m_encapMode;
207
  return m_encapMode;
273
}
208
}
274
  
209
  
275
  bool
210
bool
276
CsmaNetDevice::SetMtu (uint16_t mtu)
211
CsmaNetDevice::SetMtu (uint16_t mtu)
277
{
212
{
278
  NS_LOG_FUNCTION (mtu);
213
  NS_LOG_FUNCTION (this << mtu);
279
280
  uint32_t newFrameSize = FrameSizeFromMtu (mtu);
281
282
  if (newFrameSize > std::numeric_limits<uint16_t>::max ())
283
    {
284
      NS_LOG_WARN ("CsmaNetDevice::SetMtu(): Frame size overflow, MTU not set.");
285
      return false;
286
    }
287
288
  m_frameSize = newFrameSize;
289
  m_mtu = mtu;
214
  m_mtu = mtu;
290
215
291
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
216
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
292
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
293
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
217
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
294
218
295
  return true;
219
  return true;
 Lines 302-325    Link Here 
302
  return m_mtu;
226
  return m_mtu;
303
}
227
}
304
228
305
  void 
306
CsmaNetDevice::SetFrameSize (uint16_t frameSize)
307
{
308
  NS_LOG_FUNCTION (frameSize);
309
310
  m_frameSize = frameSize;
311
  m_mtu = MtuFromFrameSize (frameSize);
312
313
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
314
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
315
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
316
}
317
318
  uint16_t
319
CsmaNetDevice::GetFrameSize (void) const
320
{
321
  return m_frameSize;
322
}
323
229
324
  void
230
  void
325
CsmaNetDevice::SetSendEnable (bool sendEnable)
231
CsmaNetDevice::SetSendEnable (bool sendEnable)
 Lines 381-387    Link Here 
381
  NS_LOG_LOGIC ("p->GetSize () = " << p->GetSize ());
287
  NS_LOG_LOGIC ("p->GetSize () = " << p->GetSize ());
382
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
288
  NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
383
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
289
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
384
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
385
290
386
  uint16_t lengthType = 0;
291
  uint16_t lengthType = 0;
387
  switch (m_encapMode) 
292
  switch (m_encapMode) 
 Lines 435-441    Link Here 
435
        // but with an LLC/SNAP header added to the payload as in IEEE 802.2
340
        // but with an LLC/SNAP header added to the payload as in IEEE 802.2
436
        //      
341
        //      
437
        lengthType = p->GetSize ();
342
        lengthType = p->GetSize ();
438
        NS_ASSERT_MSG (lengthType <= m_frameSize - 18,
343
        NS_ASSERT_MSG (lengthType <= GetMtu (),
439
          "CsmaNetDevice::AddHeader(): 802.3 Length/Type field with LLC/SNAP: "
344
          "CsmaNetDevice::AddHeader(): 802.3 Length/Type field with LLC/SNAP: "
440
          "length interpretation must not exceed device frame size minus overhead");
345
          "length interpretation must not exceed device frame size minus overhead");
441
      }
346
      }
(-)a/src/devices/csma/csma-net-device.h (-121 / +1 lines)
 Lines 185-292    Link Here 
185
  void SetReceiveEnable (bool enable);
185
  void SetReceiveEnable (bool enable);
186
186
187
  /**
187
  /**
188
   * Set The max frame size of packets sent over this device.
189
   *
190
   * 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 
191
   * level protocols see.  We have a PHY-level MTU which is the maximum number of bytes we can send over the link 
192
   * (cf. 1500 bytes for Ethernet).  We also have a frame size which is some total number of bytes in a packet which could
193
   * or could not include any framing and overhead.  There can be a lot of inconsistency in definitions of these terms.  For
194
   * example, RFC 1042 asserts that the terms maximum transmission unit and maximum packet size are equivalent.  RFC 791, 
195
   * however, defines MTU as the maximum sized IP datagram that can be sent.  Packet size and frame size are sometimes
196
   * used interchangeably.
197
   *
198
   * So, some careful definitions are in order to avoid confusion:
199
   *
200
   * In real Ethernet, a packet on the wire starts with a preamble of seven bytes of alternating ones and zeroes followed by
201
   * a Start-of-Frame-Delimeter (10101011).  This is followed by what is usually called the packet: a MAC destination and 
202
   * source, a type field, payload, a possible padding field and a CRC.  To be strictly and pedantically correct the frame 
203
   * size is necessarily larger than the packet size on a real Ethernet.  But, this isn't a real Ethernet, it's a simulation
204
   * of a device similar to Ethernet, and we have no good reason to add framing bits.  So, in the case of the CSMA device, 
205
   * the frame size is equal to the packet size.  Since these two values are equal, there is no danger in assuming they are 
206
   * identical.  We do not implement any padding out to a minimum frame size, so padding is a non-issue.  We define packet 
207
   * size to be equal to frame size and this excludes the preamble and SFD bytes of a real Ethernet frame.  We define a 
208
   * single (MAC-level) MTU that coresponds to the payload size of the packet, which is the IP-centric view of the term as
209
   * seen in RFC 791.
210
   *
211
   * To make this concrete, consider DIX II (Digital Equipment, Intel, Xerox type II) framing, which is used in most TCP/IP 
212
   * stacks.  NetWare and Wireshark call this framing Ethernet II, by the way.  In this framing scheme, a real packet on the 
213
   * wire starts with the preamble and Start-of-Frame-Delimeter (10101011).  We ignore these bits on this device since it they 
214
   * are not  needed.  In DIX II, the SFD is followed by the MAC (48) destination address (6 bytes), source address (6 bytes), 
215
   * the EtherType field (2 bytes), payload (0-1500 bytes) and a CRC (4 bytes) -- this corresponds to our entire frame.  The
216
   * payload of the packet/frame in DIX can be from 0 to 1500 bytes.  It is the maxmimum value of this payload that we call
217
   * the MTU.  Typically, one sees the MTU set to 1500 bytes and the maximum frame size set to 1518 bytes in Ethernet-based
218
   * networks.
219
   *
220
   * Different framing schemes can make for different MTU and frame size relationships.  For example, we support LLC/SNAP
221
   * encapsulation which adds eight bytes of header overhead to the usual DIX framing.  In this case, if the maximum frame
222
   * size is left at 1518 bytes, we need to export an MTU that reflects the loss of eight bytes for a total of 1492.
223
   * 
224
   * Another complication is that IEEE 802.1Q adds four bytes to the maximum frame size for VLAN tagging.  In order to 
225
   * provide an MTU of 1500 bytes, the frame size would need to increased to 1522 bytes to absorb the additional overhead.
226
   *
227
   * So, there are really three variables that are not entirely free at work here.  There is the maximum frame size, the
228
   * MTU and the framing scheme which we call the encapsulation mode.
229
   *
230
   * So, what do we do since there are be three values which must always be consistent in the driver?  Which values to we
231
   * allow to be changed and how do we ensure the other two are consistent?  We want to actually allow a user to change 
232
   * these three variables in flexible ways, but we want the results (even at intermediate stages of her ultimate change) to 
233
   * be consistent.  We certainly don't want to require that users must understand the various requirements of an enapsulation
234
   * mode in order to set these variables.
235
   *
236
   * Consider the following situation:  A user wants to set the maximum frame size to 1418 bytes instead of 1518.  This
237
   * user shouldn't have to concern herself that the current encapuslation mode is LLC/SNAP and this will consume eight bytes.
238
   * She should not have to also figure out that the MTU needs to be set to 1392 bytes, and she should certainly not have to 
239
   * do this in some special order to keep intermediate steps consistent.
240
   *
241
   * Similarly, a user who is interested in setting the MTU to 1400 bytes should not be forced to understand that 
242
   * (based on encapsulation mode) the frame size may need to be set to eighteen + eight bytes more than what he wants 
243
   * in certain cases (802,3 + LLC/SNAP), twenty-two + zero bytes in others (802.1Q) and other inscrutable combinations
244
   *
245
   * Now, consider a user who is only interested in changing the encapsulation mode from LLC/SNAP to DIX.  This 
246
   * is going to change the relationship between the MTU and the frame size.  We've may have to come up with a new value 
247
   * for at least one of the these?  Which one?  There are too many free variables.
248
   *
249
   * We could play games trying to figure out what the user wants to do, but that is typically a bad plan and programmers
250
   * have a long and distinguished history of guessing wrong.  We'll avoid all of that and just define a flexible behavior
251
   * that can be worked to get what you want.  Here it is:
252
   *
253
   * - If the user is changing the encapsulation mode, the PHY MTU will remain fixed and the MAC MTU will change, if required,
254
   * to make the three values consistent;
255
   *
256
   * - If the user is changing the MTU, she is interested in getting that part of the system set, so the frame size
257
   * will be changed to make the three values consistent;
258
   *
259
   * - If the user is changing the frame size, he is interested in getting that part of the system set, so the MTU
260
   * will be changed to make the three values consistent;
261
   *
262
   * - You cannot define the MTU and frame size separately -- they are always tied together by the emulation mode.  This
263
   * is not a restriction.  Consider what this means.  Perhaps you want to set the frame size to some large number and the
264
   * MTU to some small number.  The largest packet you can send is going to be limited by the MTU, so it is not possible to
265
   * send a frame larger than the MTU plus overhead.  The larger frame size is not useful.
266
   * 
267
   * So, if a user calls SetFrameSize, we assume that the maximum frame size is the interesting thing for that user and
268
   * we just adjust the MTU to a new "correct value" based on the current encapsulation mode.  If a user calls SetMtu, we 
269
   * assume that the MTU is the interesting property for that user, and we adjust the frame size to a new "correct value" 
270
   * for the current encapsulation mode.  If a user calls SetEncapsulationMode, then we take the MTU as the free variable 
271
   * and set its value to match the current frame size.
272
   *
273
   * \param frameSize The max frame size of packets sent over this device.
274
   */
275
  void SetFrameSize (uint16_t frameSize);
276
277
  /**
278
   * Get The max frame size of packets sent over this device.
279
   *
280
   * \returns The max frame size of packets sent over this device.
281
   */
282
  uint16_t GetFrameSize (void) const;
283
284
  /**
285
   * Set the encapsulation mode of this device.
188
   * Set the encapsulation mode of this device.
286
   *
189
   *
287
   * \param mode The encapsulation mode of this device.
190
   * \param mode The encapsulation mode of this device.
288
   *
191
   *
289
   * \see SetFrameSize
290
   */
192
   */
291
  void SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode);
193
  void SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode);
292
194
 Lines 456-475    Link Here 
456
  void Init (bool sendEnable, bool receiveEnable);
358
  void Init (bool sendEnable, bool receiveEnable);
457
359
458
  /**
360
  /**
459
   * Calculate the value for the MTU that would result from 
460
   * setting the frame size to the given value.
461
   * \param frameSize size of frame
462
   */
463
  uint32_t MtuFromFrameSize (uint32_t frameSize);
464
465
  /**
466
   * Calculate the value for the frame size that would be required
467
   * to be able to set the MTU to the given value.
468
   * \param mtu MTU
469
   */
470
  uint32_t FrameSizeFromMtu (uint32_t mtu);
471
472
  /**
473
   * Start Sending a Packet Down the Wire.
361
   * Start Sending a Packet Down the Wire.
474
   *
362
   *
475
   * The TransmitStart method is the method that is used internally in
363
   * The TransmitStart method is the method that is used internally in
 Lines 804-818    Link Here 
804
   */
692
   */
805
  TracedCallback<> m_linkChangeCallbacks;
693
  TracedCallback<> m_linkChangeCallbacks;
806
694
807
  static const uint16_t DEFAULT_FRAME_SIZE = 1518;
695
  static const uint16_t DEFAULT_MTU = 1500;
808
  static const uint16_t ETHERNET_OVERHEAD = 18;
809
810
  /**
811
   * The frame size/packet size.  This corresponds to the maximum 
812
   * number of bytes that can be transmitted as a packet without framing.
813
   * This corresponds to the 1518 byte packet size often seen on Ethernet.
814
   */
815
  uint32_t m_frameSize;
816
696
817
  /**
697
  /**
818
   * The Maxmimum Transmission Unit.  This corresponds to the maximum 
698
   * The Maxmimum Transmission Unit.  This corresponds to the maximum 
(-)a/src/devices/emu/emu-net-device.cc (+4 lines)
 Lines 63-68    Link Here 
63
  static TypeId tid = TypeId ("ns3::EmuNetDevice")
63
  static TypeId tid = TypeId ("ns3::EmuNetDevice")
64
    .SetParent<NetDevice> ()
64
    .SetParent<NetDevice> ()
65
    .AddConstructor<EmuNetDevice> ()
65
    .AddConstructor<EmuNetDevice> ()
66
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
67
                   UintegerValue (0), // arbitrary un-used value because no setter
68
                   MakeUintegerAccessor (&EmuNetDevice::GetMtu),
69
                   MakeUintegerChecker<uint16_t> ())                   
66
    .AddAttribute ("Address", 
70
    .AddAttribute ("Address", 
67
                   "The ns-3 MAC address of this (virtual) device.",
71
                   "The ns-3 MAC address of this (virtual) device.",
68
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
72
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
(-)a/src/devices/mesh/mesh-point-device.cc (-1 / +6 lines)
 Lines 39-44    Link Here 
39
  static TypeId tid = TypeId ("ns3::MeshPointDevice")
39
  static TypeId tid = TypeId ("ns3::MeshPointDevice")
40
  .SetParent<NetDevice> ()
40
  .SetParent<NetDevice> ()
41
  .AddConstructor<MeshPointDevice> ()
41
  .AddConstructor<MeshPointDevice> ()
42
  .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
43
                 UintegerValue (0xffff),
44
                 MakeUintegerAccessor (&MeshPointDevice::SetMtu,
45
                                       &MeshPointDevice::GetMtu),
46
                 MakeUintegerChecker<uint16_t> ())                   
42
  .AddAttribute ( "RoutingProtocol",
47
  .AddAttribute ( "RoutingProtocol",
43
                  "The mesh routing protocol used by this mesh point.",
48
                  "The mesh routing protocol used by this mesh point.",
44
                  PointerValue (),
49
                  PointerValue (),
 Lines 50-56    Link Here 
50
}
55
}
51
56
52
MeshPointDevice::MeshPointDevice () :
57
MeshPointDevice::MeshPointDevice () :
53
  m_ifIndex (0), m_mtu (1500)
58
  m_ifIndex (0)
54
{
59
{
55
  NS_LOG_FUNCTION_NOARGS ();
60
  NS_LOG_FUNCTION_NOARGS ();
56
  m_channel = CreateObject<BridgeChannel> ();
61
  m_channel = CreateObject<BridgeChannel> ();
(-)a/src/devices/point-to-point/point-to-point-net-device.cc (-71 / +6 lines)
 Lines 41-57    Link Here 
41
  static TypeId tid = TypeId ("ns3::PointToPointNetDevice")
41
  static TypeId tid = TypeId ("ns3::PointToPointNetDevice")
42
    .SetParent<NetDevice> ()
42
    .SetParent<NetDevice> ()
43
    .AddConstructor<PointToPointNetDevice> ()
43
    .AddConstructor<PointToPointNetDevice> ()
44
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
45
                   UintegerValue (DEFAULT_MTU),
46
                   MakeUintegerAccessor (&PointToPointNetDevice::SetMtu,
47
                                         &PointToPointNetDevice::GetMtu),
48
                   MakeUintegerChecker<uint16_t> ())                   
44
    .AddAttribute ("Address", 
49
    .AddAttribute ("Address", 
45
                   "The MAC address of this device.",
50
                   "The MAC address of this device.",
46
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
51
                   Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
47
                   MakeMac48AddressAccessor (&PointToPointNetDevice::m_address),
52
                   MakeMac48AddressAccessor (&PointToPointNetDevice::m_address),
48
                   MakeMac48AddressChecker ())
53
                   MakeMac48AddressChecker ())
49
    .AddAttribute ("FrameSize", 
50
                   "The maximum size of a packet sent over this device.",
51
                   UintegerValue (DEFAULT_FRAME_SIZE),
52
                   MakeUintegerAccessor (&PointToPointNetDevice::SetFrameSize,
53
                                         &PointToPointNetDevice::GetFrameSize),
54
                   MakeUintegerChecker<uint16_t> ())
55
    .AddAttribute ("DataRate", 
54
    .AddAttribute ("DataRate", 
56
                   "The default data rate for point to point links",
55
                   "The default data rate for point to point links",
57
                   DataRateValue (DataRate ("32768b/s")),
56
                   DataRateValue (DataRate ("32768b/s")),
 Lines 152-167    Link Here 
152
  m_currentPkt (0)
151
  m_currentPkt (0)
153
{
152
{
154
  NS_LOG_FUNCTION (this);
153
  NS_LOG_FUNCTION (this);
155
156
  //
157
  // A quick sanity check to ensure consistent constants.
158
  //
159
  PppHeader ppp;
160
  NS_ASSERT_MSG (PPP_OVERHEAD == ppp.GetSerializedSize (), 
161
                 "PointToPointNetDevice::PointToPointNetDevice(): PPP_OVERHEAD inconsistent");
162
163
  m_frameSize = DEFAULT_FRAME_SIZE;
164
  m_mtu = MtuFromFrameSize (m_frameSize);
165
}
154
}
166
155
167
PointToPointNetDevice::~PointToPointNetDevice ()
156
PointToPointNetDevice::~PointToPointNetDevice ()
 Lines 594-658    Link Here 
594
  return Address ();
583
  return Address ();
595
}
584
}
596
585
597
  uint32_t
598
PointToPointNetDevice::MtuFromFrameSize (uint32_t frameSize)
599
{
600
  NS_LOG_FUNCTION (frameSize);
601
  NS_ASSERT_MSG (frameSize <= std::numeric_limits<uint16_t>::max (), 
602
                 "PointToPointNetDevice::MtuFromFrameSize(): Frame size should be derived from 16-bit quantity: " << 
603
                 frameSize);
604
  PppHeader ppp;
605
  NS_ASSERT_MSG ((uint32_t)frameSize >= ppp.GetSerializedSize (), 
606
                 "PointToPointNetDevice::MtuFromFrameSize(): Given frame size too small to support PPP");
607
  return frameSize - ppp.GetSerializedSize ();
608
}
609
  
610
  uint32_t
611
PointToPointNetDevice::FrameSizeFromMtu (uint32_t mtu)
612
{
613
  NS_LOG_FUNCTION (mtu);
614
615
  PppHeader ppp;
616
  return mtu + ppp.GetSerializedSize ();
617
}
618
619
  void 
620
PointToPointNetDevice::SetFrameSize (uint16_t frameSize)
621
{
622
  NS_LOG_FUNCTION (frameSize);
623
624
  m_frameSize = frameSize;
625
  m_mtu = MtuFromFrameSize (frameSize);
626
627
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
628
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
629
}
630
631
  uint16_t
632
PointToPointNetDevice::GetFrameSize (void) const
633
{
634
  return m_frameSize;
635
}
636
637
  bool
586
  bool
638
PointToPointNetDevice::SetMtu (uint16_t mtu)
587
PointToPointNetDevice::SetMtu (uint16_t mtu)
639
{
588
{
640
  NS_LOG_FUNCTION (mtu);
589
  NS_LOG_FUNCTION (this << mtu);
641
642
  uint32_t newFrameSize = FrameSizeFromMtu (mtu);
643
644
  if (newFrameSize > std::numeric_limits<uint16_t>::max ())
645
    {
646
      NS_LOG_WARN ("PointToPointNetDevice::SetMtu(): Frame size overflow, MTU not set.");
647
      return false;
648
    }
649
650
  m_frameSize = newFrameSize;
651
  m_mtu = mtu;
590
  m_mtu = mtu;
652
653
  NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
654
  NS_LOG_LOGIC ("m_mtu = " << m_mtu);
655
656
  return true;
591
  return true;
657
}
592
}
658
593
(-)a/src/devices/point-to-point/point-to-point-net-device.h (-125 lines)
 Lines 138-246    Link Here 
138
   */
138
   */
139
  void Receive (Ptr<Packet> p);
139
  void Receive (Ptr<Packet> p);
140
140
141
  /**
142
   * \brief Set the max frame size of L2 frames sent over this device.
143
   *
144
   * We use the following terminology.  MTU is the maximum sized payload 
145
   * of the point-to-point frame.  For example, if the MTU is 1500 bytes, 
146
   * then any IP datagram sent to the device must be smaller for equal to 
147
   * the MTU.  The MTU is an attribute of base class NetDevice.
148
   *
149
   * The maximum frame size is the maximum size of the L2 frame that can
150
   * be sent on the channel.  Typically this is a bit larger than the MTU
151
   * to account for framing and header overhead.  Note that the maximum
152
   * frame size constrains the MTU unless the L2 performs segmentation
153
   * and reassembly.
154
   *
155
   * In real serial channel (HDLC, for example), the wire idles (sends 
156
   * all ones) until the channel begins sending a packet.
157
   * A frame on the wire starts with a flag character (01111110).  This is 
158
   * followed by what is usually called the packet: * address, control, 
159
   * payload, and a Frame Check Sequence (FCS).  This is followed by 
160
   * another flag character.  If the flag characters are used, then bit 
161
   * stuffing must be used to prevent flag characters from appearing in 
162
   * the packet and confusing the receiver.  But, this isn't a real link, 
163
   * it's a simulation of a device similar to a point-to-point device, and 
164
   * we have no good reason to add framing bits and therefore to do 
165
   * bit-stuffing.  So, in the case of the point-to-point device, the frame 
166
   * size is equal to the packet size.  Since these two values are defined 
167
   * to be equal, there is no danger in assuming they are identical.  
168
   * We define packet size to be equal to frame size and this excludes 
169
   * the flag characters.  We define a single (MAC-level) MTU that 
170
   * corresponds to the payload size of the packet, which is the 
171
   * IP-centric view of the term as seen in RFC 791.
172
   *
173
   * To make this concrete, consider an example PPP framing on a 
174
   * synchronous link.  In this framing scheme, a real serial frame on the 
175
   * wire starts with a flag character, address and control characters, 
176
   * then a 16-bit PPP protocol ID (0x21 = IP).  Then we would see the 
177
   * actual payload we are supposed to send, presumably an IP datagram.  
178
   * At then we see the FCS and finally another flag character to end 
179
   * the frame.  We ignore the flag bits on this device since it they are 
180
   * not needed.  We aren't really using HDLC to send frames across the 
181
   * link, so we don't need the address and control bits either.  In fact,
182
   * to encapsulate using unframed PPP all we need to do is prepend the 
183
   * two-byte protocol ID.
184
   *
185
   * Typically the limiting factor in frame size is due to hardware 
186
   * limitations in the underlying HDLC controller receive FIFO buffer size.  
187
   * This number can vary widely.  For example, the Motorola MC92460 has 
188
   * a 64 KByte maximum frame size;  the Intel IXP4XX series has a 16 
189
   * KByte size.  Older USARTs have a maximum frame size around 2KBytes, 
190
   * and typical PPP links on the Internet have their MTU set to 1500 
191
   * bytes since this is what will typically be used on Ethernet segments
192
   * and will avoid path MTU issues.  We choose to make the default MTU 
193
   * 1500 bytes which then fixes the maximum frame size
194
   * as described below.
195
   *
196
   * So, there are really two related variables at work here.  There 
197
   * is the maximum frame size that can be sent over the
198
   * link and there is the MTU.
199
   *
200
   * So, what do we do since these values must always be consistent in the 
201
   * driver?  We want to actually allow a user to change these variables, 
202
   * but we want the results (even at intermediate stages of her ultimate 
203
   * change) to be consistent.  We certainly don't want to require that 
204
   * users must understand the details of PPP encapsulation in order to 
205
   * set these variables.  We therefore link these variables as follows:
206
   *
207
   * - If the user is changing the MTU, he or she is interested in 
208
   *   getting that part of the system set, so the frame size
209
   *   will be changed to make it consistent;
210
   *
211
   * - If the user is changing the frame size, he or she is interested 
212
   *   in getting that part of the system set, so the MTU will be changed 
213
   *   to make it consistent;
214
   *
215
   * - You cannot define the MTU and frame size separately -- they are 
216
   *   always tied together by the overhead of the PPP encapsulation.  
217
   *   This is not a restriction.  Consider what this means.  Perhaps you 
218
   *   want to set the frame size to some large number and the MTU to 
219
   *   some small number.  The largest packet you can send is going to 
220
   *   be limited by the MTU, so it is not possible to send a frame 
221
   *   larger than the MTU plus overhead.  Having the ability to set a  
222
   *   larger frame size is not useful.
223
   * 
224
   * So, if a user calls SetFrameSize, we assume that the maximum frame 
225
   * size is the interesting thing for that user and we just adjust 
226
   * the MTU to a new "correct value" based on the current encapsulation 
227
   * mode.  If a user calls SetMtu, we assume that the MTU is the 
228
   * interesting property for that user, and we adjust the frame size to 
229
   * a new "correct value" for the current encapsulation mode.  If a 
230
   * user calls SetEncapsulationMode, then we take the MTU as the free 
231
   * variable and set its value to match the current frame size.
232
   *
233
   * \param frameSize The max frame size of packets sent over this device.
234
   */
235
  void SetFrameSize (uint16_t frameSize);
236
237
  /**
238
   * Get the max frame size of packets sent over this device.
239
   *
240
   * \returns The max frame size of packets sent over this device.
241
   */
242
  uint16_t GetFrameSize (void) const;
243
244
  // The remaining methods are documented in ns3::NetDevice*
141
  // The remaining methods are documented in ns3::NetDevice*
245
  
142
  
246
  virtual void SetIfIndex(const uint32_t index);
143
  virtual void SetIfIndex(const uint32_t index);
 Lines 287-305    Link Here 
287
  virtual void DoDispose (void);
184
  virtual void DoDispose (void);
288
185
289
private:
186
private:
290
  /**
291
   * Calculate the value for the MTU that would result from 
292
   * setting the frame size to the given value.
293
   * \param frameSize size of frame
294
   */
295
  uint32_t MtuFromFrameSize (uint32_t frameSize);
296
297
  /**
298
   * Calculate the value for the frame size that would be required
299
   * to be able to set the MTU to the given value.
300
   * \param mtu MTU
301
   */
302
  uint32_t FrameSizeFromMtu (uint32_t mtu);
303
187
304
  /**
188
  /**
305
   * \returns the address of the remote device connected to this device
189
   * \returns the address of the remote device connected to this device
 Lines 544-558    Link Here 
544
  TracedCallback<> m_linkChangeCallbacks;
428
  TracedCallback<> m_linkChangeCallbacks;
545
429
546
  static const uint16_t DEFAULT_MTU = 1500;
430
  static const uint16_t DEFAULT_MTU = 1500;
547
  static const uint16_t PPP_OVERHEAD = 2;
548
  static const uint16_t DEFAULT_FRAME_SIZE = DEFAULT_MTU + PPP_OVERHEAD;
549
550
  /**
551
   * The frame size/packet size.  This corresponds to the maximum 
552
   * number of bytes that can be transmitted as a packet without framing.
553
   * This corresponds to the 1518 byte packet size often seen on Ethernet.
554
   */
555
  uint32_t m_frameSize;
556
431
557
  /**
432
  /**
558
   * The Maxmimum Transmission Unit.  This corresponds to the maximum 
433
   * The Maxmimum Transmission Unit.  This corresponds to the maximum 
(-)a/src/devices/tap-bridge/tap-bridge.cc (-1 / +6 lines)
 Lines 33-38    Link Here 
33
#include "ns3/simulator.h"
33
#include "ns3/simulator.h"
34
#include "ns3/realtime-simulator-impl.h"
34
#include "ns3/realtime-simulator-impl.h"
35
#include "ns3/system-thread.h"
35
#include "ns3/system-thread.h"
36
#include "ns3/uinteger.h"
36
37
37
#include <sys/wait.h>
38
#include <sys/wait.h>
38
#include <sys/stat.h>
39
#include <sys/stat.h>
 Lines 74-79    Link Here 
74
  static TypeId tid = TypeId ("ns3::TapBridge")
75
  static TypeId tid = TypeId ("ns3::TapBridge")
75
    .SetParent<NetDevice> ()
76
    .SetParent<NetDevice> ()
76
    .AddConstructor<TapBridge> ()
77
    .AddConstructor<TapBridge> ()
78
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
79
                   UintegerValue (0),
80
                   MakeUintegerAccessor (&TapBridge::SetMtu,
81
                                         &TapBridge::GetMtu),
82
                   MakeUintegerChecker<uint16_t> ())                   
77
    .AddAttribute ("DeviceName", 
83
    .AddAttribute ("DeviceName", 
78
                   "The name of the tap device to create.",
84
                   "The name of the tap device to create.",
79
                   StringValue (""),
85
                   StringValue (""),
 Lines 126-132    Link Here 
126
TapBridge::TapBridge ()
132
TapBridge::TapBridge ()
127
: m_node (0),
133
: m_node (0),
128
  m_ifIndex (0),
134
  m_ifIndex (0),
129
  m_mtu (0),
130
  m_sock (-1),
135
  m_sock (-1),
131
  m_startEvent (),
136
  m_startEvent (),
132
  m_stopEvent (),
137
  m_stopEvent (),
(-)a/src/devices/virtual-net-device/virtual-net-device.cc (-1 / +6 lines)
 Lines 27-32    Link Here 
27
#include "virtual-net-device.h"
27
#include "virtual-net-device.h"
28
#include "ns3/channel.h"
28
#include "ns3/channel.h"
29
#include "ns3/trace-source-accessor.h"
29
#include "ns3/trace-source-accessor.h"
30
#include "ns3/uinteger.h"
30
31
31
32
32
NS_LOG_COMPONENT_DEFINE ("VirtualNetDevice");
33
NS_LOG_COMPONENT_DEFINE ("VirtualNetDevice");
 Lines 41-46    Link Here 
41
  static TypeId tid = TypeId ("ns3::VirtualNetDevice")
42
  static TypeId tid = TypeId ("ns3::VirtualNetDevice")
42
    .SetParent<NetDevice> ()
43
    .SetParent<NetDevice> ()
43
    .AddConstructor<VirtualNetDevice> ()
44
    .AddConstructor<VirtualNetDevice> ()
45
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
46
                   UintegerValue (0xffff),
47
                   MakeUintegerAccessor (&VirtualNetDevice::SetMtu,
48
                                         &VirtualNetDevice::GetMtu),
49
                   MakeUintegerChecker<uint16_t> ())                   
44
    .AddTraceSource ("MacTx", 
50
    .AddTraceSource ("MacTx", 
45
                     "Trace source indicating a packet has arrived for transmission by this device",
51
                     "Trace source indicating a packet has arrived for transmission by this device",
46
                     MakeTraceSourceAccessor (&VirtualNetDevice::m_macTxTrace))
52
                     MakeTraceSourceAccessor (&VirtualNetDevice::m_macTxTrace))
 Lines 69-75    Link Here 
69
{
75
{
70
  m_needsArp = false;
76
  m_needsArp = false;
71
  m_supportsSendFrom = true;
77
  m_supportsSendFrom = true;
72
  m_mtu = 65535;
73
  m_isPointToPoint = true;
78
  m_isPointToPoint = true;
74
}
79
}
75
80
(-)a/src/devices/virtual-net-device/virtual-net-device.h (-2 / +1 lines)
 Lines 91-98    Link Here 
91
  void SetSupportsSendFrom (bool supportsSendFrom);
91
  void SetSupportsSendFrom (bool supportsSendFrom);
92
92
93
  /**
93
  /**
94
   * \brief Configure the reported MTU for the virtual device. The
94
   * \brief Configure the reported MTU for the virtual device.
95
   * default value is 65535.
96
   * \param mtu MTU value to set
95
   * \param mtu MTU value to set
97
   * \return whether the MTU value was within legal bounds
96
   * \return whether the MTU value was within legal bounds
98
   */
97
   */
(-)a/src/devices/wifi/wifi-mac.cc (-11 lines)
 Lines 175-185    Link Here 
175
                   TimeValue (GetDefaultMaxPropagationDelay ()),
175
                   TimeValue (GetDefaultMaxPropagationDelay ()),
176
                   MakeTimeAccessor (&WifiMac::m_maxPropagationDelay),
176
                   MakeTimeAccessor (&WifiMac::m_maxPropagationDelay),
177
                   MakeTimeChecker ())
177
                   MakeTimeChecker ())
178
    .AddAttribute ("MaxMsduSize", "The maximum size of an MSDU accepted by the MAC layer."
179
                   "This value conforms to the specification.",
180
		   UintegerValue (2304),
181
		   MakeUintegerAccessor (&WifiMac::m_maxMsduSize),
182
		   MakeUintegerChecker<uint16_t> (1,2304))
183
    .AddAttribute ("Ssid", "The ssid we want to belong to.",
178
    .AddAttribute ("Ssid", "The ssid we want to belong to.",
184
		   SsidValue (Ssid ("default")),
179
		   SsidValue (Ssid ("default")),
185
		   MakeSsidAccessor (&WifiMac::GetSsid,
180
		   MakeSsidAccessor (&WifiMac::GetSsid,
 Lines 232-243    Link Here 
232
  return m_maxPropagationDelay;
227
  return m_maxPropagationDelay;
233
}
228
}
234
229
235
uint32_t 
236
WifiMac::GetMaxMsduSize (void) const
237
{
238
  return m_maxMsduSize;
239
}
240
241
void 
230
void 
242
WifiMac::NotifyTx (Ptr<const Packet> packet)
231
WifiMac::NotifyTx (Ptr<const Packet> packet)
243
{
232
{
(-)a/src/devices/wifi/wifi-mac.h (-5 lines)
 Lines 111-120    Link Here 
111
   * Unused for now.
111
   * Unused for now.
112
   */
112
   */
113
  Time GetMaxPropagationDelay (void) const;
113
  Time GetMaxPropagationDelay (void) const;
114
  /**
115
   * \returns the maximum size of a MAC-level data payload.
116
   */
117
  uint32_t GetMaxMsduSize (void) const;
118
114
119
  /**
115
  /**
120
   * \returns the MAC address associated to this MAC layer.
116
   * \returns the MAC address associated to this MAC layer.
 Lines 246-252    Link Here 
246
  virtual void FinishConfigureStandard (enum WifiPhyStandard standard) = 0;
242
  virtual void FinishConfigureStandard (enum WifiPhyStandard standard) = 0;
247
243
248
  Time m_maxPropagationDelay;
244
  Time m_maxPropagationDelay;
249
  uint32_t m_maxMsduSize;
250
245
251
  void Configure80211a (void);
246
  void Configure80211a (void);
252
  void Configure80211b (void);
247
  void Configure80211b (void);
(-)a/src/devices/wifi/wifi-net-device.cc (-11 / +7 lines)
 Lines 42-47    Link Here 
42
  static TypeId tid = TypeId ("ns3::WifiNetDevice")
42
  static TypeId tid = TypeId ("ns3::WifiNetDevice")
43
    .SetParent<NetDevice> ()
43
    .SetParent<NetDevice> ()
44
    .AddConstructor<WifiNetDevice> ()
44
    .AddConstructor<WifiNetDevice> ()
45
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
46
                   UintegerValue (MAX_MSDU_SIZE),
47
                   MakeUintegerAccessor (&WifiNetDevice::SetMtu,
48
                                         &WifiNetDevice::GetMtu),
49
                   MakeUintegerChecker<uint16_t> (1,MAX_MSDU_SIZE))
45
    .AddAttribute ("Channel", "The channel attached to this device",
50
    .AddAttribute ("Channel", "The channel attached to this device",
46
                   PointerValue (),
51
                   PointerValue (),
47
                   MakePointerAccessor (&WifiNetDevice::DoGetChannel),
52
                   MakePointerAccessor (&WifiNetDevice::DoGetChannel),
 Lines 66-73    Link Here 
66
}
71
}
67
72
68
WifiNetDevice::WifiNetDevice ()
73
WifiNetDevice::WifiNetDevice ()
69
  : m_mtu (0),
74
  : m_configComplete (false)
70
    m_configComplete (false)
71
{
75
{
72
  NS_LOG_FUNCTION_NOARGS ();
76
  NS_LOG_FUNCTION_NOARGS ();
73
}
77
}
 Lines 187-195    Link Here 
187
bool 
191
bool 
188
WifiNetDevice::SetMtu (const uint16_t mtu)
192
WifiNetDevice::SetMtu (const uint16_t mtu)
189
{
193
{
190
  UintegerValue maxMsduSize;
194
  if (mtu > MAX_MSDU_SIZE)
191
  m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
192
  if (mtu > maxMsduSize.Get () || mtu == 0)
193
    {
195
    {
194
      return false;
196
      return false;
195
    }
197
    }
 Lines 199-210    Link Here 
199
uint16_t 
201
uint16_t 
200
WifiNetDevice::GetMtu (void) const
202
WifiNetDevice::GetMtu (void) const
201
{
203
{
202
  if (m_mtu == 0)
203
    {
204
      UintegerValue maxMsduSize;
205
      m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
206
      m_mtu = maxMsduSize.Get ();
207
    }
208
  return m_mtu;
204
  return m_mtu;
209
}
205
}
210
bool 
206
bool 
(-)a/src/devices/wifi/wifi-net-device.h (+4 lines)
 Lines 103-108    Link Here 
103
  virtual bool SupportsSendFrom (void) const;
103
  virtual bool SupportsSendFrom (void) const;
104
104
105
private:
105
private:
106
107
  // This value conforms to the 802.11 specification
108
  static const uint16_t MAX_MSDU_SIZE = 2304;
109
106
  virtual void DoDispose (void);
110
  virtual void DoDispose (void);
107
  virtual void DoStart (void);
111
  virtual void DoStart (void);
108
  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
112
  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
(-)a/src/devices/wimax/wimax-net-device.cc (-18 / +8 lines)
 Lines 57-62    Link Here 
57
57
58
    .SetParent<NetDevice> ()
58
    .SetParent<NetDevice> ()
59
59
60
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
61
                   UintegerValue (MAX_MSDU_SIZE),
62
                   MakeUintegerAccessor (&WimaxNetDevice::SetMtu,
63
                                         &WimaxNetDevice::GetMtu),
64
                   MakeUintegerChecker<uint16_t> (0,MAX_MSDU_SIZE))
65
60
    .AddAttribute ("Phy",
66
    .AddAttribute ("Phy",
61
                   "The PHY layer attached to this device.",
67
                   "The PHY layer attached to this device.",
62
                   PointerValue (),
68
                   PointerValue (),
 Lines 81-92    Link Here 
81
                   MakeUintegerAccessor (&WimaxNetDevice::GetTtg, &WimaxNetDevice::SetTtg),
87
                   MakeUintegerAccessor (&WimaxNetDevice::GetTtg, &WimaxNetDevice::SetTtg),
82
                   MakeUintegerChecker<uint16_t> (0, 120))
88
                   MakeUintegerChecker<uint16_t> (0, 120))
83
89
84
    .AddAttribute ("MaxMsduSize",
85
                   "The maximum size of an MSDU accepted by the MAC layer.",
86
                   UintegerValue (1500),
87
                   MakeUintegerAccessor (&WimaxNetDevice::m_maxMsduSize),
88
                   MakeUintegerChecker<uint16_t> (1, 1500))
89
90
    .AddAttribute ("ConnectionManager",
90
    .AddAttribute ("ConnectionManager",
91
                   "The connection manager attached to this device.",
91
                   "The connection manager attached to this device.",
92
                   PointerValue (),
92
                   PointerValue (),
 Lines 127-134    Link Here 
127
}
127
}
128
128
129
WimaxNetDevice::WimaxNetDevice (void)
129
WimaxNetDevice::WimaxNetDevice (void)
130
  : m_mtu (0),
130
  : m_state (0),
131
    m_state (0),
132
    m_symbolIndex (0),
131
    m_symbolIndex (0),
133
    m_ttg (0),
132
    m_ttg (0),
134
    m_rtg (0)
133
    m_rtg (0)
 Lines 164-174    Link Here 
164
  NetDevice::DoDispose ();
163
  NetDevice::DoDispose ();
165
}
164
}
166
165
167
uint32_t
168
WimaxNetDevice::GetMaxMsduSize (void) const
169
{
170
  return m_maxMsduSize;
171
}
172
166
173
void
167
void
174
WimaxNetDevice::SetTtg (uint16_t ttg)
168
WimaxNetDevice::SetTtg (uint16_t ttg)
 Lines 233-239    Link Here 
233
bool
227
bool
234
WimaxNetDevice::SetMtu (const uint16_t mtu)
228
WimaxNetDevice::SetMtu (const uint16_t mtu)
235
{
229
{
236
  if (mtu > m_maxMsduSize || mtu == 0)
230
  if (mtu > MAX_MSDU_SIZE)
237
    {
231
    {
238
      return false;
232
      return false;
239
    }
233
    }
 Lines 244-253    Link Here 
244
uint16_t
238
uint16_t
245
WimaxNetDevice::GetMtu (void) const
239
WimaxNetDevice::GetMtu (void) const
246
{
240
{
247
  if (m_mtu == 0)
248
    {
249
      m_mtu = m_maxMsduSize;
250
    }
251
  return m_mtu;
241
  return m_mtu;
252
}
242
}
253
243
(-)a/src/devices/wimax/wimax-net-device.h (-2 / +2 lines)
 Lines 68-74    Link Here 
68
  static TypeId GetTypeId (void);
68
  static TypeId GetTypeId (void);
69
  WimaxNetDevice (void);
69
  WimaxNetDevice (void);
70
  virtual ~WimaxNetDevice (void);
70
  virtual ~WimaxNetDevice (void);
71
  uint32_t GetMaxMsduSize (void) const;
72
  /**
71
  /**
73
   * \param ttg transmit/receive transition gap
72
   * \param ttg transmit/receive transition gap
74
   */
73
   */
 Lines 221-226    Link Here 
221
  WimaxNetDevice (const WimaxNetDevice &);
220
  WimaxNetDevice (const WimaxNetDevice &);
222
  WimaxNetDevice & operator= (const WimaxNetDevice &);
221
  WimaxNetDevice & operator= (const WimaxNetDevice &);
223
222
223
  static const uint16_t MAX_MSDU_SIZE = 1500;
224
224
  virtual bool DoSend (Ptr<Packet> packet,
225
  virtual bool DoSend (Ptr<Packet> packet,
225
                       const Mac48Address& source,
226
                       const Mac48Address& source,
226
                       const Mac48Address& dest,
227
                       const Mac48Address& dest,
 Lines 239-245    Link Here 
239
  std::string m_name;
240
  std::string m_name;
240
  bool m_linkUp;
241
  bool m_linkUp;
241
  Callback<void> m_linkChange;
242
  Callback<void> m_linkChange;
242
  uint32_t m_maxMsduSize;
243
  mutable uint16_t m_mtu;
243
  mutable uint16_t m_mtu;
244
244
245
  // temp, shall be in BS. defined here to allow SS to access. SS shall actually determine it from DLFP, shall be moved to BS after DLFP is implemented
245
  // temp, shall be in BS. defined here to allow SS to access. SS shall actually determine it from DLFP, shall be moved to BS after DLFP is implemented
(-)a/src/node/net-device.cc (-7 lines)
 Lines 33-45    Link Here 
33
{
33
{
34
  static TypeId tid = TypeId ("ns3::NetDevice")
34
  static TypeId tid = TypeId ("ns3::NetDevice")
35
    .SetParent<Object> ()
35
    .SetParent<Object> ()
36
    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
37
                   TypeId::ATTR_SET | TypeId::ATTR_GET,
38
                   UintegerValue (0xffff),
39
                   MakeUintegerAccessor (&NetDevice::SetMtu,
40
                                         &NetDevice::GetMtu),
41
                   MakeUintegerChecker<uint16_t> ())
42
                   
43
    ;
36
    ;
44
  return tid;
37
  return tid;
45
}
38
}

Return to bug 822