Skip to content

Hackathon 13th July 2018

Christopher Scherb edited this page Jul 16, 2018 · 24 revisions

Agenda

  • Unit tests in CCN-lite
  • Data structures
  • Remove redundant (raw bytes) packet representation
  • Helper functions for creating interests and/or data

Participants

  • Cenk Gündogan (HAW)
  • Christopher Scherb (UBAS)
  • Michael Frey (MSA Safety)

Topics

Unit tests in CCN-lite

The goal is to have CMocka ready for CCN-lite. Tests (and mocks) should be in a directory test/ in the project root and integrated in the CMake-based build process. I've started a branch (latest changes need to be committed) over here.

I've created a top-level CMakeLists.txt which allows to build CCN-lite the following way (which just allows to omit the ../src in the cmake call for now)

$ mkdir build ; cd build
$ cmake ..
$ make

The goal would be to have a directory which contains a sub-directory "mocks/" and for each unit (of a unit test) at least a sub-directory, e.g. test/ccnl-pkt or test/ccnl-pkt-ndn.

Data structures

We want to start to refactor the interface for accessing various data structures across CCN-lite. One good starting point might be the content store. There is already a ticket which discusses some ideas, such as callbacks and a unified interface for accessing the content store (and hence allow to provide different implementations).

We should also think about making things const wherever it is possible. The content store will never alter prefix nor the content so there is no need to make them non-const (see also MISRA C:2004, rule 16.7 and MISRA C:2012, rule 8.13)

Ideas

NDN-CPP

I've thought it might be a good idea to look how NDN does it. The Data API is a good starting point.

API
/** 
  * @brief Returns the size of the content store
  */
uint32_t size();

/** 
  * @brief Adds content to the content store
  *
  * @return 0, if the operation was successful
  * @return -1, if the content could not be added to the content store (no space?)
  * @return -2, if the content is already in the content store
  */
int8_t add(const struct ccnl_prefix_s *prefix, const struct ccnl_content_s *content);

/** 
  * @brief Returns the content of a given @p prefix
  *
  * @return Upon success the content object associated with the given 
  *   prefix, NULL otherwise
  */
const struct ccnl_content_s* get(const struct ccnl_prefix_s *prefix);

/** 
  * @brief Removes all entries from the content store
  */
void clear();

/** 
  * @brief Checks if content under the given @p prefix is already stored
  *  in the content store.
  * 
  * @note Does it make sense?
  */
bool has_prefix(const struct ccnl_prefix_s *prefix);

/** 
  * @brief Removes the content associated with the given @p prefix from
  *  the content store.
  * 
  * @note Should the removed content be returned?
  */
void remove(const struct ccnl_prefix_s *prefix);

We probably should also spend a few thoughts on life-cycle. Which unit is responsible for a single struct ccnl_content_s 'object' returned by a get() call for example.

Remove redundant (raw bytes) packet representation

Pull Requests

Create an InterestObject in ccn-lite:

  • Use functions in ccnl-pkt/ccnl-pkt-builder
  • There are two types of packet crafting functions:
    • functions that returns an object which allocated memory (ccnl_mkInterestObject, ccnl_mkContentObject)
    • functions that uses preallocated memory (ccnl_mkInterest, ccnl_mkContent).

To create a new interest:

  • create a prefix:
    • struct ccnl_prefix_s *p = ccnl_URItoPrefix("/test/data", 0, NULL); // name, suite, chunknum
  • create an interest object:
    • struct ccnl_interest_s * i = ccnl_mkInterestObject(p, NULL); //prefix, options (NULL for default)
  • create binary interest data using preallocated memory:
    • char packet[CCNL_MAX_PACKET_SIZE]; int len; int off;
    • ccnl_mkInterest(p, NULL, packet, &len, &off); //prefix, options, out: packet, out: packetlen, offset?

To create a new content object:

  • create a prefix:
    • struct ccnl_prefix_s *p = ccnl_URItoPrefix("/test/data", 0, NULL); // name, suite, chunknum
  • create an content object:
    • struct ccnl_content_s * i = ccnl_mkContentObject(p, "payload", 7, NULL); //prefix, payload, payloadlen, options (NULL for default)
  • create binary content data using preallocated memory:
    • char packet[CCNL_MAX_PACKET_SIZE]; char tmp[CCNL_MAX_PACKET_SIZE]; int len; int contentpos; int off;
    • ccnl_mkContent(p, "payload", 7, packet, &len, &contentpos, &off, NULL);//prefix, payload, payloadlen, options, out: packet, out: packetlen, out: contentoffset, out: offset, options ?