Yes Yes, this is my problem. I know that the header isn't there firstly , i need to prevent BuildHeader method to create a new header and delete my old header modified by the previous router in receive method:
*the first sender (source) don't find any packet so any header therefore it will create a new packet. That makes packet->RemoveHeader(ipHeader) failed.
*Otherwise, all nodes receive and send an existed packet (also existed header) so i can do packet->RemoveHeader(ipHeader)
I tried to locate when the header change in my senario, I find that the header is changed in send method exactly in this part of code:
// 2) check: packet is destined to a subnet-directed broadcast address
uint32_t ifaceIndex = 0;
for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin ();
ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
{
Ptr<Ipv4Interface> outInterface = *ifaceIter;
for (uint32_t j = 0; j < GetNAddresses (ifaceIndex); j++)
{
Ipv4InterfaceAddress ifAddr = GetAddress (ifaceIndex, j);
NS_LOG_LOGIC ("Testing address " << ifAddr.GetLocal () << " with mask " << ifAddr.GetMask ());
if (destination.IsSubnetDirectedBroadcast (ifAddr.GetMask ()) &&
destination.CombineMask (ifAddr.GetMask ()) == ifAddr.GetLocal ().CombineMask (ifAddr.GetMask ()) )
{
NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 2: subnet directed bcast to " << ifAddr.GetLocal ())
----------->>>>> ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, tos, mayFragment);
Ptr<Packet> packetCopy = packet->Copy ();
m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex);
if ( ??????????????????????????????? ) packet->RemoveHeader(ipHeader);
packetCopy->AddHeader (ipHeader);
m_txTrace (packetCopy, m_node->GetObject<Ipv4> (), ifaceIndex);
outInterface->Send (packetCopy, destination);
return;
}
}
}
I want to add a condition for making packet->RemoveHeader(ipHeader) work and extract the old header.
Help me please Sir.