I have created a new packet header in NS2 which contains two fields.Is there any way to check to see if the packet header fields contains the value I have given through tcl.
If you have given values from tcl file then you need to bind these values with the variables you declared for your new packet header. Then for accessing those values you need to create an object of Packet class.
Sample code-
Packet* pkt = allocpkt();
hdr_cmn *ch = HDR_CMN(pkt);
hdr_ip* iph = HDR_IP(pkt);
hdr_yourhdr* aph = HDR_yourheader(pkt);
iph->src_.addr_ = here_.addr_;
iph->dst_.addr_ = IP_BROADCAST;
iph->dst_.port_ = this->port();
ch->next_hop() = IP_BROADCAST;
ch->ptype() = PT_DSRCApp;
ch->channel = channel_;
ch->size() = size_;
ch->type_dsrc = type_dsrc_;
ch->type_agent_ = type_agent_;
aph->seq_nr=seq_nr_; //your first variable
aph->x_src=pnode->X(); //your second variable
ch is the object of common header and iph is the object of ip header.
iph is the object of your new header. And seq_nr and x_src are your two fields of your header.
Use printf when the packet arrives at the destination to see the contents of the field you just added or you can also use printf somewhere in the middle layer to see the contents.
As said by Bilal, use printf when packet arrived at the destination. For example in above code if you want to print the value of your second variable use this line
I am not good in ns2 , so i need help. Please guide me how to change the priority of the packet in ns2...My mean if two packets reached to the node or router at same time router read the priorities of packets, and then forward high priority packet first and low priority packet 2nd....thanks