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.

Chapter 8Delays <strong>and</strong> LinksDelays represent the time required for a packet to traverse a link. A special form of this object (“dynamic link”) also capturesthe possibility of a link failure. <strong>The</strong> amount of time required for a packet to traverse a link is defined to be s/b + d where sis the packet size (as recorded in its IP header), b is the speed of the link in bits/sec, <strong>and</strong> d is the link delay in seconds. <strong>The</strong>implement<strong>at</strong>ion of link delays is closely associ<strong>at</strong>ed with the blocking procedures described for Queues in Section7.1.1.8.1 <strong>The</strong> LinkDelay Class<strong>The</strong> class LinkDelay is derived from the base class Connector. Its definition is in ~<strong>ns</strong>/delay.cc, <strong>and</strong> is brieflyexcerpted below:class LinkDelay : public Connector {public:LinkDelay();void recv(Packet* p, H<strong>and</strong>ler*);void send(Packet* p, H<strong>and</strong>ler*);void h<strong>and</strong>le(Event* e);double delay(); /* line l<strong>at</strong>ency on this link */double b<strong>and</strong>width(); /* b<strong>and</strong>width on this link */inline double txtime(Packet* p) { /* time to send pkt p on this link */hdr_cmn* hdr = (hdr_cmn*) p->access(off_cmn_);return (hdr->size() * 8. / b<strong>and</strong>width_);}protected:double b<strong>and</strong>width_; /* b<strong>and</strong>width of underlying link (bits/sec) */double delay_; /* line l<strong>at</strong>ency */int dynamic_; /* indic<strong>at</strong>es whether or not link is ~ */Event inTra<strong>ns</strong>it_;PacketQueue* itq_; /* internal packet queue for dynamic links */Packet* nextPacket_; /* to be delivered for a dynamic link. */Event intr_;};85

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

Saved successfully!

Ooh no, something went wrong!