NS2 Notebook:Display RTS/CTS Pkt Type in NS2 Trace File

来源:互联网 发布:金山数据恢复大师vip 编辑:程序博客网 时间:2024/06/07 17:07

This is actually useless for ns 2.33 as I know, but it is useful if we modify the trace formats as we wish : )

There are several posts on NS2 user mailing list explaining how to display RTS/CTS packet type in NS2 trace file. Hereis an example. However, I failed to adopt them in NS 2.26 with new trace format. Here is my solution which just uses code written for old trace format. You only need to modify ns-2.26/trace/cmu-trace.cc in the following way and I think this solution can also work for NS versions later than 2.26.

void
CMUTrace::format_mac(Packet *p, const char *why, int offset)
{

……



sprintf(pt_->buffer() + offset,
“-Ma %x -Md %x -Ms %x -Mt %s “,
mh->dh_duration,
ETHER_ADDR(mh->dh_da),
ETHER_ADDR(mh->dh_sa),
((ch->ptype() == PT_MAC) ? (
(mh->dh_fc.fc_subtype == MAC_Subtype_RTS) ? “RTS” :
(mh->dh_fc.fc_subtype == MAC_Subtype_CTS) ? “CTS” :
(mh->dh_fc.fc_subtype == MAC_Subtype_ACK) ? “ACK” :
“UNKN”
) : packet_info.name(ch->ptype())));

return;


}

Here is an exmaple NS2 trace file which displays the RTS/CTS/ACK information of MAC layer frame.


r -t 0.003583515 -Hs 0 -Hd -2 … -Nl MAC -Nw — -Ma 0 -Md 0 -Ms 0 -Mt ACK
s -t 0.003853348 -Hs 8 -Hd -2 …-Nl MAC -Nw — -Ma 2ff -Md 0 -Ms 8 -Mt RTS
r -t 0.004125515 -Hs 0 -Hd -2 … -Nl MAC -Nw — -Ma 2ff -Md 0 -Ms 8 -Mt RTS
s -t 0.004135515 -Hs 0 -Hd -2 … -Nl MAC -Nw — -Ma 1fd -Md 8 -Ms 0 -Mt CTS
r -t 0.004383682 -Hs 8 -Hd -2 … -Nl MAC -Nw — -Ma 1fd -Md 8 -Ms 0 -Mt CTS

0 0
原创粉丝点击