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.

36.7 Extending the Base Class AgentIn the earlier section on configur<strong>at</strong>ion parameters (Section 36.1.2), we had shown how to trivially extend the agent to getdeterministic <strong>and</strong> probabilistic protocol behavior. In this section, we describe how to derive more complex exte<strong>ns</strong>io<strong>ns</strong> to theprotocol for fixed <strong>and</strong> adaptive timer mechanisms.36.7.1 Fixed Timers<strong>The</strong> fixed timer mechanism are done in the derived class Agent/SRM/Fixed <strong>The</strong> main difference with fixed timers isth<strong>at</strong> the repair parameters are set to log(groupSize_). <strong>The</strong>refore, the repair procedure of a fixed timer agent will set D 1<strong>and</strong> D 2 to be proportional to the group size before scheduling the repair object.36.7.2 Adaptive TimersAgents using adaptive timer mechanisms modify their request <strong>and</strong> repair parameters under three conditio<strong>ns</strong> (1) every time anew loss object is cre<strong>at</strong>ed; (2) when sending a message; <strong>and</strong> (3) when they receive a duplic<strong>at</strong>e, if their rel<strong>at</strong>ive distance to theloss is less than th<strong>at</strong> of the agent th<strong>at</strong> sends the duplic<strong>at</strong>e. All three changes require exte<strong>ns</strong>io<strong>ns</strong> to the agent <strong>and</strong> the loss objects.<strong>The</strong> class Agent/SRM/Adaptive uses class SRM/request/Adaptive <strong>and</strong> class SRM/repair/Adaptiveas the request <strong>and</strong> repair functio<strong>ns</strong> respectively. In addition, the last item requires extending the packet headers, to advertisetheir distances to the loss. <strong>The</strong> corresponding compiled class for the agent is the class ASRMAgent.Recompute for Each New Loss Object Each time a new request object is cre<strong>at</strong>ed, SRM/request/Adaptive::set-paramsinvokes $agent_ recompute-request-params. <strong>The</strong> agent method recompute-request-params(). uses thest<strong>at</strong>istics about duplic<strong>at</strong>es <strong>and</strong> delay to modify C 1 <strong>and</strong> C 2 for the current <strong>and</strong> future requests.Similarly, SRM/request/Adaptive::set-params for a new repair object invokes $agent_ recompute-repair-params.<strong>The</strong> agent method recompute-repair-params(). uses the st<strong>at</strong>istics objects to modify D 1 <strong>and</strong> D 2 for the current <strong>and</strong>future repairs.Sending a Message If a loss object sends a request in its first round_, then the agent, in the i<strong>ns</strong>tance procedure sending-request{},will lower C 1 , <strong>and</strong> set its i<strong>ns</strong>tance variable closest_(requestor) to 1.Similarly, a loss object th<strong>at</strong> sends a repair in its first round_ will invoke the agent’s i<strong>ns</strong>tance procedure, sending-repair{},to lower D 1 <strong>and</strong> set closest_(repairor) to 1.Advertising the Distance Each agent must add additional inform<strong>at</strong>ion to each request/repair th<strong>at</strong> it sends out. <strong>The</strong> baseclass SRMAgent invokes the virtual method addExtendedHeaders() for each SRM packet th<strong>at</strong> it sends out. <strong>The</strong>method is invoked after adding the SRM packet headers, <strong>and</strong> before the packet is tra<strong>ns</strong>mitted. <strong>The</strong> adaptive SRM agentoverloads addExtendedHeaders() to specify its distances in the additional headers. When sending a request, th<strong>at</strong> agentunequivocally knows the identity of the sender. As an example, the definition of addExtendedHeaders() for the adaptiveSRM agent is:void addExtendedHeaders(Packet* p) {SRMinfo* sp;hdr_srm* sh = (hdr_srm*) p->access(off_srm_);319

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

Saved successfully!

Ooh no, something went wrong!