-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
104 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# NDNph Examples | ||
|
||
This examples directory is to allow Arduino IDE to locate the unit tests. | ||
For examples on how to use NDNph, please see [esp8266ndn](https://github.com/yoursunny/esp8266ndn) library. | ||
This examples directory is to allow running unit tests in Arduino IDE. | ||
Examples on how to use NDNph in a program can be found in: | ||
|
||
* [../programs](programs) directory: NDNph on Linux | ||
* [esp8266ndn](https://github.com/yoursunny/esp8266ndn) library: NDNph on microcontrollers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
option('unittest', type: 'feature') | ||
option('programs', type: 'feature') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# NDNph Linux Examples | ||
|
||
This directory contains several self-contained programs using NDNph. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
executable('ndnph-pingclient', 'pingclient.cpp', dependencies: [lib_dep]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <NDNph-config.h> | ||
#include <NDNph.h> | ||
|
||
#include <cinttypes> | ||
#include <cstdio> | ||
#include <unistd.h> | ||
|
||
ndnph::UdpUnicastTransport transport; | ||
ndnph::Face face(transport); | ||
|
||
std::unique_ptr<ndnph::PingClient> client; | ||
|
||
static bool | ||
parseArgs(int argc, char** argv) | ||
{ | ||
int interval = 1000; | ||
|
||
int c; | ||
while ((c = getopt(argc, argv, "i:")) != -1) { | ||
switch (c) { | ||
case 'i': { | ||
interval = atoi(optarg); | ||
if (interval <= 0 || interval > 60000) { | ||
return false; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (argc - optind != 1) { | ||
return false; | ||
} | ||
const char* prefix = argv[optind]; | ||
|
||
static ndnph::StaticRegion<1024> prefixRegion; | ||
client.reset(new ndnph::PingClient(ndnph::Name::parse(prefixRegion, prefix), face, interval)); | ||
return true; | ||
} | ||
|
||
int | ||
main(int argc, char** argv) | ||
{ | ||
if (!parseArgs(argc, argv)) { | ||
fprintf(stderr, "ndnph-pingclient [-i INTERVAL] PREFIX\n" | ||
" PREFIX should have 'ping' suffix to interact with ndn-tools ndnpingserver\n" | ||
" INTERVAL must be between 1 and 60000 milliseconds\n" | ||
" INTERVAL should be no less than RTT, or all requests will timeout\n"); | ||
return 2; | ||
} | ||
|
||
transport.beginTunnel({ 127, 0, 0, 1 }); | ||
for (;;) { | ||
ndnph::port::Clock::sleep(1); | ||
face.loop(); | ||
|
||
static uint16_t i = 0; | ||
if (++i % 1024 == 0) { | ||
auto cnt = client->readCounters(); | ||
printf("%" PRIu32 "I %" PRIu32 "D\n", cnt.nTxInterests, cnt.nRxData); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters