{"id":13557908,"url":"https://github.com/named-data/ndn-pi","last_synced_at":"2025-04-03T12:31:19.339Z","repository":{"id":24486768,"uuid":"27891266","full_name":"named-data/ndn-pi","owner":"named-data","description":null,"archived":true,"fork":true,"pushed_at":"2015-07-17T19:00:24.000Z","size":799,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-04T08:36:49.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"remap/ndn-pi","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/named-data.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-11T20:55:39.000Z","updated_at":"2023-01-16T22:26:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/named-data/ndn-pi","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/named-data%2Fndn-pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/named-data","download_url":"https://codeload.github.com/named-data/ndn-pi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247002290,"owners_count":20867439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:04:36.930Z","updated_at":"2025-04-03T12:31:18.725Z","avatar_url":"https://github.com/named-data.png","language":"Python","readme":"Named Data Network Internet of Things Toolkit (NDN-IoTT)\n==========================\n\n Getting Started\n---------------------------------\n\nThe major components of this kit are:\n-\tPyNDN: a Python implementation of NDN\n-\tnfd: the NDN Forwarding Daemon, which manages connections (faces)\n-   nrd: the NDN Routing Daemon, which routes interests and data \n\nThere are other libraries included for further exploration of NDN:\n-   repo-ng: a data repository server\n-   ndn-cpp: C++ implementation of NDN\n-   ndn-cxx: C++ implementation of NDN with eXperimental eXtensions\n\n### Network Connectivity\n\nIn order to communicate using NDN, all devices, Raspberry Pi or otherwise, must be\nconnected to the same LAN. By default, Raspberry Pis are configured to create or join\na WiFi network named 'Raspi\\_NDN' if a wireless interface is available. \n\nThe default password for 'Raspi\\_NDN' is 'defaultpasswd'. It can be changed with the ndn-wifi-passwd tool,\nor by modifying /etc/hostapd/hostapd.conf and /etc/wpa_supplicant/wpa_supplicant.conf.\n\nAlternatively, you may connect your Raspberry Pis by Ethernet.    \n\n### Network Configuration\n\nIf you are using multiple Raspberry Pis, they must all be connected to the same network, whether by WiFi \nor Ethernet. This allows interests and data to be multicast to the other nodes over UDP. To set up multicast,\nyou must register your network an NDN multicast face.\n\nThere is an installed script, ndn-iot-start, that will start the NDN forwarder and router if they are not \nalready running, and automatically route traffic from your nodes to the multicast face. It assumes that your \nPis are connected to a WiFi network, using the 'wlan0' interface. If you are using a different interface, e.g.\n'eth0' for ethernet, you may run\n\n        ndn-iot-start -i eth0\n\nreplacing 'eth0' with the desired interface name. For a list of network interfaces on your Pi, run 'ifconfig'.\n\nIf you wish to configure routing yourself **(not recommended)**, see [below](#manually-configuring-routing).\n\n\n### Running Your Iot Nodes\n\nThe basic unit of the IoT toolkit network is a node. Nodes are virtual, in that one\nmachine may host multiple simple nodes instead of one multi-purpose node. Although the functions of a node are\ncompletely up to the user, we recommend using each node to group related commands. For example, a Raspberry Pi\nwith both LEDs and infrared sensors may run one node that responds to LED control commands, and another that \nreports proximity readings from the IR sensors.    \n\nThere is one special node type, the controller. Each network must have a controller. Its primary responsibilities \nare creating network certificates for all other nodes in the network, and maintaining a list of available \nservices. \n\nThe configuration for the controller consists of just the network name (default is '/home') and the controller name\n(default is 'controller'). The default configuration file can be in /home/pi/.ndn/controller.conf. To change controller settings, you\nmay edit this file, or run the included ndn-iot-controller script:\n\n        ndn-iot-controller \u003cnetwork-name\u003e \u003ccontroller-name\u003e\n\nWhen nodes other than the controller join the network, they must be added by the user, by providing a serial number and\nPIN. This prevents unknown machines from gaining access to protected network commands. Use the menu provided by the controller to pair the new\nnode by entering 'P'. You will be prompted for the serial, PIN and a new name for your node. After a few seconds, the node will \nfinish its setup handshake with the controller and be ready to interact with the other nodes. You can use 'D' for 'directory' to\nsee the commands available on the new node.\n\n**Note:** Although multiple nodes may run on a single Raspberry Pi, the traffic from three or more nodes slow nfd down\nconsiderably, depending on the model of the Pi.\n\n**Note:** The directory may not correctly reflect the presence of multiple nodes with the same name. This limitation should be fixed in later\nversions.\n\n### Examples\n\nhttps://github.com/remap/ndn-pi/releases contains an image for raspberry pi - not necessarily up to date w/ this repostitory - please update once installed. \n\nThis toolkit contains three examples that demonstrate common node and network setups.\n-\tled\\_control:\tControl LEDs connected to the general purpose input/output (GPIO) pins over the network\n-\thdmi\\_cec: \tTurn a CEC-enabled device on or off depending on room occupancy\n-\tcontent\\_store: Save device statistics in a MemoryContentCache object for later analysis or logging \n\nTry running these examples and going through the tutorial [TUTORIAL.md](TUTORIAL.md) to learn how nodes work together.\n\n**Note: In order to access the GPIO pins, an IotNode must be run as root.**\n\n### Manually configuring routing\n\nIt is recommended that you use the included script, ndn-iot-start, but you can manually set up routing on your nodes with the following\nsteps.\n\n1. Ensure that the Raspberry Pi is connected to the network (wired or wireless) that will host your IoT network.\n\n2. Start the NDN forwarder and router by running\n        \n        nfd-start\n\n3. Tell the forwarder to route network traffic to the multicast face.\n If you are using WiFi only with your Raspberry Pi, the multicast face will typically have faceid 2. Otherwise, \n you will need to use the 'nfd-status' command to determine the correct face to register. Run\n\n        nfd-status -f\n\n and look for lines containing `remote=udp4://224.0.23.170:56363`. Find the faceid\n that contains an IP address on the IoT network. For example, if your nodes are all on a WiFi network, and your\n WiFi IP address is 192.168.16.7, you may find a line that reads\n\n        faceid=3 remote=udp4://224.0.23.170:56363 local=udp4://192.168.16.7:56356 ...\n\n4. Tell the forwarder to route traffic to the face you discovered in *3*.\n\n        nfdc-register / \u003cfaceid\u003e\n\n\nWriting IoT Nodes\n----------------\n\n\n### Provided Classes\nThere are several classes provided as part of the Internet of Things toolkit for NDN. \n#### IotNode\n\nNodes in your network will generally be subclasses of IotNode. \n\nThe most important method for customizing nodes is `addCommand`:\n\n```python\n    def addCommand(suffix, func, keywords, isSigned)\n```\n This is used to register your custom interest handling methods. The parameters are:\n - `suffix`: An NDN name that will be added to the node prefix to form the full command name.\n - `func`: A function that is called whenever the node receives an interest matching the suffix. The\n    function must take an Interest object and return a Data object:\n\n     ```python\n         # returns pyndn.Data or None\n         def handlerFunction(interest):\n             dataName = Name(interest.getName())\n             # ... do some processing based on the interest\n             # return a Data object or the interest will time out\n             response = Data(dataName)\n             response.setContent('Done')\n             return response\n     ```\n     Note that the sender of the interest will not receive your reply if the name of the data object does not match\n     the interest name. That is, you may append components to `dataName`, but not remove them. You may also return `None`,\n     which will cause the interest to time out.\n\n - `keywords`: A list of strings. The controller groups together all commands that share a keyword, so that other nodes\n     can search for a particular capability, service, sensor type, etc. You are free to define as many keywords as you like,\n     and their meaning is mainly application-dependent.\n - `isSigned`: By default, this is set to `False`. Setting this to `True` will allow only devices who are part of your network to\n     invoke the command, by signing their command interests.\n\nBesides adding methods for interest handling with `addCommand`, nodes can be further customized by overriding the\nfollowing methods:\n\n* setupComplete \n```python\n    def setupComplete(self)\n```\n  This method does nothing by default. It is called once the node has received its network\ncertificate from the controller and sent its capabilities list. This is the recommended\nplace for customized node behavior, e.g. searching for other nodes, scheduling tasks,\nsetting up custom callbacks.\n  \n* unknownCommandResponse\n```python\n    #returns pyndn.Data or None\n    def unknownCommandResponse(self, interest)\n```\n   By default, this method composes an error message and adds 'unknown' to the end of the\ninterest name. You may return `None` to silently ignore the unknown interest, or perform\nyour own specialized handling of the interest and return a Data packet.\n\n* verificationFailed\n```python\n    def verificationFailed(self, dataOrInterest)\n```\n   Called when a command interest fails verification. The most common reasons for failing verification are invalid signatures, \nand unsigned interests being sent when signed interests are expected. The default implementation logs the failure.\n\n* getSerial\n```python\n    def getSerial(self)\n```\n   Reads the Raspberry Pi serial number from /proc/cpuinfo. You may override this to provide some other unique id for your\nRaspberry Pis or even individual IotNodes.\n\n------\n\nThe remaining classes do not need to be subclassed, and it is not recommended that you modify them\n before you are comfortable with the toolkit and with  NDN security management. For more information, \nsee [NDN Resources](#ndn-resources).\n\n#### IoT Network Classes\n\n* BaseNode\n* IotController\n* IotConsole\n\n#### Security Classes\n* HmacHelper\n* IotPolicyManager\n* IotIdentityManager\n* IotIdentityStorage\n* IotPrivateKeyStorage\n\nNDN Resources\n-----------------\n\n* [NDN Common Client Libraries](http://named-data.net/doc/ndn-ccl-api/) for documentation of the classes available in PyNDN\n* [ndn-cxx wiki](http://redmine.named-data.net/projects/ndn-cxx/wiki) for security information\n* [NFD wiki](http://redmine.named-data.net/projects/nfd/wiki) for more on the internals of NDN packets and forwarding\n\n","funding_links":[],"categories":["Python","others"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamed-data%2Fndn-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamed-data%2Fndn-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamed-data%2Fndn-pi/lists"}