-
Notifications
You must be signed in to change notification settings - Fork 2
every parts are wroking, implemented ndnsd-tool completly and also th… #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: test
Are you sure you want to change the base?
Changes from all commits
b02ecf0
1ba7c94
0303200
7c3ef04
a3582bd
3b4d0ba
dd62698
3180bc4
aede771
0f53005
b1747aa
cd5c9cb
d00eef9
73a74d3
77380a6
4554ddb
26a8ab2
60fb747
8c6f79a
7f76944
91fb52a
0db4156
58143fe
f24d81f
99862fc
b7e80b0
18562a7
36e8e75
442a5e5
77ebb31
3d6d745
3990f1b
7a4ecf7
86fbcc8
79ca75e
fb6b721
8a5ca07
d2870d0
b8588c2
3a9b494
818c485
1a9790b
40e9faa
8cc9bd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,4 +29,8 @@ __pycache__/ | |
| *.py[cod] | ||
|
|
||
| # Other | ||
| /VERSION | ||
| /VERSION | ||
|
|
||
|
|
||
| RESOURCES/ | ||
| thesis/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # NDNSD | ||
| NDN Service Discovery |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <mxfile host="app.diagrams.net" modified="2020-04-28T18:52:05.325Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36" etag="GbPo3MfWbHfdJnHgaSCE" version="13.0.2" type="github"><diagram id="_BzWF5qOBLh8jlFu-Lp9" name="Page-1">7Vxbb6s4EP41kXYfgnzBQB6b3lY62qNKXWm7jwTcBC0BDpA22V+/doAAxgSacGnT9KV4ABPP99kzHo89wbfr7WNoBqs/fZu6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bh8FQeXY4rn/VmmbqyDQrMUB0ib4qsZCEWMJxNXf55hKwPwmx1dEqVFkqEx7iezjkte+f4DVMg5C+OtvDjbSK4jYWgdxfLSpPhGCnLLdEtvop5m12t/pZD/R5aysFzD7hAks/2WGANIErO6iytxUXtT5DofX+I1xzxNTHGHK0luqxS/VnNh3d7PTVBgMkHA4hyzRDgxKmg1QIdBTqTPBMwzfH4juV/toFtG6H03FL8ltx09Tvkjqatl41WaKjhujh0tOYkRCHhKB6+s2wO6mI1Fa1PQjuwKSbIHCZlnlWa9SOaScwJUn+4bk/X50GqEwDBPHILgupbkx4cJbJ8JOPK0Xv9Ke5ptF+6yuTMx0uJXsqvzhMqmBLMJb0Vtk86ARjwor5yefJjCM/Px7f/w8=</diagram></mxfile> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| @startuml | ||
| participant "Consumer \n (C)" as C | ||
| participant "ndnsd \n (d1)" as d1 | ||
| participant "ndnsd \n (d2)" as d2 | ||
| participant "Producer \n (P)" as P | ||
|
|
||
| skinparam SequenceMessageAlign center | ||
| skinparam style strictuml | ||
|
|
||
| P -> d2: publish service \n (type: printers, \n name: printer1 etc) | ||
| d2 -> P: status code \n (success, failed) | ||
| C -> d1: request service \n (e.g. printers) | ||
| d1 -> d1: Get service names \n (e.g. /printer1) via sync | ||
|
|
||
| d1 -> d2: Interest (**I**): /printer1 | ||
|
|
||
| note over d2 | ||
| send NACK if | ||
| service has expired | ||
| end note | ||
|
|
||
| d2 -> d1: Application NACK | ||
| note over d2 | ||
| else send data | ||
| end note | ||
|
|
||
| d2 -> d1: Data (**D**) : name = /printer1 \n content: "HP ledger jet" | ||
| d1 -> C: send response \n (service info/status) | ||
| @enduml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| @startuml | ||
| participant "Consumer \n (C)" as C | ||
| participant "NDNSD \n (d1)" as d1 | ||
| participant "NDNSD \n (d2)" as d2 | ||
| participant "Producer \n (P)" as P | ||
|
|
||
| skinparam SequenceMessageAlign center | ||
| skinparam style strictuml | ||
|
|
||
| P -> d2: publish service \n (type: printers, \n name: printer1 etc) | ||
| d2 -> P: status code | ||
| d2<--] : publish service "printer2" \n some other producer | ||
| C -> d1: request service \n (e.g. printers) | ||
| d1 -> d1: Get service names (/printer1, /printer2) via sync | ||
|
|
||
| d1 -> d2 : iteratively fetch service info | ||
| loop each for service name | ||
| d1 -> d2: **I1:** /printer1, **I2:** /printer2 | ||
| end | ||
|
|
||
| note over d2 | ||
| send NACK if | ||
| service has expired | ||
| end note | ||
|
|
||
| d2 -> d1: NACK | ||
| note over d2 | ||
| else send data | ||
| end note | ||
|
|
||
| d2 -> d1: Data (**D2**) : name = /printer1 \n content: "HP ledger jet" | ||
| d2 -> d1: Data (**D2**) : name = /printer2 \n content: "HP jet 400" | ||
|
|
||
| d1 -> C: send D1 | ||
| d1 -> C: send D2 | ||
| @enduml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| @startuml | ||
| participant "ndnsd \n (d1)" as d1 | ||
| participant "sync \n (s1)" as s1 | ||
| participant "sync \n (s2)" as s2 | ||
| participant "ndnsd \n (d2)" as d2 | ||
|
|
||
|
|
||
| skinparam SequenceMessageAlign center | ||
| skinparam style strictuml | ||
|
|
||
| note over s1,s2 | ||
| Send periodic sync interest | ||
| end note | ||
| s1 -> s2: Sync interest: /<sync-prefix>/IBF1 | ||
| s2 -> s1: Sync interest: /<sync-prefix>/IBF1 | ||
|
|
||
| note over d1 | ||
| Advertise service: | ||
| /printer1/1 | ||
| end note | ||
| d1 -> s1: p: /printer1/1 | ||
|
|
||
| note over s1 | ||
| Publish service: /printer1/1 | ||
| insert into IBF1, get IBF2 | ||
| Answer pending interest | ||
| end note | ||
| s1 -> s2: Sync Data: /<sync-prefix>/IBF1/IBF2 \n content: /printer/1 | ||
| s1 -> s2: Sync interest: /<sync-prefix>/IBF2 | ||
| s1 -> d1: Callback, \n publish status | ||
|
|
||
| note over s2 | ||
| Insert /printer/1 | ||
| to IBF1 and get IBF2 | ||
| end note | ||
| s2 -> d2: Update callback \n to ndnsd | ||
| note over s1,s2 | ||
| Send periodic sync interest | ||
| end note | ||
| @enduml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,140 @@ | ||
| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | ||
| /* | ||
| * Copyright (c) 2014-2020, The University of Memphis | ||
| * | ||
| * This file is part of NDNSD. | ||
| * Author: Saurab Dulal (sdulal@memphis.edu) | ||
| * | ||
| * NDNSD is free software: you can redistribute it and/or modify it under the terms | ||
| * of the GNU Lesser General Public License as published by the Free Software Foundation, | ||
| * either version 3 of the License, or (at your option) any later version. | ||
| * | ||
| * NDNSD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
| * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
| * PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along with | ||
| * NDNSD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. | ||
| **/ | ||
|
|
||
| #include "ndnsd/discovery/service-discovery.hpp" | ||
| #include <ndn-cxx/util/logger.hpp> | ||
|
|
||
| #include<iostream> | ||
| #include <list> | ||
|
|
||
| #include <boost/program_options/options_description.hpp> | ||
| #include <boost/program_options/variables_map.hpp> | ||
| #include <boost/program_options/parsers.hpp> | ||
|
|
||
| class consumer | ||
| NDN_LOG_INIT(ndnsd.examples.ConsumerApp); | ||
|
|
||
| static void | ||
| usage(const boost::program_options::options_description& options) | ||
| { | ||
| std::cout << "Usage: ndnsd-consumer [options] e.g. printer \n" | ||
| << options; | ||
| exit(2); | ||
| } | ||
|
|
||
| }; | ||
| class Consumer | ||
| { | ||
| public: | ||
| Consumer(const ndn::Name& serviceName, const std::map<char, uint8_t>& pFlags) | ||
| : m_serviceDiscovery(serviceName, pFlags, std::bind(&Consumer::processCallback, this, _1)) | ||
| { | ||
| } | ||
|
|
||
| void | ||
| execute () | ||
| { | ||
| // process and handle request | ||
| m_serviceDiscovery.consumerHandler(); | ||
| } | ||
|
|
||
| private: | ||
| void | ||
| processCallback(const ndnsd::discovery::Reply& callback) | ||
| { | ||
| NDN_LOG_INFO("Service info received"); | ||
| auto status = (callback.status == ndnsd::discovery::ACTIVE)? "ACTIVE": "EXPIRED"; | ||
| std::cout << "Status: " << status << std::endl; | ||
| for (const auto& item : callback.serviceDetails) | ||
| { | ||
| std::cout << item.first << ": " << item.second << std::endl; | ||
| } | ||
| } | ||
|
|
||
| private: | ||
| ndnsd::discovery::ServiceDiscovery m_serviceDiscovery; | ||
|
|
||
| }; | ||
|
|
||
| int main() | ||
| int | ||
| main(int argc, char* argv[]) | ||
| { | ||
| std::string serviceName; | ||
| int contFlag = -1; | ||
|
|
||
| namespace po = boost::program_options; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why use boost::program_options here instead of just usual c++? |
||
| po::options_description visibleOptDesc("Options"); | ||
|
|
||
| visibleOptDesc.add_options() | ||
| ("help,h", "print this message and exit") | ||
| ("serviceName,s", po::value<std::string>(&serviceName)->required(), "Service name to fetch service info") | ||
| ("continuous,c", po::value<int>(&contFlag), "continuous discovery, 1 for true 0 for false") | ||
| ; | ||
|
|
||
| try | ||
| { | ||
| po::variables_map optVm; | ||
| po::store(po::parse_command_line(argc, argv, visibleOptDesc), optVm); | ||
| po::notify(optVm); | ||
|
|
||
| if (optVm.count("continuous")) { | ||
| if (contFlag != ndnsd::discovery::OPTIONAL and contFlag != ndnsd::discovery::REQUIRED) | ||
| { | ||
| std::cout << "'c' must be either '0' or '1', default i.e. '0' will be used" << std::endl; | ||
| } | ||
| } | ||
| else | ||
| contFlag = 0; | ||
|
|
||
| if (optVm.count("serviceName")) { | ||
| if (serviceName.empty()) | ||
| { | ||
| std::cerr << "ERROR: serviceName cannot be empty" << std::endl; | ||
| usage(visibleOptDesc); | ||
| } | ||
| } | ||
|
|
||
| } | ||
| catch (const po::error& e) { | ||
| std::cerr << "ERROR: " << e.what() << std::endl; | ||
| usage(visibleOptDesc); | ||
| } | ||
| // TODO: protocol shouldn't be hard-coded. | ||
| std::map<char, uint8_t> flags; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems complicated for only two things? Maybe have an Options class.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also TODO, my new changes however have the options class.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I meant was to replay this std::map with an options class such that you pass that to your discovery stuff. Where are the new changes? |
||
| flags.insert(std::pair<char, uint8_t>('p', ndnsd::SYNC_PROTOCOL_PSYNC)); //protocol choice | ||
| flags.insert(std::pair<char, uint8_t>('t', ndnsd::discovery::CONSUMER)); //type producer: 1 | ||
| flags.insert(std::pair<char, uint8_t>('c', contFlag)); | ||
|
|
||
| try | ||
| { | ||
| std::cout << "Fetching service info for: " << serviceName << std::endl; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant? |
||
| NDN_LOG_INFO("Fetching service info for: " << serviceName); | ||
| Consumer consumer(serviceName, flags); | ||
| consumer.execute(); | ||
| } | ||
| catch (const std::exception& e) { | ||
| std::cerr << "ERROR: " << e.what() << std::endl; | ||
| NDN_LOG_ERROR("Cannot execute consumer, try again later: " << e.what()); | ||
| } | ||
|
|
||
| try { | ||
| Consumer consumer(argv[1], flags); | ||
| consumer.execute(); | ||
| } | ||
| catch (const std::exception& e) { | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log something here? |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | ||
| /* | ||
| * Copyright (c) 2014-2020, The University of Memphis | ||
| * | ||
| * This file is part of NDNSD. | ||
| * Author: Saurab Dulal (sdulal@memphis.edu) | ||
| * | ||
| * NDNSD is free software: you can redistribute it and/or modify it under the terms | ||
| * of the GNU Lesser General Public License as published by the Free Software Foundation, | ||
| * either version 3 of the License, or (at your option) any later version. | ||
| * | ||
| * NDNSD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
| * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
| * PURPOSE. See the GNU Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public License along with | ||
| * NDNSD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. | ||
| **/ | ||
|
|
||
| #include "ndnsd/discovery/service-discovery.hpp" | ||
| #include <ndn-cxx/util/logger.hpp> | ||
|
|
||
| #include<iostream> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space before < |
||
| #include <list> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is list used? |
||
|
|
||
| NDN_LOG_INIT(ndnsd.examples.ProducerApp); | ||
|
|
||
| inline bool | ||
| isFile(const std::string& fileName) | ||
| { | ||
| return boost::filesystem::exists(fileName); | ||
| } | ||
|
|
||
| class Producer | ||
| { | ||
| public: | ||
|
|
||
| Producer(const std::string& filename, const std::map<char, uint8_t>& pFlags) | ||
| : m_serviceDiscovery(filename, pFlags, std::bind(&Producer::processCallback, this, _1)) | ||
| { | ||
| } | ||
| void | ||
| execute () | ||
| { | ||
| m_serviceDiscovery.producerHandler(); | ||
| } | ||
|
|
||
| private: | ||
| void | ||
| processCallback(const ndnsd::discovery::Reply& callback) | ||
| { | ||
| NDN_LOG_INFO("Service publish callback received"); | ||
| auto status = (callback.status == ndnsd::discovery::ACTIVE)? "ACTIVE": "EXPIRED"; | ||
| std::cout << "\n Status: " << status << std::endl; | ||
| for (auto& item : callback.serviceDetails) | ||
| { | ||
| std::cout << item.first << ": " << item.second << std::endl; | ||
| } | ||
| } | ||
|
|
||
| private: | ||
| ndnsd::discovery::ServiceDiscovery m_serviceDiscovery; | ||
| }; | ||
|
|
||
| int | ||
| main(int argc, char* argv[]) | ||
| { | ||
| std::map<char, uint8_t> flags; | ||
| flags.insert(std::pair<char, uint8_t>('p', ndnsd::SYNC_PROTOCOL_PSYNC)); //protocol choice | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still hard coded protocol choice? |
||
| flags.insert(std::pair<char, uint8_t>('t', ndnsd::discovery::PRODUCER)); //type producer: 1 | ||
|
|
||
| try { | ||
| NDN_LOG_INFO("Starting producer application"); | ||
| Producer producer(argv[1], flags); | ||
| producer.execute(); | ||
| } | ||
| catch (const std::exception& e) { | ||
| std::cout << "Exception: " << e.what() << std::endl; | ||
| NDN_LOG_ERROR("Cannot execute producer, try again later: " << e.what()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- | ||
|
|
||
| top = '..' | ||
|
|
||
| def build(bld): | ||
| # List all .cpp files (whole example in one .cpp) | ||
| for ex in bld.path.ant_glob('*.cpp'): | ||
| name = ex.change_ext('').path_from(bld.path.get_bld()) | ||
| bld.program(name='example-%s' % name, | ||
| target='ndnsd-%s' % name, | ||
| source=[ex], | ||
| use='ndnsd') |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use ndn-cxx logger here too? So you get logs only when you want to.