Custom Nodes

class ndn.schema.simple_node.LocalResource(parent=None, data=None)

LocalResource is a custom node that preloads some data. When need() is called, it returns the loaded data directly. This node type does not interact with the network.

async need(match, **kwargs)

Consume an object corresponding to this node. Specific node type can override this function to have customized processing pipeline. For example, a SegmentedNode can do reassembly here. By default it sends an Interest packet to fetch a Data.

Parameters
  • match – the matched node object of this node.

  • kwargs – other arguments from user input.

Returns

This is defined by the node type. By default it returns what process_data() returns. That is, a tuple of contect and metadata dict.

async on_register(root, app, prefix, cached)

Called when the root node root is attached to app, and the attach() wants to register prefixed under the subtree rooted at this node.

Parameters
  • root – the root of the static tree.

  • app – the NDNApp to be attached to.

  • prefix – the prefix of the static tree.

  • cached (bool) – If there is a cache policy that applies to this node.

Returns

whether succeeded or not.

async provide(match, content, **kwargs)

Produce an object corresponding to this node, and make all generated Data packets available. Specific node type can override this function to have customized processing pipeline. For example, a SegmentedNode can do segmentation here. By default it makes a Data packet out of content and put it into the cache.

Parameters
  • match – the matched node object of this node.

  • content – the content of the object.

  • kwargs – other arguments from user input.

class ndn.schema.simple_node.RDRNode(parent=None, **kwargs)

RDRNode represents a versioned and segmented object whose encoding follows the RDR protocol. Its provide function generates the metadata packet, and need function handles version discovery.

class MetaData(parent=None)
async need(match, **kwargs)

Consume an object corresponding to this node. Specific node type can override this function to have customized processing pipeline. For example, a SegmentedNode can do reassembly here. By default it sends an Interest packet to fetch a Data.

Parameters
  • match – the matched node object of this node.

  • kwargs – other arguments from user input.

Returns

This is defined by the node type. By default it returns what process_data() returns. That is, a tuple of contect and metadata dict.

async process_int(match, param, app_param, raw_packet)

Processing an incoming Interest packet. Specific node type can override this function to have customized processing pipeline.

Note

This function will not be called if the Interest packet is satisfied with a cached Data packet.

Parameters
  • match – the matched node object of this node.

  • param – the parameters of the Interest packet.

  • app_param – the ApplicationParameters of the Interest packet.

  • raw_packet – the raw Interest packet.

class MetaDataValue
async need(match, **kwargs)

Consume an object corresponding to this node. Specific node type can override this function to have customized processing pipeline. For example, a SegmentedNode can do reassembly here. By default it sends an Interest packet to fetch a Data.

Parameters
  • match – the matched node object of this node.

  • kwargs – other arguments from user input.

Returns

This is defined by the node type. By default it returns what process_data() returns. That is, a tuple of contect and metadata dict.

async provide(match, content, **kwargs)

Produce an object corresponding to this node, and make all generated Data packets available. Specific node type can override this function to have customized processing pipeline. For example, a SegmentedNode can do segmentation here. By default it makes a Data packet out of content and put it into the cache.

Parameters
  • match – the matched node object of this node.

  • content – the content of the object.

  • kwargs – other arguments from user input.

class ndn.schema.simple_node.SegmentedNode(parent=None, timeout=4000, retry_times=3, segment_size=4400)

SegmentedNode represents a segmented object. The segmented object is composed with multiple Data packets, whose name have a suffix “/seg=seg_no” attached to the object’s name. The provide function handles segmentation, and the need function handles reassembly.

Note

Currently, the fetching pipeline is a simple one-by-one pipeline. where only one Interest will be in-flight at one time.

async need(match, **kwargs)

Consume an object corresponding to this node. Specific node type can override this function to have customized processing pipeline. For example, a SegmentedNode can do reassembly here. By default it sends an Interest packet to fetch a Data.

Parameters
  • match – the matched node object of this node.

  • kwargs – other arguments from user input.

Returns

This is defined by the node type. By default it returns what process_data() returns. That is, a tuple of contect and metadata dict.

async process_int(match, param, app_param, raw_packet)

Processing an incoming Interest packet. Specific node type can override this function to have customized processing pipeline.

Note

This function will not be called if the Interest packet is satisfied with a cached Data packet.

Parameters
  • match – the matched node object of this node.

  • param – the parameters of the Interest packet.

  • app_param – the ApplicationParameters of the Interest packet.

  • raw_packet – the raw Interest packet.

async provide(match, content, **kwargs)

Produce an object corresponding to this node, and make all generated Data packets available. Specific node type can override this function to have customized processing pipeline. For example, a SegmentedNode can do segmentation here. By default it makes a Data packet out of content and put it into the cache.

Parameters
  • match – the matched node object of this node.

  • content – the content of the object.

  • kwargs – other arguments from user input.