void BsmApplication::DequeueTrace(std::string context, Ptr<const WifiMacQueueItem> item)
{
// BIPLAV starts
// BIPLAV receiving starts
Time rcv;
Time sqhd;
Time total_delay;
Ptr< Packet> packet = (item->GetPacket())->Copy();
SeqTsHeader seqTsx;
rcv = (Simulator::Now()); // time of reception
packet->PeekHeader(seqTsx);
sqhd = (seqTsx.GetTs()); //time stamp of when packet generated
// std::cerr<<"rcv = "<<rcv<<", sqhd = "<<sqhd<<std::endl;
total_delay = (rcv - sqhd); //total delay calculation
loc_header new_header;
packet->PeekHeader(new_header);
Vector old_position = new_header.GetLocation();
Vector old_velocity = new_header.GetSpeed();
// std::cout<<"the speeds are: "<<old_velocity<<std::endl;
uint32_t SenderId = new_header.GetSenderId();
std::cerr<<"Inside DequeTrace for node at T="<<rcv.GetSeconds()<<" for node "<<SenderId<<" from ("<<old_position<<") with vel ("<<old_velocity<<")"<<std::endl;
std::cerr<<"tx_attempt was "<<tx_attempts[SenderId];
tx_attempts[SenderId] = tx_attempts[SenderId] + 1;
std::cerr<<" and it became "<< tx_attempts[SenderId]<<std::endl;
}
std::string dequeue_path= "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/*/$ns3::OcbWifiMac/*/Queue/Dequeue";
Config::Connect (dequeue_path, MakeCallback (&BsmApplication::DequeueTrace));
new_header.SetSenderId(socket->GetNode()->GetId());
My initial guess is that in the middle of the network, you are peeking a
packet that has different headers than the one at the endpoints.
Can you check first whether the packet size (GetSize ()) is the same at
both points?
>
> Either packet copying is where the mistake is, or my sequence of reading
> information from the header is wrong. But I use the same process to read
> packet header data at receiver, and it works.
>
> So I have a few questions:
>
> 1. Does creating packet copies copy the header associated with the packet ?
Yes, as needed.
> 2. PeekHeader vs RemoveHeader : PeekHeader doesn't tamper with the
> header, right ?
Right. Both PeekHeader and RemoveHeader copy the header bits into the
Header object that you have passed in.
> 3. If I have two headers, how do I read the seconds header without
> removing the first header ? I do PeekHeader and it doesn't generate
> errors, but the values are wrong and it typically happens when
> headers are read in the wrong way.
You can't peek more than the head-of-line header; if you need to look
further, you will usually need remove the first header and later add it
back.
void BsmApplication::DequeueTrace(std::string context, Ptr<const WifiMacQueueItem> item)
{
// BIPLAV starts
// BIPLAV receiving starts
Time rcv;
Time sqhd;
Time total_delay;
Ptr< Packet> packet = (item->GetPacket())->Copy();
SeqTsHeader seqTsx;
rcv = (Simulator::Now()); // time of reception
packet->RemoveHeader(seqTsx);
sqhd = (seqTsx.GetTs()); //time stamp of when packet generated
// std::cerr<<"rcv = "<<rcv<<", sqhd = "<<sqhd<<std::endl;
total_delay = (rcv - sqhd); //total delay calculation
loc_header new_header;
packet->RemoveHeader(new_header); Vector old_position = new_header.GetLocation(); // giving error Vector old_velocity = new_header.GetSpeed(); // giving error
// std::cout<<"the speeds are: "<<old_velocity<<std::endl;
uint32_t SenderId = new_header.GetSenderId(); // giving error
Packet->ToString() gives = ns3::LlcSnapHeader (type 0x0) ns3::Ipv4Header (tos 0x0 DSCP Default ECN Not-ECT ttl 0 id 0 protocol 0 offset (bytes) 0 flags [none] length: 20 102.102.102.102 > 102.102.102.102) ns3::UdpHeader (length: 65536 0 > 1) ns3::SeqTsHeader ((seq=0 time=0)) ns3::loc_Header (Packet sent by Node 0 from (0,0,0
) Payload (size=120)