38.3.3 Reception of a Packet

We create a new c++ class PLMLossMonitor (~ns/plm/loss-monitor-plm.cc) that inherits from LossMonitor. The OTcl class name of the c++ PLMLossMonitor class is Agent/LossMonitor/PLM.
class PLMLossMonitor : public LossMonitor {
public:
        PLMLossMonitor();
        virtual void recv(Packet* pkt, Handler*);
protected:
        // PLM only
        int flag_PP_;
        double packet_time_PP_;
        int fid_PP_;
};

static class PLMLossMonitorClass : public TclClass {
public:
        PLMLossMonitorClass() : TclClass("Agent/LossMonitor/PLM") {}
        TclObject* create(int, const char*const*) {
                return (new PLMLossMonitor());
        }
} class_loss_mon_plm;

We add in void PLMLossMonitor::recv(Packet* pkt, Handler*) a Tcl call to the Agent/LossMonitor/PLM instproc log-PP each time a packet is received :

  void LossMonitor::recv(Packet* pkt, Handler*)
  {
    ...
    if (expected_ \>= 0) {
      ...
      }
    Tcl::instance().evalf("%s log-PP", name());
    }

The Agent/LossMonitor/PLM instproc log-PP is empty. In fact, we define the log-PP instproc for the class PLMLossTrace. log-PP computes an estimate of the available bandwidth based on a single PP burst (of length PP_burst_length in packets). Once log-PP has received the PP_burst_length packets of the burst, it computes the estimate and calls the PLM instproc make_estimate with the computed estimate as argument.

make_estimate puts the estimate based on a single PP (PP_value) in an array of estimate samples (PP_estimate). If PP_value is lower than the current subscription level (i.e. lower than the throughput achieved according to the current number of layers subscribed), make_estimate calls the PLM instproc stability-drop which simply drops layers until the current subscription level becomes lower than PP_value. make_estimate makes an estimate PP_estimate_value by taking the minimum PP_value received during the last check_estimate period (if there are at least PP_estimation_length single PP estimate received). Once make_estimate has a PP_estimate_value it calls the PLM instproc choose_layer which joins or drops layer(s) according to the current subscription level and to the PP_estimate_value. For details about the PLM instproc make_estimate, refer to its code in ~ns/tcl/plm/plm.tcl.

Tom Henderson 2011-11-05