Project

General

Profile

Actions

Bug #4156

closed

Encoding LpPackets after adding repeating field causes other fields to be lost

Added by Eric Newberry over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Base
Target version:
Start date:
06/27/2017
Due date:
% Done:

100%

Estimated time:

Description

Encoding an LpPacket immediately after adding a repeatable field appears to cause all other fields to be lost, as seen in this example code:

#include <ndn-cxx/lp/packet.hpp>
#include <iostream>
#include <cstring>

int
main(int argc, char** argv)
{
  ndn::Buffer buf(100);
  uint32_t value = 1;
  std::memcpy(buf.buf(), &value, sizeof(value));

  ndn::lp::Packet pkt;
  pkt.set<ndn::lp::FragIndexField>(123);
  std::cout << pkt.wireEncode().size() << std::endl;
  pkt.set<ndn::lp::FragmentField>(std::make_pair(buf.begin(), buf.end()));
  std::cout << pkt.wireEncode().size() << std::endl;
  pkt.add<ndn::lp::TxSequenceField>(23568981);
  std::cout << pkt.wireEncode().size() << std::endl;
  pkt.add<ndn::lp::AckField>(1000);
  std::cout << pkt.wireEncode().size() << std::endl;
  pkt.add<ndn::lp::AckField>(1001);
  std::cout << pkt.wireEncode().size() << std::endl;
  pkt.add<ndn::lp::AckField>(1002);
  std::cout << pkt.wireEncode().size() << std::endl;

  ndn::Block b = pkt.wireEncode();
  std::cout.write(reinterpret_cast<const char*>(b.wire()), b.size());
}

Producing the following output:

5
107
115
8
8
8
[plus some non-alphanumeric output of the encoded packet]

This issue appears to be fixed if the LpPacket's existing elements are parsed before finding an iterator for the new element's position.


Related issues 1 (0 open1 closed)

Blocks NFD - Feature #3931: Implement NDNLP Link Reliability ProtocolClosedEric Newberry

Actions
Actions

Also available in: Atom PDF