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.

<strong>The</strong> recv() method overrides the base class Connector version. It is defined as follows:void LinkDelay::recv(Packet* p, H<strong>and</strong>ler* h){double txt = txtime(p);Scheduler& s = Scheduler::i<strong>ns</strong>tance();if (dynamic_) {Event* e = (Event*)p;e->time_ = s.clock() + txt + delay_;itq_->enque(p);schedule_next();} else {s.schedule(target_, p, txt + delay_);}/* XXX only need one intr_ since upstream object should* block until it’s h<strong>and</strong>ler is called** This only holds if the link is not dynamic. If it is, then* the link itself will hold the packet, <strong>and</strong> call the upstream* object <strong>at</strong> the appropri<strong>at</strong>e time. This second interrupt is* called inTra<strong>ns</strong>it_, <strong>and</strong> is invoked through schedule_next()*/s.schedule(h, &intr_, txt);}This object supports one i<strong>ns</strong>tproc-like, $object dynamic, to set its variable, dynamic_. This variable determineswhether the link is dynamic or not (i.e., prone to fail/recover <strong>at</strong> appropri<strong>at</strong>e times). <strong>The</strong> internal behavior of the link in eachcase is different.For “non-dynamic” links, this method oper<strong>at</strong>es by receiving a packet, p, <strong>and</strong> scheduling two events. Assume these two eventsare called E 1 <strong>and</strong> E 2 , <strong>and</strong> th<strong>at</strong> event E 1 is scheduled to occur before E 2 . E 1 is scheduled to occur when the upstream node<strong>at</strong>tached to this delay element has completed sending the current packet (which takes time equal to the packet size dividedby the link b<strong>and</strong>width). E 1 is usually associ<strong>at</strong>ed with a Queue object, <strong>and</strong> will cause it to (possibly) become unblocked (seesection 7.1.1). E 2 represents the packet arrival event <strong>at</strong> the dow<strong>ns</strong>tream neighbor of the delay element. Event E 2 occurs anumber of seconds l<strong>at</strong>er than E 1 equal to the link delay.Altern<strong>at</strong>ely, when the link is dynamic, <strong>and</strong> receives p, then it will schedule E 1 to possibly unblock the queue <strong>at</strong> the appropri<strong>at</strong>etime. However, E 2 is scheduled only if p is the only packet currently in tra<strong>ns</strong>it. Otherwise, there is <strong>at</strong> least one packet intra<strong>ns</strong>it on the link th<strong>at</strong> must be delivered before p <strong>at</strong> E 2 . <strong>The</strong>refore, packet p is held in the object’s inTra<strong>ns</strong>it queue, itq_.When the packet just before p in tra<strong>ns</strong>it on the link is delivered <strong>at</strong> the neighbor node, the DelayLink object will schedule anevent for itself to fire <strong>at</strong> E 2 . At th<strong>at</strong> appropri<strong>at</strong>e time then, it’s h<strong>and</strong>le() method will directly send p to its target. <strong>The</strong> object’sinternal schedule_next() method will schedule these events for packet sin tra<strong>ns</strong>it <strong>at</strong> the appropri<strong>at</strong>e time.8.2 Comm<strong>and</strong>s <strong>at</strong> a glance<strong>The</strong> LinkDelay object represents the time required by a packet to tra<strong>ns</strong>verse the link <strong>and</strong> is used internally within a Link.Hence we donot list any linkdelay rel<strong>at</strong>ed comm<strong>and</strong>s suitable for simul<strong>at</strong>ion scripts here.86

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

Saved successfully!

Ooh no, something went wrong!