📄 cmu-trace.cc
字号:
voidCMUTrace::format_dsr(Packet *p, int offset){ hdr_sr *srh = hdr_sr::access(p); if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-dsr:h %d -dsr:q %d -dsr:s %d -dsr:p %d -dsr:n %d " "-dsr:l %d -dsr:e {%d %d} -dsr:w %d -dsr:m %d -dsr:c %d " "-dsr:b {%d %d} ", srh->num_addrs(), srh->route_request(), srh->rtreq_seq(), srh->route_reply(), srh->rtreq_seq(), srh->route_reply_len(), srh->reply_addrs()[0].addr, srh->reply_addrs()[srh->route_reply_len()-1].addr, srh->route_error(), srh->num_route_errors(), srh->down_links()[srh->num_route_errors() - 1].tell_addr, srh->down_links()[srh->num_route_errors() - 1].from_addr, srh->down_links()[srh->num_route_errors() - 1].to_addr); return; } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-P dsr -Ph %d -Pq %d -Ps %d -Pp %d -Pn %d -Pl %d -Pe %d->%d -Pw %d -Pm %d -Pc %d -Pb %d->%d ", srh->num_addrs(), // how many nodes travered srh->route_request(), srh->rtreq_seq(), srh->route_reply(), srh->rtreq_seq(), srh->route_reply_len(), // the dest of the src route srh->reply_addrs()[0].addr, srh->reply_addrs()[srh->route_reply_len()-1].addr, srh->route_error(), srh->num_route_errors(), srh->down_links()[srh->num_route_errors() - 1].tell_addr, srh->down_links()[srh->num_route_errors() - 1].from_addr, srh->down_links()[srh->num_route_errors() - 1].to_addr); return; } sprintf(pt_->buffer() + offset, "%d [%d %d] [%d %d %d %d->%d] [%d %d %d %d->%d]", srh->num_addrs(), srh->route_request(), srh->rtreq_seq(), srh->route_reply(), srh->rtreq_seq(), srh->route_reply_len(), // the dest of the src route srh->reply_addrs()[0].addr, srh->reply_addrs()[srh->route_reply_len()-1].addr, srh->route_error(), srh->num_route_errors(), srh->down_links()[srh->num_route_errors() - 1].tell_addr, srh->down_links()[srh->num_route_errors() - 1].from_addr, srh->down_links()[srh->num_route_errors() - 1].to_addr);}voidCMUTrace::format_msg(Packet *, int){}voidCMUTrace::format_tcp(Packet *p, int offset){ struct hdr_cmn *ch = HDR_CMN(p); struct hdr_tcp *th = HDR_TCP(p); if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-tcp:s %d -tcp:a %d -tcp:f %d -tcp:o %d ", th->seqno_, th->ackno_, ch->num_forwards(), ch->opt_num_forwards()); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-Pn tcp -Ps %d -Pa %d -Pf %d -Po %d ", th->seqno_, th->ackno_, ch->num_forwards(), ch->opt_num_forwards()); } else { sprintf(pt_->buffer() + offset, "[%d %d] %d %d", th->seqno_, th->ackno_, ch->num_forwards(), ch->opt_num_forwards()); }}/* Armando L. Caro Jr. <acaro@@cis,udel,edu> 6/5/2002 * (with help from Florina Almenrez <florina@@it,uc3m,es>) */voidCMUTrace::format_sctp(Packet* p,int offset){ struct hdr_cmn *ch = HDR_CMN(p); struct hdr_sctp *sh = HDR_SCTP(p); //struct hdr_ip *ih = HDR_IP(p); char cChunkType; for(u_int i = 0; i < sh->NumChunks(); i++) { switch(sh->SctpTrace()[i].eType) { case SCTP_CHUNK_INIT: case SCTP_CHUNK_INIT_ACK: case SCTP_CHUNK_COOKIE_ECHO: case SCTP_CHUNK_COOKIE_ACK: cChunkType = 'I'; // connection initialization break; case SCTP_CHUNK_DATA: cChunkType = 'D'; break; case SCTP_CHUNK_SACK: cChunkType = 'S'; break; case SCTP_CHUNK_FORWARD_TSN: cChunkType = 'R'; break; case SCTP_CHUNK_HB: cChunkType = 'H'; break; case SCTP_CHUNK_HB_ACK: cChunkType = 'B'; break; default: // quiet compiler cChunkType = ' '; assert (false); break; } if( newtrace_ ) { sprintf(pt_->buffer() + offset, "-Pn sctp -Pnc %d -Pct %c " "-Ptsn %d -Psid %d -Pssn %d " "-Pf %d -Po %d ", sh->NumChunks(), cChunkType, sh->SctpTrace()[i].uiTsn, sh->SctpTrace()[i].usStreamId, sh->SctpTrace()[i].usStreamSeqNum, ch->num_forwards(), ch->opt_num_forwards()); } else { sprintf(pt_->buffer() + offset, "[%d %c %d %d %d] %d %d", sh->NumChunks(), cChunkType, sh->SctpTrace()[i].uiTsn, sh->SctpTrace()[i].usStreamId, sh->SctpTrace()[i].usStreamSeqNum, ch->num_forwards(), ch->opt_num_forwards()); } }}voidCMUTrace::format_rtp(Packet *p, int offset){ struct hdr_cmn *ch = HDR_CMN(p); struct hdr_rtp *rh = HDR_RTP(p); struct hdr_ip *ih = HDR_IP(p); Node* thisnode = Node::get_node_by_address(src_); //hacking, needs to change later, int dst = Address::instance().get_nodeaddr(ih->daddr()); if (dst == src_){ // I just received a cbr data packet if (thisnode->energy_model() && thisnode->energy_model()->powersavingflag()) { thisnode->energy_model()->set_node_state(EnergyModel::INROUTE); } } if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-cbr:s %d -cbr:f %d -cbr:o %d ", rh->seqno_, ch->num_forwards(), ch->opt_num_forwards()); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-Pn cbr -Pi %d -Pf %d -Po %d ", rh->seqno_, ch->num_forwards(), ch->opt_num_forwards()); } else { sprintf(pt_->buffer() + offset, "[%d] %d %d", rh->seqno_, ch->num_forwards(), ch->opt_num_forwards()); }}voidCMUTrace::format_imep(Packet *p, int offset){ struct hdr_imep *im = HDR_IMEP(p);#define U_INT16_T(x) *((u_int16_t*) &(x)) if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-imep:a %c -imep:h %c -imep:o %c -imep:l %04x ", (im->imep_block_flags & BLOCK_FLAG_ACK) ? 'A' : '-', (im->imep_block_flags & BLOCK_FLAG_HELLO) ? 'H' : '-', (im->imep_block_flags & BLOCK_FLAG_OBJECT) ? 'O' : '-', U_INT16_T(im->imep_length)); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-P imep -Pa %c -Ph %c -Po %c -Pl 0x%04x ] ", (im->imep_block_flags & BLOCK_FLAG_ACK) ? 'A' : '-', (im->imep_block_flags & BLOCK_FLAG_HELLO) ? 'H' : '-', (im->imep_block_flags & BLOCK_FLAG_OBJECT) ? 'O' : '-', U_INT16_T(im->imep_length)); } else { sprintf(pt_->buffer() + offset, "[%c %c %c 0x%04x] ", (im->imep_block_flags & BLOCK_FLAG_ACK) ? 'A' : '-', (im->imep_block_flags & BLOCK_FLAG_HELLO) ? 'H' : '-', (im->imep_block_flags & BLOCK_FLAG_OBJECT) ? 'O' : '-', U_INT16_T(im->imep_length)); }#undef U_INT16_T}voidCMUTrace::format_tora(Packet *p, int offset){ struct hdr_tora *th = HDR_TORA(p); struct hdr_tora_qry *qh = HDR_TORA_QRY(p); struct hdr_tora_upd *uh = HDR_TORA_UPD(p); struct hdr_tora_clr *ch = HDR_TORA_CLR(p); switch(th->th_type) { case TORATYPE_QRY: if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-tora:t %x -tora:d %d -tora:c QUERY", qh->tq_type, qh->tq_dst); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-P tora -Pt 0x%x -Pd %d -Pc QUERY ", qh->tq_type, qh->tq_dst); } else { sprintf(pt_->buffer() + offset, "[0x%x %d] (QUERY)", qh->tq_type, qh->tq_dst); } break; case TORATYPE_UPD: if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-tora:t %x -tora:d %d -tora:a %f -tora:o %d " "-tora:r %d -tora:e %d -tora:i %d -tora:c UPDATE", uh->tu_type, uh->tu_dst, uh->tu_tau, uh->tu_oid, uh->tu_r, uh->tu_delta, uh->tu_id); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-P tora -Pt 0x%x -Pd %d (%f %d %d %d %d) -Pc UPDATE ", uh->tu_type, uh->tu_dst, uh->tu_tau, uh->tu_oid, uh->tu_r, uh->tu_delta, uh->tu_id); } else { sprintf(pt_->buffer() + offset, "-Pt 0x%x -Pd %d -Pa %f -Po %d -Pr %d -Pe %d -Pi %d -Pc UPDATE ", uh->tu_type, uh->tu_dst, uh->tu_tau, uh->tu_oid, uh->tu_r, uh->tu_delta, uh->tu_id); } break; case TORATYPE_CLR: if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-tora:t %x -tora:d %d -tora:a %f -tora:o %d " "-tora:c CLEAR ", ch->tc_type, ch->tc_dst, ch->tc_tau, ch->tc_oid); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-P tora -Pt 0x%x -Pd %d -Pa %f -Po %d -Pc CLEAR ", ch->tc_type, ch->tc_dst, ch->tc_tau, ch->tc_oid); } else { sprintf(pt_->buffer() + offset, "[0x%x %d %f %d] (CLEAR)", ch->tc_type, ch->tc_dst, ch->tc_tau, ch->tc_oid); } break; }}voidCMUTrace::format_aodv(Packet *p, int offset){ struct hdr_aodv *ah = HDR_AODV(p); struct hdr_aodv_request *rq = HDR_AODV_REQUEST(p); struct hdr_aodv_reply *rp = HDR_AODV_REPLY(p); switch(ah->ah_type) { case AODVTYPE_RREQ: if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-aodv:t %x -aodv:h %d -aodv:b %d -aodv:d %d " "-aodv:ds %d -aodv:s %d -aodv:ss %d " "-aodv:c REQUEST ", rq->rq_type, rq->rq_hop_count, rq->rq_bcast_id, rq->rq_dst, rq->rq_dst_seqno, rq->rq_src, rq->rq_src_seqno); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-P aodv -Pt 0x%x -Ph %d -Pb %d -Pd %d -Pds %d -Ps %d -Pss %d -Pc REQUEST ", rq->rq_type, rq->rq_hop_count, rq->rq_bcast_id, rq->rq_dst, rq->rq_dst_seqno, rq->rq_src, rq->rq_src_seqno); } else { sprintf(pt_->buffer() + offset, "[0x%x %d %d [%d %d] [%d %d]] (REQUEST)", rq->rq_type, rq->rq_hop_count, rq->rq_bcast_id, rq->rq_dst, rq->rq_dst_seqno, rq->rq_src, rq->rq_src_seqno); } break; case AODVTYPE_RREP: case AODVTYPE_HELLO: case AODVTYPE_RERR: if (pt_->tagged()) { sprintf(pt_->buffer() + offset, "-aodv:t %x -aodv:h %d -aodv:d %d -adov:ds %d " "-aodv:l %f -aodv:c %s ", rp->rp_type, rp->rp_hop_count, rp->rp_dst, rp->rp_dst_seqno, rp->rp_lifetime, rp->rp_type == AODVTYPE_RREP ? "REPLY" : (rp->rp_type == AODVTYPE_RERR ? "ERROR" : "HELLO")); } else if (newtrace_) { sprintf(pt_->buffer() + offset, "-P aodv -Pt 0x%x -Ph %d -Pd %d -Pds %d -Pl %f -Pc %s ", rp->rp_type, rp->rp_hop_count, rp->rp_dst, rp->rp_dst_seqno, rp->rp_lifetime, rp->rp_type == AODVTYPE_RREP ? "REPLY" : (rp->rp_type == AODVTYPE_RERR ? "ERROR" : "HELLO")); } else { sprintf(pt_->buffer() + offset, "[0x%x %d [%d %d] %f] (%s)", rp->rp_type, rp->rp_hop_count, rp->rp_dst, rp->rp_dst_seqno, rp->rp_lifetime, rp->rp_type == AODVTYPE_RREP ? "REPLY" : (rp->rp_type == AODVTYPE_RERR ? "ERROR" : "HELLO")); } break; default:#ifdef WIN32 fprintf(stderr, "CMUTrace::format_aodv: invalid AODV packet type\n");#else fprintf(stderr, "%s: invalid AODV packet type\n", __FUNCTION__);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -