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.

26.4 Trace File Form<strong>at</strong><strong>The</strong> Trace::form<strong>at</strong>() method defines the trace file form<strong>at</strong> used in trace files produced by the Trace class. It is co<strong>ns</strong>tructedto maintain backward comp<strong>at</strong>ibility with output files in earlier versio<strong>ns</strong> of the simul<strong>at</strong>or (i.e., <strong>ns</strong> v1) so th<strong>at</strong> <strong>ns</strong> v1post-processing scripts continue to oper<strong>at</strong>e. <strong>The</strong> important pieces of its implement<strong>at</strong>ion are as follows:// this function should retain some backward-comp<strong>at</strong>ibility, so th<strong>at</strong>// scripts don’t break.void Trace::form<strong>at</strong>(int tt, int s, int d, Packet* p){hdr_cmn *th = (hdr_cmn*)p->access(off_cmn_);hdr_ip *iph = (hdr_ip*)p->access(off_ip_);hdr_tcp *tcph = (hdr_tcp*)p->access(off_tcp_);hdr_rtp *rh = (hdr_rtp*)p->access(off_rtp_);packet_t t = th->ptype();co<strong>ns</strong>t char* name = packet_info.name(t);if (name == 0)abort();int seqno;/* XXX *//* CBR’s now have seqno’s too */if (t == PT_RTP || t == PT_CBR)seqno = rh->seqno();else if (t == PT_TCP || t == PT_ACK)seqno = tcph->seqno();elseseqno = -1;...if (!show_tcphdr_) {sprintf(wrk_, "%c %g %d %d %s %d %s %d %d.%d %d.%d %d %d",tt,Scheduler::i<strong>ns</strong>tance().clock(),s,d,name,th->size(),flags,iph->flowid() /* was p->class_ */,iph->src() >> 8, iph->src() & 0xff, // XXXiph->dst() >> 8, iph->dst() & 0xff,seqno,th->uid() /* was p->uid_ */);// XXX} else {sprintf(wrk_,"%c %g %d %d %s %d %s %d %d.%d %d.%d %d %d %d 0x%x %d",tt,Scheduler::i<strong>ns</strong>tance().clock(),s,d,235

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

Saved successfully!

Ooh no, something went wrong!