12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

UserInheritPLMTopologyI<strong>ns</strong>tanti<strong>at</strong>ePLMPLM/<strong>ns</strong>PLMLayerPLMLayerPLMLayer/<strong>ns</strong>PLMLayer/<strong>ns</strong>Agent/LossMonitor/PLMAgent/LossMonitor/PLMPLMLossTracePLMLossTraceNumber of layersFigure 37.1: Inheritance <strong>and</strong> i<strong>ns</strong>tanti<strong>at</strong>ion when we cre<strong>at</strong>e a receiver.cre<strong>at</strong>e-layer <strong>and</strong>, by this way, cre<strong>at</strong>es as many i<strong>ns</strong>tances of the class PLMLayer/<strong>ns</strong> (the <strong>ns</strong> interface to the PLMLayerclass) as there are layers. Each i<strong>ns</strong>tance of PLMLayer/<strong>ns</strong> cre<strong>at</strong>es an i<strong>ns</strong>tance of the class PLMLossTrace which is repo<strong>ns</strong>iblefor monitoring the received <strong>and</strong> lost packets thanks to the fact th<strong>at</strong> the class PLMLossTrace inherits from the classAgent/LossMonitor/PLM. Fig. 37.1 schem<strong>at</strong>ically describes the process of a PLM receiver i<strong>ns</strong>tanti<strong>at</strong>ion. In the following wedescribe the behavior of a PLM receiver when it receives a packet <strong>and</strong> when it detects a loss.37.3.3 Reception of a PacketWe cre<strong>at</strong>e a new c++ class PLMLossMonitor (~<strong>ns</strong>/plm/loss-monitor-plm.cc) th<strong>at</strong> inherits from LossMonitor. <strong>The</strong> OTcl classname of the c++ PLMLossMonitor class is Agent/LossMonitor/PLM.class PLMLossMonitor : public LossMonitorpublic:PLMLossMonitor();virtual void recv(Packet* pkt, H<strong>and</strong>ler*);protected:// PLM onlyint flag_PP_;double packet_time_PP_;int fid_PP_;;st<strong>at</strong>ic class PLMLossMonitorClass : public TclClasspublic:PLMLossMonitorClass() : TclClass("Agent/LossMonitor/PLM")TclObject* cre<strong>at</strong>e(int, co<strong>ns</strong>t char*co<strong>ns</strong>t*)return (new PLMLossMonitor());class_loss_mon_plm;327

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!