From 162194c37fe4abe46c154863f300a2d9e96108f1 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Tue, 5 Aug 2008 10:06:40 -0700 Subject: [PATCH 1/2] repeat the virtual keyword in the subclass --- src/simulator/default-simulator-impl.h | 36 ++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/simulator/default-simulator-impl.h b/src/simulator/default-simulator-impl.h index d61025fa6..b923d614d 100644 --- a/src/simulator/default-simulator-impl.h +++ b/src/simulator/default-simulator-impl.h @@ -43,25 +43,23 @@ public: DefaultSimulatorImpl (); ~DefaultSimulatorImpl (); - void Destroy (); - - bool IsFinished (void) const; - Time Next (void) const; - void Stop (void); - void Stop (Time const &time); - EventId Schedule (Time const &time, const Ptr &event); - EventId ScheduleNow (const Ptr &event); - EventId ScheduleDestroy (const Ptr &event); - void Remove (const EventId &ev); - void Cancel (const EventId &ev); - bool IsExpired (const EventId &ev) const; - void Run (void); - Time Now (void) const; - Time GetDelayLeft (const EventId &id) const; - Time GetMaximumSimulationTime (void) const; - - void SetScheduler (Ptr scheduler); - Ptr GetScheduler (void) const; + virtual void Destroy (); + virtual bool IsFinished (void) const; + virtual Time Next (void) const; + virtual void Stop (void); + virtual void Stop (Time const &time); + virtual EventId Schedule (Time const &time, const Ptr &event); + virtual EventId ScheduleNow (const Ptr &event); + virtual EventId ScheduleDestroy (const Ptr &event); + virtual void Remove (const EventId &ev); + virtual void Cancel (const EventId &ev); + virtual bool IsExpired (const EventId &ev) const; + virtual void Run (void); + virtual Time Now (void) const; + virtual Time GetDelayLeft (const EventId &id) const; + virtual Time GetMaximumSimulationTime (void) const; + virtual void SetScheduler (Ptr scheduler); + virtual Ptr GetScheduler (void) const; private: void ProcessOneEvent (void); From 2966ca33b9fb0e19c16a2695f3f21a40e2bc747c Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Tue, 5 Aug 2008 10:34:26 -0700 Subject: [PATCH 2/2] Comment to clarify MTU policy was insufficiently clear --- src/devices/csma/csma-net-device.h | 42 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/devices/csma/csma-net-device.h b/src/devices/csma/csma-net-device.h index 4e59d0ae3..cb6405b18 100644 --- a/src/devices/csma/csma-net-device.h +++ b/src/devices/csma/csma-net-device.h @@ -201,34 +201,36 @@ public: /** * Set The max PHY-level payload length of packets sent over this device. * - * Okay, that was easy to say, but the details are a bit thorny. We have a MAC-level that is the payload that higher + * 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). The value that determines the relationship between these two values is the link - * encapsulation mode. The link encapsulation defines the number of bytes of overhead that are required for the particular - * MAC protocol used. For example, if the LLC/SNAP encapsulation is used, eight bytes of LLC/SNAP header are consumed and - * therefore the MAC-level MTU must be set and reported as eight bytes less than the PHY-level MTU (which we call the - * payload length to try and avoid confusion). + * encapsulation mode. The link encapsulation method dictates the number of bytes of overhead that are required for the + * particular MAC protocol used. For example, if the LLC/SNAP encapsulation is used, eight bytes of LLC/SNAP header are + * consumed and therefore the MAC-level MTU must be set and reported as eight bytes less than the PHY-level MTU (which we + * call the payload length to try and avoid confusion). * - * So, what do we do since there must 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 enable a user to change - * these two payload lengths in flexible ways, but we want the results (even at intermediate stages) 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. + * 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 allowe 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 physical layer MTU to 1400 bytes instead of 1500. This * user shouldn't have to concern herself that the current encapuslation mode is LLC and this will consume eight bytes. * She should not have to also set the MAC MTU to 1392 bytes, and she should certainly not have to do this before setting - * the PHY MTU. + * the PHY MTU to make the eventual result consistent. * - * A user who is interested in setting the MAC-level MTU to 1400 bytes should not be forced to understand that in certain - * cases the PHY-level MTU must be set to eight bytes more than what he wants in certain cases and zero bytes in others. + * Similarly, a user who is interested in setting the MAC-level MTU to 1400 bytes should not be forced to understand that + * (based on encapsulation mode) the PHY-level MTU may need to be set to eight bytes more than what he wants in certain + * cases and zero bytes in others. * * Now, consider a user who is only interested in changing the encapsulation mode from LLC/SNAP to ETHERNET_V1. This * is going to change the relationship between the MAC MTU and the PHY MTU. We've may have to come up with a new value - * for at least one of the MTUs? Which one? + * for at least one of the MTUs? 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. So we're going - * to just define a flexible behavior. Here it is: + * 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; @@ -237,12 +239,14 @@ public: * will be changed to make the three values consistent; * * - If the user is changing the PHY MTU, he is interested in getting that part of the system set, so the MAC MTU - * will be changed to make the three values consistent. + * will be changed to make the three values consistent; + * + * - You cannot define the MAC MTU and PHY MTU separately -- they are always tied together by the emulation mode. * * So, if a user calls SetMaxPayloadLength, we assume that the PHY-level MTU is the interesting thing for that user and - * we just adjust the MAC-level MTU to "the correct value" based on the current encapsulation mode. If a user calls + * we just adjust the MAC-level MTU to a new "correct value" based on the current encapsulation mode. If a user calls * SetMacMtu, we assume that the MAC-level MTU is the interesting property for that user, and we adjust the PHY-level MTU - * to "the correct value" for the current encapsulation mode. If a user calls SetEncapsulationMode, then we take the + * to a new "correct value" for the current encapsulation mode. If a user calls SetEncapsulationMode, then we take the * MAC-level MTU as the free variable and set its value to match the current PHY-level MTU. * * \param mayPayloadLength The max PHY-level payload length of packets sent over this device.