JonnyKong / Sync-MANET

A data synchronization library over Named Data Networking for MANET
GNU Lesser General Public License v2.1
2 stars 2 forks source link

Duplicate data_interest #2

Open yoursunny opened 3 years ago

yoursunny commented 3 years ago

I'm evaluating the chat client application. It seems that the program is sometimes sending multiple data_interest packets at the same time.

Environment:

Steps:

  1. In $HOME/.ndn/client.conf, set transport=tcp://127.0.0.1:6363 so that ndn-cxx connects to NFD over TCP.
  2. Start tcpdump -i lo 'port 6363' to capture packets.
  3. Start NFD.
  4. Set multicast strategy for /ndn/svs namespace.
  5. Start three clients with ID 1, 2, and 3.
  6. Send "aaa" from client 1.
  7. Send "bbb" from client 2.
  8. Send "ccc" from client 3.

The pcap trace indicates that the client is sometimes sending the same data_interest more than once. This occurs within a short period of time, as these Interests appear as a single TCP segment. An example is frame 176, in which the application sends two Interests with name /ndn/svs/vsyncData/%01/%02/%00 and different nonces. Another example is frame 305, where three Interests with the same name were sent.

While sending duplicate Interests does not cause real problems because the forwarder would aggregate these packets and the client library would deliver Data replies to every callback, this wastes compute cycles and indicates a potential logic error in the Sync-MANET library.

JonnyKong commented 3 years ago

Thanks for the profiling. It is the expected behavior, but I agree it will waste cycles.

This is likely because the library use an asynchronous queue (pending_data_interest) containing the packets to be sent to NFD. It dispatches packets (SVS::asyncSendPacket()) at a constant rate, regardless of the packet type, or number of packets remaining in the queue.

To account for data_interest losses, when a data_interest is sent to NFD, it will be enqueued again immediately: https://github.com/JonnyKong/Sync-MANET/blob/dd077d6a9c62a689be1d8e070e77c8909a2ccdba/svs.cpp#L108

Therefore, when the queue is very short, the same data_interest will be sent again and again before corresponding data comes back.

yoursunny commented 3 years ago

It is the expected behavior

It is the implemented behavior, but should not be the expected behavior. It makes no sense to retransmit the same Interest before estimated RTO has elapsed.

JonnyKong commented 3 years ago

It is the implemented behavior, but should not be the expected behavior. It makes no sense to retransmit the same Interest before estimated RTO has elapsed.

Yes, I agree. This is a hackathon project, so many things are implemented roughly.