Consumer Producer example on two containers - skoulouzis/ndn-with-docker GitHub Wiki
This is a simple test of the NFD.
Start docker containers
On the hosting node start NFD A:
sudo docker run --name nfd-A nfd
or:
sudo docker start nfd-A
On the hosting node start NFD B:
sudo docker run --name nfd-B nfd
or:
sudo docker start nfd-B
Get containers' IP addresses
For nfd-B on the hosting node type:
sudo docker inspect nfd-B | grep IPAddress
The output should look like this:
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.3",
"IPAddress": "172.17.0.3",
Connect containers
Log in nfd-A. From the hosting node type:
sudo docker exec -it nfd-A bash
Add to nfd-A a route to nfd-B. On nfd-A type:
nfdc face create udp://$nfd-B_IP
The output should look like this:
face-created id=260 local=udp4://172.17.0.2:6363 remote=udp4://172.17.0.3:6363 persistency=persistent reliability=off
Next, on nfd-A type:
nfdc route add /example udp://$nfd-B_IP
The output should look like this:
route-add-accepted prefix=/example nexthop=260 origin=static cost=0 flags=child-inherit expires=never
This means that nfd-B can send data to nfd-A. However, nfd-A cannot send data to nfd-B.
Send message
Log in nfd-B. On the hosting node type:
sudo docker exec -it nfd-B bash
Next, On nfd-B type:
/ndn-cxx/build/examples/producer
On nfd-A type:
/ndn-cxx/build/examples/consumer
The output should look like this:
Sending /example/testApp/randomData?ndn.MustBeFresh=1&ndn.InterestLifetime=2000
Name: /example/testApp/randomData/testApp/%FD%00%00%01at%F9Y%5B
MetaInfo: ContentType: 0, FreshnessPeriod: 10000 milliseconds
Content: (size: 11)
Signature: (type: SignatureSha256WithRsa, value_length: 256)
If no data are send from nfd-B you should see something like this
Sending /example/testApp/randomData?ndn.MustBeFresh=1&ndn.InterestLifetime=2000
received Nack with reason NoRoute for interest /example/testApp/randomData?ndn.MustBeFresh=1&ndn.InterestLifetime=2000&ndn.Nonce=2055367689