--- a/src/applications/udp-client-server/udp-client-server-test.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/applications/udp-client-server/udp-client-server-test.cc Sat Apr 10 13:45:09 2010 -0700
@@ -161,7 +161,7 @@
apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));
- uint32_t MaxPacketSize = 1400;
+ uint32_t MaxPacketSize = 1400-28; // ip/udp header
UdpTraceClientHelper client (i.GetAddress (1), port,"");
client.SetAttribute ("MaxPacketSize", UintegerValue (MaxPacketSize));
apps = client.Install (n.Get (0));
--- a/src/devices/bridge/bridge-net-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/bridge/bridge-net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -22,6 +22,7 @@
#include "ns3/log.h"
#include "ns3/boolean.h"
#include "ns3/simulator.h"
+#include "ns3/uinteger.h"
NS_LOG_COMPONENT_DEFINE ("BridgeNetDevice");
@@ -36,6 +37,11 @@
static TypeId tid = TypeId ("ns3::BridgeNetDevice")
.SetParent<NetDevice> ()
.AddConstructor<BridgeNetDevice> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (1500),
+ MakeUintegerAccessor (&BridgeNetDevice::SetMtu,
+ &BridgeNetDevice::GetMtu),
+ MakeUintegerChecker<uint16_t> ())
.AddAttribute ("EnableLearning",
"Enable the learning mode of the Learning Bridge",
BooleanValue (true),
@@ -53,8 +59,7 @@
BridgeNetDevice::BridgeNetDevice ()
: m_node (0),
- m_ifIndex (0),
- m_mtu (0xffff)
+ m_ifIndex (0)
{
NS_LOG_FUNCTION_NOARGS ();
m_channel = CreateObject<BridgeChannel> ();
--- a/src/devices/csma/csma-net-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/csma/csma-net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -50,11 +50,10 @@
Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
MakeMac48AddressAccessor (&CsmaNetDevice::m_address),
MakeMac48AddressChecker ())
- .AddAttribute ("FrameSize",
- "The maximum size of a packet sent over this device.",
- UintegerValue (DEFAULT_FRAME_SIZE),
- MakeUintegerAccessor (&CsmaNetDevice::SetFrameSize,
- &CsmaNetDevice::GetFrameSize),
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (DEFAULT_MTU),
+ MakeUintegerAccessor (&CsmaNetDevice::SetMtu,
+ &CsmaNetDevice::GetMtu),
MakeUintegerChecker<uint16_t> ())
.AddAttribute ("EncapsulationMode",
"The link-layer encapsulation type to use.",
@@ -173,8 +172,6 @@
// to change it here.
//
m_encapMode = DIX;
- m_frameSize = DEFAULT_FRAME_SIZE;
- m_mtu = MtuFromFrameSize (m_frameSize);
}
CsmaNetDevice::~CsmaNetDevice()
@@ -192,76 +189,14 @@
NetDevice::DoDispose ();
}
- uint32_t
-CsmaNetDevice::MtuFromFrameSize (uint32_t frameSize)
-{
- NS_LOG_FUNCTION (frameSize);
-
- NS_ASSERT_MSG (frameSize <= std::numeric_limits<uint16_t>::max (),
- "CsmaNetDevice::MtuFromFrameSize(): Frame size should be derived from 16-bit quantity: " << frameSize);
-
- uint32_t newSize;
-
- switch (m_encapMode)
- {
- case DIX:
- newSize = frameSize - ETHERNET_OVERHEAD;
- break;
- case LLC:
- {
- LlcSnapHeader llc;
-
- NS_ASSERT_MSG ((uint32_t)(frameSize - ETHERNET_OVERHEAD) >= llc.GetSerializedSize (),
- "CsmaNetDevice::MtuFromFrameSize(): Given frame size too small to support LLC mode");
- newSize = frameSize - ETHERNET_OVERHEAD - llc.GetSerializedSize ();
- }
- break;
- case ILLEGAL:
- default:
- NS_FATAL_ERROR ("CsmaNetDevice::MtuFromFrameSize(): Unknown packet encapsulation mode");
- return 0;
- }
-
- return newSize;
-}
-
- uint32_t
-CsmaNetDevice::FrameSizeFromMtu (uint32_t mtu)
-{
- NS_LOG_FUNCTION (mtu);
-
- uint32_t newSize;
-
- switch (m_encapMode)
- {
- case DIX:
- newSize = mtu + ETHERNET_OVERHEAD;
- break;
- case LLC:
- {
- LlcSnapHeader llc;
- newSize = mtu + ETHERNET_OVERHEAD + llc.GetSerializedSize ();
- }
- break;
- case ILLEGAL:
- default:
- NS_FATAL_ERROR ("CsmaNetDevice::FrameSizeFromMtu(): Unknown packet encapsulation mode");
- return 0;
- }
-
- return newSize;
-}
-
void
CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode)
{
NS_LOG_FUNCTION (mode);
m_encapMode = mode;
- m_mtu = MtuFromFrameSize (m_frameSize);
NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
- NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
NS_LOG_LOGIC ("m_mtu = " << m_mtu);
}
@@ -272,24 +207,13 @@
return m_encapMode;
}
- bool
+bool
CsmaNetDevice::SetMtu (uint16_t mtu)
{
- NS_LOG_FUNCTION (mtu);
-
- uint32_t newFrameSize = FrameSizeFromMtu (mtu);
-
- if (newFrameSize > std::numeric_limits<uint16_t>::max ())
- {
- NS_LOG_WARN ("CsmaNetDevice::SetMtu(): Frame size overflow, MTU not set.");
- return false;
- }
-
- m_frameSize = newFrameSize;
+ NS_LOG_FUNCTION (this << mtu);
m_mtu = mtu;
NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
- NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
NS_LOG_LOGIC ("m_mtu = " << m_mtu);
return true;
@@ -302,24 +226,6 @@
return m_mtu;
}
- void
-CsmaNetDevice::SetFrameSize (uint16_t frameSize)
-{
- NS_LOG_FUNCTION (frameSize);
-
- m_frameSize = frameSize;
- m_mtu = MtuFromFrameSize (frameSize);
-
- NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
- NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
- NS_LOG_LOGIC ("m_mtu = " << m_mtu);
-}
-
- uint16_t
-CsmaNetDevice::GetFrameSize (void) const
-{
- return m_frameSize;
-}
void
CsmaNetDevice::SetSendEnable (bool sendEnable)
@@ -381,7 +287,6 @@
NS_LOG_LOGIC ("p->GetSize () = " << p->GetSize ());
NS_LOG_LOGIC ("m_encapMode = " << m_encapMode);
NS_LOG_LOGIC ("m_mtu = " << m_mtu);
- NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
uint16_t lengthType = 0;
switch (m_encapMode)
@@ -435,7 +340,7 @@
// but with an LLC/SNAP header added to the payload as in IEEE 802.2
//
lengthType = p->GetSize ();
- NS_ASSERT_MSG (lengthType <= m_frameSize - 18,
+ NS_ASSERT_MSG (lengthType <= GetMtu (),
"CsmaNetDevice::AddHeader(): 802.3 Length/Type field with LLC/SNAP: "
"length interpretation must not exceed device frame size minus overhead");
}
--- a/src/devices/csma/csma-net-device.h Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/csma/csma-net-device.h Sat Apr 10 13:45:09 2010 -0700
@@ -185,108 +185,10 @@
void SetReceiveEnable (bool enable);
/**
- * Set The max frame size of packets sent over this device.
- *
- * 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
- * level protocols see. We have a PHY-level MTU which is the maximum number of bytes we can send over the link
- * (cf. 1500 bytes for Ethernet). We also have a frame size which is some total number of bytes in a packet which could
- * or could not include any framing and overhead. There can be a lot of inconsistency in definitions of these terms. For
- * example, RFC 1042 asserts that the terms maximum transmission unit and maximum packet size are equivalent. RFC 791,
- * however, defines MTU as the maximum sized IP datagram that can be sent. Packet size and frame size are sometimes
- * used interchangeably.
- *
- * So, some careful definitions are in order to avoid confusion:
- *
- * In real Ethernet, a packet on the wire starts with a preamble of seven bytes of alternating ones and zeroes followed by
- * a Start-of-Frame-Delimeter (10101011). This is followed by what is usually called the packet: a MAC destination and
- * source, a type field, payload, a possible padding field and a CRC. To be strictly and pedantically correct the frame
- * size is necessarily larger than the packet size on a real Ethernet. But, this isn't a real Ethernet, it's a simulation
- * of a device similar to Ethernet, and we have no good reason to add framing bits. So, in the case of the CSMA device,
- * the frame size is equal to the packet size. Since these two values are equal, there is no danger in assuming they are
- * identical. We do not implement any padding out to a minimum frame size, so padding is a non-issue. We define packet
- * size to be equal to frame size and this excludes the preamble and SFD bytes of a real Ethernet frame. We define a
- * single (MAC-level) MTU that coresponds to the payload size of the packet, which is the IP-centric view of the term as
- * seen in RFC 791.
- *
- * To make this concrete, consider DIX II (Digital Equipment, Intel, Xerox type II) framing, which is used in most TCP/IP
- * stacks. NetWare and Wireshark call this framing Ethernet II, by the way. In this framing scheme, a real packet on the
- * wire starts with the preamble and Start-of-Frame-Delimeter (10101011). We ignore these bits on this device since it they
- * are not needed. In DIX II, the SFD is followed by the MAC (48) destination address (6 bytes), source address (6 bytes),
- * the EtherType field (2 bytes), payload (0-1500 bytes) and a CRC (4 bytes) -- this corresponds to our entire frame. The
- * 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
- * the MTU. Typically, one sees the MTU set to 1500 bytes and the maximum frame size set to 1518 bytes in Ethernet-based
- * networks.
- *
- * Different framing schemes can make for different MTU and frame size relationships. For example, we support LLC/SNAP
- * encapsulation which adds eight bytes of header overhead to the usual DIX framing. In this case, if the maximum frame
- * size is left at 1518 bytes, we need to export an MTU that reflects the loss of eight bytes for a total of 1492.
- *
- * Another complication is that IEEE 802.1Q adds four bytes to the maximum frame size for VLAN tagging. In order to
- * provide an MTU of 1500 bytes, the frame size would need to increased to 1522 bytes to absorb the additional overhead.
- *
- * So, there are really three variables that are not entirely free at work here. There is the maximum frame size, the
- * MTU and the framing scheme which we call the encapsulation mode.
- *
- * So, what do we do since there are be three values which must always be consistent in the driver? Which values to we
- * allow to be changed and how do we ensure the other two are consistent? We want to actually allow a user to change
- * these three variables in flexible ways, but we want the results (even at intermediate stages of her ultimate change) to
- * be consistent. We certainly don't want to require that users must understand the various requirements of an enapsulation
- * mode in order to set these variables.
- *
- * Consider the following situation: A user wants to set the maximum frame size to 1418 bytes instead of 1518. This
- * user shouldn't have to concern herself that the current encapuslation mode is LLC/SNAP and this will consume eight bytes.
- * 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
- * do this in some special order to keep intermediate steps consistent.
- *
- * Similarly, a user who is interested in setting the MTU to 1400 bytes should not be forced to understand that
- * (based on encapsulation mode) the frame size may need to be set to eighteen + eight bytes more than what he wants
- * in certain cases (802,3 + LLC/SNAP), twenty-two + zero bytes in others (802.1Q) and other inscrutable combinations
- *
- * Now, consider a user who is only interested in changing the encapsulation mode from LLC/SNAP to DIX. This
- * is going to change the relationship between the MTU and the frame size. We've may have to come up with a new value
- * for at least one of the these? Which one? There are too many free variables.
- *
- * We could play games trying to figure out what the user wants to do, but that is typically a bad plan and programmers
- * have a long and distinguished history of guessing wrong. We'll avoid all of that and just define a flexible behavior
- * that can be worked to get what you want. Here it is:
- *
- * - If the user is changing the encapsulation mode, the PHY MTU will remain fixed and the MAC MTU will change, if required,
- * to make the three values consistent;
- *
- * - If the user is changing the MTU, she is interested in getting that part of the system set, so the frame size
- * will be changed to make the three values consistent;
- *
- * - If the user is changing the frame size, he is interested in getting that part of the system set, so the MTU
- * will be changed to make the three values consistent;
- *
- * - You cannot define the MTU and frame size separately -- they are always tied together by the emulation mode. This
- * is not a restriction. Consider what this means. Perhaps you want to set the frame size to some 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 is not possible to
- * send a frame larger than the MTU plus overhead. The larger frame size is not useful.
- *
- * So, if a user calls SetFrameSize, we assume that the maximum frame size is the interesting thing for that user and
- * we just adjust the MTU to a new "correct value" based on the current encapsulation mode. If a user calls SetMtu, we
- * assume that the MTU is the interesting property for that user, and we adjust the frame size to a new "correct value"
- * for the current encapsulation mode. If a user calls SetEncapsulationMode, then we take the MTU as the free variable
- * and set its value to match the current frame size.
- *
- * \param frameSize The max frame size of packets sent over this device.
- */
- void SetFrameSize (uint16_t frameSize);
-
- /**
- * Get The max frame size of packets sent over this device.
- *
- * \returns The max frame size of packets sent over this device.
- */
- uint16_t GetFrameSize (void) const;
-
- /**
* Set the encapsulation mode of this device.
*
* \param mode The encapsulation mode of this device.
*
- * \see SetFrameSize
*/
void SetEncapsulationMode (CsmaNetDevice::EncapsulationMode mode);
@@ -456,20 +358,6 @@
void Init (bool sendEnable, bool receiveEnable);
/**
- * Calculate the value for the MTU that would result from
- * setting the frame size to the given value.
- * \param frameSize size of frame
- */
- uint32_t MtuFromFrameSize (uint32_t frameSize);
-
- /**
- * Calculate the value for the frame size that would be required
- * to be able to set the MTU to the given value.
- * \param mtu MTU
- */
- uint32_t FrameSizeFromMtu (uint32_t mtu);
-
- /**
* Start Sending a Packet Down the Wire.
*
* The TransmitStart method is the method that is used internally in
@@ -804,15 +692,7 @@
*/
TracedCallback<> m_linkChangeCallbacks;
- static const uint16_t DEFAULT_FRAME_SIZE = 1518;
- static const uint16_t ETHERNET_OVERHEAD = 18;
-
- /**
- * The frame size/packet size. This corresponds to the maximum
- * number of bytes that can be transmitted as a packet without framing.
- * This corresponds to the 1518 byte packet size often seen on Ethernet.
- */
- uint32_t m_frameSize;
+ static const uint16_t DEFAULT_MTU = 1500;
/**
* The Maxmimum Transmission Unit. This corresponds to the maximum
--- a/src/devices/emu/emu-net-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/emu/emu-net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -63,6 +63,10 @@
static TypeId tid = TypeId ("ns3::EmuNetDevice")
.SetParent<NetDevice> ()
.AddConstructor<EmuNetDevice> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (0), // arbitrary un-used value because no setter
+ MakeUintegerAccessor (&EmuNetDevice::GetMtu),
+ MakeUintegerChecker<uint16_t> ())
.AddAttribute ("Address",
"The ns-3 MAC address of this (virtual) device.",
Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
--- a/src/devices/mesh/mesh-point-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/mesh/mesh-point-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -39,6 +39,11 @@
static TypeId tid = TypeId ("ns3::MeshPointDevice")
.SetParent<NetDevice> ()
.AddConstructor<MeshPointDevice> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (0xffff),
+ MakeUintegerAccessor (&MeshPointDevice::SetMtu,
+ &MeshPointDevice::GetMtu),
+ MakeUintegerChecker<uint16_t> ())
.AddAttribute ( "RoutingProtocol",
"The mesh routing protocol used by this mesh point.",
PointerValue (),
@@ -50,7 +55,7 @@
}
MeshPointDevice::MeshPointDevice () :
- m_ifIndex (0), m_mtu (1500)
+ m_ifIndex (0)
{
NS_LOG_FUNCTION_NOARGS ();
m_channel = CreateObject<BridgeChannel> ();
--- a/src/devices/point-to-point/point-to-point-net-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/point-to-point/point-to-point-net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -41,17 +41,16 @@
static TypeId tid = TypeId ("ns3::PointToPointNetDevice")
.SetParent<NetDevice> ()
.AddConstructor<PointToPointNetDevice> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (DEFAULT_MTU),
+ MakeUintegerAccessor (&PointToPointNetDevice::SetMtu,
+ &PointToPointNetDevice::GetMtu),
+ MakeUintegerChecker<uint16_t> ())
.AddAttribute ("Address",
"The MAC address of this device.",
Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
MakeMac48AddressAccessor (&PointToPointNetDevice::m_address),
MakeMac48AddressChecker ())
- .AddAttribute ("FrameSize",
- "The maximum size of a packet sent over this device.",
- UintegerValue (DEFAULT_FRAME_SIZE),
- MakeUintegerAccessor (&PointToPointNetDevice::SetFrameSize,
- &PointToPointNetDevice::GetFrameSize),
- MakeUintegerChecker<uint16_t> ())
.AddAttribute ("DataRate",
"The default data rate for point to point links",
DataRateValue (DataRate ("32768b/s")),
@@ -152,16 +151,6 @@
m_currentPkt (0)
{
NS_LOG_FUNCTION (this);
-
- //
- // A quick sanity check to ensure consistent constants.
- //
- PppHeader ppp;
- NS_ASSERT_MSG (PPP_OVERHEAD == ppp.GetSerializedSize (),
- "PointToPointNetDevice::PointToPointNetDevice(): PPP_OVERHEAD inconsistent");
-
- m_frameSize = DEFAULT_FRAME_SIZE;
- m_mtu = MtuFromFrameSize (m_frameSize);
}
PointToPointNetDevice::~PointToPointNetDevice ()
@@ -594,65 +583,11 @@
return Address ();
}
- uint32_t
-PointToPointNetDevice::MtuFromFrameSize (uint32_t frameSize)
-{
- NS_LOG_FUNCTION (frameSize);
- NS_ASSERT_MSG (frameSize <= std::numeric_limits<uint16_t>::max (),
- "PointToPointNetDevice::MtuFromFrameSize(): Frame size should be derived from 16-bit quantity: " <<
- frameSize);
- PppHeader ppp;
- NS_ASSERT_MSG ((uint32_t)frameSize >= ppp.GetSerializedSize (),
- "PointToPointNetDevice::MtuFromFrameSize(): Given frame size too small to support PPP");
- return frameSize - ppp.GetSerializedSize ();
-}
-
- uint32_t
-PointToPointNetDevice::FrameSizeFromMtu (uint32_t mtu)
-{
- NS_LOG_FUNCTION (mtu);
-
- PppHeader ppp;
- return mtu + ppp.GetSerializedSize ();
-}
-
- void
-PointToPointNetDevice::SetFrameSize (uint16_t frameSize)
-{
- NS_LOG_FUNCTION (frameSize);
-
- m_frameSize = frameSize;
- m_mtu = MtuFromFrameSize (frameSize);
-
- NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
- NS_LOG_LOGIC ("m_mtu = " << m_mtu);
-}
-
- uint16_t
-PointToPointNetDevice::GetFrameSize (void) const
-{
- return m_frameSize;
-}
-
bool
PointToPointNetDevice::SetMtu (uint16_t mtu)
{
- NS_LOG_FUNCTION (mtu);
-
- uint32_t newFrameSize = FrameSizeFromMtu (mtu);
-
- if (newFrameSize > std::numeric_limits<uint16_t>::max ())
- {
- NS_LOG_WARN ("PointToPointNetDevice::SetMtu(): Frame size overflow, MTU not set.");
- return false;
- }
-
- m_frameSize = newFrameSize;
+ NS_LOG_FUNCTION (this << mtu);
m_mtu = mtu;
-
- NS_LOG_LOGIC ("m_frameSize = " << m_frameSize);
- NS_LOG_LOGIC ("m_mtu = " << m_mtu);
-
return true;
}
--- a/src/devices/point-to-point/point-to-point-net-device.h Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/point-to-point/point-to-point-net-device.h Sat Apr 10 13:45:09 2010 -0700
@@ -138,109 +138,6 @@
*/
void Receive (Ptr<Packet> p);
- /**
- * \brief Set the max frame size of L2 frames sent over this device.
- *
- * We use the following terminology. MTU is the maximum sized payload
- * of the point-to-point frame. For example, if the MTU is 1500 bytes,
- * then any IP datagram sent to the device must be smaller for equal to
- * the MTU. The MTU is an attribute of base class NetDevice.
- *
- * The maximum frame size is the maximum size of the L2 frame that can
- * be sent on the channel. Typically this is a bit larger than the MTU
- * to account for framing and header overhead. Note that the maximum
- * frame size constrains the MTU unless the L2 performs segmentation
- * and reassembly.
- *
- * In real serial channel (HDLC, for example), the wire idles (sends
- * all ones) until the channel begins sending a packet.
- * A frame on the wire starts with a flag character (01111110). This is
- * followed by what is usually called the packet: * address, control,
- * payload, and a Frame Check Sequence (FCS). This is followed by
- * another flag character. If the flag characters are used, then bit
- * stuffing must be used to prevent flag characters from appearing in
- * the packet and confusing the receiver. But, this isn't a real link,
- * it's a simulation of a device similar to a point-to-point device, and
- * we have no good reason to add framing bits and therefore to do
- * bit-stuffing. So, in the case of the point-to-point device, the frame
- * size is equal to the packet size. Since these two values are defined
- * to be equal, there is no danger in assuming they are identical.
- * We define packet size to be equal to frame size and this excludes
- * the flag characters. We define a single (MAC-level) MTU that
- * corresponds to the payload size of the packet, which is the
- * IP-centric view of the term as seen in RFC 791.
- *
- * To make this concrete, consider an example PPP framing on a
- * synchronous link. In this framing scheme, a real serial frame on the
- * wire starts with a flag character, address and control characters,
- * then a 16-bit PPP protocol ID (0x21 = IP). Then we would see the
- * actual payload we are supposed to send, presumably an IP datagram.
- * At then we see the FCS and finally another flag character to end
- * the frame. We ignore the flag bits on this device since it they are
- * not needed. We aren't really using HDLC to send frames across the
- * link, so we don't need the address and control bits either. In fact,
- * to encapsulate using unframed PPP all we need to do is prepend the
- * two-byte protocol ID.
- *
- * Typically the limiting factor in frame size is due to hardware
- * limitations in the underlying HDLC controller receive FIFO buffer size.
- * This number can vary widely. For example, the Motorola MC92460 has
- * a 64 KByte maximum frame size; the Intel IXP4XX series has a 16
- * KByte size. Older USARTs have a maximum frame size around 2KBytes,
- * and typical PPP links on the Internet have their MTU set to 1500
- * bytes since this is what will typically be used on Ethernet segments
- * and will avoid path MTU issues. We choose to make the default MTU
- * 1500 bytes which then fixes the maximum frame size
- * as described below.
- *
- * So, there are really two related variables at work here. There
- * is the maximum frame size that can be sent over the
- * link and there is the MTU.
- *
- * So, what do we do since these values must always be consistent in the
- * driver? We want to actually allow a user to change these variables,
- * but we want the results (even at intermediate stages of her ultimate
- * change) to be consistent. We certainly don't want to require that
- * users must understand the details of PPP encapsulation in order to
- * set these variables. We therefore link these variables as follows:
- *
- * - If the user is changing the MTU, he or she is interested in
- * getting that part of the system set, so the frame size
- * will be changed to make it consistent;
- *
- * - If the user is changing the frame size, he or she is interested
- * in getting that part of the system set, so the MTU will be changed
- * to make it consistent;
- *
- * - You cannot define the MTU and frame size separately -- they are
- * always tied together by the overhead of the PPP encapsulation.
- * This is not a restriction. Consider what this means. Perhaps you
- * want to set the frame size to some 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 is not possible to send a frame
- * larger than the MTU plus overhead. Having the ability to set a
- * larger frame size is not useful.
- *
- * So, if a user calls SetFrameSize, we assume that the maximum frame
- * size is the interesting thing for that user and we just adjust
- * the MTU to a new "correct value" based on the current encapsulation
- * mode. If a user calls SetMtu, we assume that the MTU is the
- * interesting property for that user, and we adjust the frame size to
- * a new "correct value" for the current encapsulation mode. If a
- * user calls SetEncapsulationMode, then we take the MTU as the free
- * variable and set its value to match the current frame size.
- *
- * \param frameSize The max frame size of packets sent over this device.
- */
- void SetFrameSize (uint16_t frameSize);
-
- /**
- * Get the max frame size of packets sent over this device.
- *
- * \returns The max frame size of packets sent over this device.
- */
- uint16_t GetFrameSize (void) const;
-
// The remaining methods are documented in ns3::NetDevice*
virtual void SetIfIndex(const uint32_t index);
@@ -287,19 +184,6 @@
virtual void DoDispose (void);
private:
- /**
- * Calculate the value for the MTU that would result from
- * setting the frame size to the given value.
- * \param frameSize size of frame
- */
- uint32_t MtuFromFrameSize (uint32_t frameSize);
-
- /**
- * Calculate the value for the frame size that would be required
- * to be able to set the MTU to the given value.
- * \param mtu MTU
- */
- uint32_t FrameSizeFromMtu (uint32_t mtu);
/**
* \returns the address of the remote device connected to this device
@@ -544,15 +428,6 @@
TracedCallback<> m_linkChangeCallbacks;
static const uint16_t DEFAULT_MTU = 1500;
- static const uint16_t PPP_OVERHEAD = 2;
- static const uint16_t DEFAULT_FRAME_SIZE = DEFAULT_MTU + PPP_OVERHEAD;
-
- /**
- * The frame size/packet size. This corresponds to the maximum
- * number of bytes that can be transmitted as a packet without framing.
- * This corresponds to the 1518 byte packet size often seen on Ethernet.
- */
- uint32_t m_frameSize;
/**
* The Maxmimum Transmission Unit. This corresponds to the maximum
--- a/src/devices/tap-bridge/tap-bridge.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/tap-bridge/tap-bridge.cc Sat Apr 10 13:45:09 2010 -0700
@@ -33,6 +33,7 @@
#include "ns3/simulator.h"
#include "ns3/realtime-simulator-impl.h"
#include "ns3/system-thread.h"
+#include "ns3/uinteger.h"
#include <sys/wait.h>
#include <sys/stat.h>
@@ -74,6 +75,11 @@
static TypeId tid = TypeId ("ns3::TapBridge")
.SetParent<NetDevice> ()
.AddConstructor<TapBridge> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (0),
+ MakeUintegerAccessor (&TapBridge::SetMtu,
+ &TapBridge::GetMtu),
+ MakeUintegerChecker<uint16_t> ())
.AddAttribute ("DeviceName",
"The name of the tap device to create.",
StringValue (""),
@@ -126,7 +132,6 @@
TapBridge::TapBridge ()
: m_node (0),
m_ifIndex (0),
- m_mtu (0),
m_sock (-1),
m_startEvent (),
m_stopEvent (),
--- a/src/devices/virtual-net-device/virtual-net-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/virtual-net-device/virtual-net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -27,6 +27,7 @@
#include "virtual-net-device.h"
#include "ns3/channel.h"
#include "ns3/trace-source-accessor.h"
+#include "ns3/uinteger.h"
NS_LOG_COMPONENT_DEFINE ("VirtualNetDevice");
@@ -41,6 +42,11 @@
static TypeId tid = TypeId ("ns3::VirtualNetDevice")
.SetParent<NetDevice> ()
.AddConstructor<VirtualNetDevice> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (1500),
+ MakeUintegerAccessor (&VirtualNetDevice::SetMtu,
+ &VirtualNetDevice::GetMtu),
+ MakeUintegerChecker<uint16_t> ())
.AddTraceSource ("MacTx",
"Trace source indicating a packet has arrived for transmission by this device",
MakeTraceSourceAccessor (&VirtualNetDevice::m_macTxTrace))
@@ -69,7 +75,6 @@
{
m_needsArp = false;
m_supportsSendFrom = true;
- m_mtu = 65535;
m_isPointToPoint = true;
}
--- a/src/devices/virtual-net-device/virtual-net-device.h Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/virtual-net-device/virtual-net-device.h Sat Apr 10 13:45:09 2010 -0700
@@ -91,8 +91,7 @@
void SetSupportsSendFrom (bool supportsSendFrom);
/**
- * \brief Configure the reported MTU for the virtual device. The
- * default value is 65535.
+ * \brief Configure the reported MTU for the virtual device.
* \param mtu MTU value to set
* \return whether the MTU value was within legal bounds
*/
--- a/src/devices/wifi/wifi-mac.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/wifi/wifi-mac.cc Sat Apr 10 13:45:09 2010 -0700
@@ -175,11 +175,6 @@
TimeValue (GetDefaultMaxPropagationDelay ()),
MakeTimeAccessor (&WifiMac::m_maxPropagationDelay),
MakeTimeChecker ())
- .AddAttribute ("MaxMsduSize", "The maximum size of an MSDU accepted by the MAC layer."
- "This value conforms to the specification.",
- UintegerValue (2304),
- MakeUintegerAccessor (&WifiMac::m_maxMsduSize),
- MakeUintegerChecker<uint16_t> (1,2304))
.AddAttribute ("Ssid", "The ssid we want to belong to.",
SsidValue (Ssid ("default")),
MakeSsidAccessor (&WifiMac::GetSsid,
@@ -232,12 +227,6 @@
return m_maxPropagationDelay;
}
-uint32_t
-WifiMac::GetMaxMsduSize (void) const
-{
- return m_maxMsduSize;
-}
-
void
WifiMac::NotifyTx (Ptr<const Packet> packet)
{
--- a/src/devices/wifi/wifi-mac.h Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/wifi/wifi-mac.h Sat Apr 10 13:45:09 2010 -0700
@@ -111,10 +111,6 @@
* Unused for now.
*/
Time GetMaxPropagationDelay (void) const;
- /**
- * \returns the maximum size of a MAC-level data payload.
- */
- uint32_t GetMaxMsduSize (void) const;
/**
* \returns the MAC address associated to this MAC layer.
@@ -246,7 +242,6 @@
virtual void FinishConfigureStandard (enum WifiPhyStandard standard) = 0;
Time m_maxPropagationDelay;
- uint32_t m_maxMsduSize;
void Configure80211a (void);
void Configure80211b (void);
--- a/src/devices/wifi/wifi-net-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/wifi/wifi-net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -42,6 +42,11 @@
static TypeId tid = TypeId ("ns3::WifiNetDevice")
.SetParent<NetDevice> ()
.AddConstructor<WifiNetDevice> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (MAX_MSDU_SIZE),
+ MakeUintegerAccessor (&WifiNetDevice::SetMtu,
+ &WifiNetDevice::GetMtu),
+ MakeUintegerChecker<uint16_t> (1,MAX_MSDU_SIZE))
.AddAttribute ("Channel", "The channel attached to this device",
PointerValue (),
MakePointerAccessor (&WifiNetDevice::DoGetChannel),
@@ -66,8 +71,7 @@
}
WifiNetDevice::WifiNetDevice ()
- : m_mtu (0),
- m_configComplete (false)
+ : m_configComplete (false)
{
NS_LOG_FUNCTION_NOARGS ();
}
@@ -187,9 +191,7 @@
bool
WifiNetDevice::SetMtu (const uint16_t mtu)
{
- UintegerValue maxMsduSize;
- m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
- if (mtu > maxMsduSize.Get () || mtu == 0)
+ if (mtu > MAX_MSDU_SIZE)
{
return false;
}
@@ -199,12 +201,6 @@
uint16_t
WifiNetDevice::GetMtu (void) const
{
- if (m_mtu == 0)
- {
- UintegerValue maxMsduSize;
- m_mac->GetAttribute ("MaxMsduSize", maxMsduSize);
- m_mtu = maxMsduSize.Get ();
- }
return m_mtu;
}
bool
--- a/src/devices/wifi/wifi-net-device.h Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/wifi/wifi-net-device.h Sat Apr 10 13:45:09 2010 -0700
@@ -103,6 +103,10 @@
virtual bool SupportsSendFrom (void) const;
private:
+
+ // This value conforms to the 802.11 specification
+ static const uint16_t MAX_MSDU_SIZE = 2304;
+
virtual void DoDispose (void);
virtual void DoStart (void);
void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
--- a/src/devices/wimax/wimax-net-device.cc Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/wimax/wimax-net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -57,6 +57,12 @@
.SetParent<NetDevice> ()
+ .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
+ UintegerValue (DEFAULT_MSDU_SIZE),
+ MakeUintegerAccessor (&WimaxNetDevice::SetMtu,
+ &WimaxNetDevice::GetMtu),
+ MakeUintegerChecker<uint16_t> (0,MAX_MSDU_SIZE))
+
.AddAttribute ("Phy",
"The PHY layer attached to this device.",
PointerValue (),
@@ -81,12 +87,6 @@
MakeUintegerAccessor (&WimaxNetDevice::GetTtg, &WimaxNetDevice::SetTtg),
MakeUintegerChecker<uint16_t> (0, 120))
- .AddAttribute ("MaxMsduSize",
- "The maximum size of an MSDU accepted by the MAC layer.",
- UintegerValue (1500),
- MakeUintegerAccessor (&WimaxNetDevice::m_maxMsduSize),
- MakeUintegerChecker<uint16_t> (1, 1500))
-
.AddAttribute ("ConnectionManager",
"The connection manager attached to this device.",
PointerValue (),
@@ -127,8 +127,7 @@
}
WimaxNetDevice::WimaxNetDevice (void)
- : m_mtu (0),
- m_state (0),
+ : m_state (0),
m_symbolIndex (0),
m_ttg (0),
m_rtg (0)
@@ -164,11 +163,6 @@
NetDevice::DoDispose ();
}
-uint32_t
-WimaxNetDevice::GetMaxMsduSize (void) const
-{
- return m_maxMsduSize;
-}
void
WimaxNetDevice::SetTtg (uint16_t ttg)
@@ -233,7 +227,7 @@
bool
WimaxNetDevice::SetMtu (const uint16_t mtu)
{
- if (mtu > m_maxMsduSize || mtu == 0)
+ if (mtu > MAX_MSDU_SIZE)
{
return false;
}
@@ -244,10 +238,6 @@
uint16_t
WimaxNetDevice::GetMtu (void) const
{
- if (m_mtu == 0)
- {
- m_mtu = m_maxMsduSize;
- }
return m_mtu;
}
--- a/src/devices/wimax/wimax-net-device.h Thu Apr 08 23:01:34 2010 +0900
+++ b/src/devices/wimax/wimax-net-device.h Sat Apr 10 13:45:09 2010 -0700
@@ -68,7 +68,6 @@
static TypeId GetTypeId (void);
WimaxNetDevice (void);
virtual ~WimaxNetDevice (void);
- uint32_t GetMaxMsduSize (void) const;
/**
* \param ttg transmit/receive transition gap
*/
@@ -221,6 +220,10 @@
WimaxNetDevice (const WimaxNetDevice &);
WimaxNetDevice & operator= (const WimaxNetDevice &);
+ static const uint16_t MAX_MSDU_SIZE = 1500;
+ // recommended by wimax forum.
+ static const uint16_t DEFAULT_MSDU_SIZE = 1400;
+
virtual bool DoSend (Ptr<Packet> packet,
const Mac48Address& source,
const Mac48Address& dest,
@@ -239,7 +242,6 @@
std::string m_name;
bool m_linkUp;
Callback<void> m_linkChange;
- uint32_t m_maxMsduSize;
mutable uint16_t m_mtu;
// 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 Thu Apr 08 23:01:34 2010 +0900
+++ b/src/node/net-device.cc Sat Apr 10 13:45:09 2010 -0700
@@ -33,13 +33,6 @@
{
static TypeId tid = TypeId ("ns3::NetDevice")
.SetParent<Object> ()
- .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
- TypeId::ATTR_SET | TypeId::ATTR_GET,
- UintegerValue (0xffff),
- MakeUintegerAccessor (&NetDevice::SetMtu,
- &NetDevice::GetMtu),
- MakeUintegerChecker<uint16_t> ())
-
;
return tid;
}