I generated tcp packet in the leaf switch named A in a spine-leaf topology. When in leaf switch B I use function "PeekHeader" to get the information of the tcp header I generated before, the program terminated with the error "assert failed. cond="m_current + delta <= m_dataEnd", file=./ns3/buffer.h, line=853". And I make sure the tcp packet should reach the switch B.
I use backtrace in gdb to find the cause of the error. It is actually the "TcpHeader::Deserialize" error. However, if in the leaf switch A I "PeekHeader" the tcp packet I generated, the correct information will come out.
I am very confused why the information is incorrect in another switch. Below is my code that I used to generate the tcp packet. I created a tcp packet returned.
Ptr<Packet> sqy_p = Create<Packet> ();
Ipv4Header new_ipHeader;
TcpHeader sqy_header,new_tcpHeader;
Buffer buffer;
packet->PeekHeader(sqy_header);
new_ipHeader.SetSource(destAddress);
new_ipHeader.SetDestination(header.GetSource());
new_tcpHeader.SetSourcePort(sqy_header.GetDestinationPort());
new_tcpHeader.SetDestinationPort(sqy_header.GetSourcePort());
new_tcpHeader.SetSequenceNumber (SequenceNumber32(0));
new_tcpHeader.SetAckNumber (SequenceNumber32(0));
uint8_t flags=0;
flags |= TcpHeader::ACK;
new_tcpHeader.SetFlags(flags);
new_tcpHeader.SetWindowSize(0);
new_tcpHeader.SetUrgentPointer(0);
buffer.AddAtStart(new_tcpHeader.GetSerializedSize ());
new_tcpHeader.Serialize (buffer.Begin ());
new_tcpHeader.EnableChecksums();
new_tcpHeader.InitializeChecksum (destAddress, header.GetSource(), 6);
sqy_p->AddHeader(new_tcpHeader);
new_ipHeader.SetProtocol(6);
//new_ipHeader.SetPayloadSize(0);
//sqy_p->AddHeader(new_ipHeader);
TcpHeader CopyHeader;
sqy_p->PeekHeader(CopyHeader);
NS_LOG_ERROR (" PeekHeader: "<<TcpHeader::FlagsToString(CopyHeader.GetFlags()));
uint32_t sqy_flowId = CongaFlowId (destAddress, header.GetSource(), sqy_header.GetDestinationPort(), sqy_header.GetSourcePort());
sqy_p->AddPacketTag(FlowIdTag(sqy_flowId));
sqy_p->AddPacketTag(sqyEcho(sqy_flowId));