Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b02ecf0
waf working fine
dulalsaurab Mar 30, 2020
1ba7c94
build fine, compilation fails
dulalsaurab Mar 31, 2020
0303200
Update consumer.cpp
dulalsaurab Mar 31, 2020
7c3ef04
compilation and installation working
dulalsaurab Mar 31, 2020
a3582bd
producer receiving interest
dulalsaurab Apr 1, 2020
3b4d0ba
stuck on app crashing
dulalsaurab Apr 2, 2020
dd62698
fix app crashing, data was not signed
dulalsaurab Apr 2, 2020
3180bc4
basic producer consumer working fine
dulalsaurab Apr 3, 2020
aede771
working on tlv
dulalsaurab Apr 5, 2020
0f53005
tlv working fine
dulalsaurab Apr 6, 2020
b1747aa
some problem with tlv
dulalsaurab Apr 7, 2020
cd5c9cb
tlv working fine, chronosync not
dulalsaurab Apr 7, 2020
d00eef9
chronosync stil not working
dulalsaurab Apr 7, 2020
73a74d3
latest code:
dulalsaurab Apr 8, 2020
77380a6
commit with seperate producer and consumer API
dulalsaurab Apr 9, 2020
4554ddb
discovery flow diagram
dulalsaurab Apr 24, 2020
26a8ab2
Update service_discovery.drawio
dulalsaurab Apr 24, 2020
60fb747
Create sequence_diagram_big.uml
dulalsaurab Apr 24, 2020
8c6f79a
Create seq_diagram_small.uml
dulalsaurab Apr 24, 2020
7f76944
added sequence diagram
dulalsaurab Apr 26, 2020
91fb52a
Added Directory Service.drawio
dulalsaurab Apr 28, 2020
0db4156
code clealing
dulalsaurab Apr 28, 2020
58143fe
Merge branch 'master' of https://github.com/dulalsaurab/NDN-SD
dulalsaurab Apr 28, 2020
f24d81f
Update service_discovery.drawio
dulalsaurab Apr 30, 2020
99862fc
remove the deamon part
dulalsaurab Apr 30, 2020
b7e80b0
final commit
dulalsaurab Apr 30, 2020
18562a7
revised
dulalsaurab Apr 30, 2020
36e8e75
revised
dulalsaurab Apr 30, 2020
442a5e5
added some more figures
dulalsaurab Apr 30, 2020
77ebb31
added data hierarchy and edited previous diagrams
dulalsaurab May 13, 2020
3d6d745
complete some diagrams
dulalsaurab May 13, 2020
3990f1b
some update
dulalsaurab May 13, 2020
7a4ecf7
included ndn-lite namespace design
dulalsaurab May 15, 2020
86fbcc8
Simplified interface, added service update feature and many more
dulalsaurab May 22, 2020
79ca75e
Merge pull request #1 from dulalsaurab/file-op
dulalsaurab May 22, 2020
fb6b721
every parts are wroking, implemented ndnsd-tool completly and also th…
dulalsaurab May 23, 2020
8a5ca07
every parts are wroking, implemented ndnsd-tool completly and also th…
dulalsaurab Mar 30, 2020
d2870d0
fix service status bug
dulalsaurab May 29, 2020
b8588c2
add option class
dulalsaurab Jun 3, 2020
3a9b494
every parts are wroking, implemented ndnsd-tool completly and also th…
dulalsaurab Mar 30, 2020
818c485
code refactor
dulalsaurab Jun 3, 2020
1a9790b
Merge branch 'local' of https://github.com/dulalsaurab/NDN-SD into local
dulalsaurab Jun 3, 2020
40e9faa
code refactor
dulalsaurab Jun 3, 2020
8cc9bd6
Create README.md
dulalsaurab Jun 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ __pycache__/
*.py[cod]

# Other
/VERSION
/VERSION


RESOURCES/
thesis/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# NDNSD
NDN Service Discovery
1 change: 1 addition & 0 deletions docs/Directory Service.drawio
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">7Vxbb6s4E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eycawrk6eKnhE50+rBgtUDymzc+ETr6SQZlZx4pjBXSkeqhnXNEBgmZnu2toIAKwDnY+BM2CGsD0zcFhtfG4mbh8FQeXY4rn/VmmbqyDQrMUB0ib4qsZCEWMJxNXf55hKwPwmx1dEqVFkqEx7iezjkte+f4DVMg5C+OtvDjbSK4jYWgdxfLSpPhGCnLLdEtvop5m12t/pZD/R5aysFzD7hAks/2WGANIErO6iytxUXtT5DofX+I1xzxNTHGHK0luqxS/VnNh3d7PTVBgMkHA4hyzRDgxKmg1QIdBTqTPBMwzfH4juV/toFtG6H03FL8ltx09Tvkjqatl41WaKjhujh0tOYkRCHhKB6+s2wO6mI1Fa1PQjuwKSbIHCZlnlWa9SOaScwJUn+4bk/X50GqEwDBPHILgupbkx4cJbJ8JOPK0Xv9Ke5ptF+6yuTMx0uJXsqvzhMqmBLMJb0Vtk86ARjwor5yefJjCM/Px7f/w8=</diagram></mxfile>
29 changes: 29 additions & 0 deletions docs/seq_diagram_small.uml
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
36 changes: 36 additions & 0 deletions docs/sequence_diagram_big.uml
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
40 changes: 40 additions & 0 deletions docs/sequence_diagram_ndnsd_psync.uml
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
133 changes: 130 additions & 3 deletions examples/consumer.cpp
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;
Copy link
Collaborator

@agawande agawande May 31, 2020

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.

}
}

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;
Copy link
Collaborator

@agawande agawande Jun 4, 2020

Choose a reason for hiding this comment

The 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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems complicated for only two things? Maybe have an Options class.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also TODO, my new changes however have the options class.

Copy link
Collaborator

@agawande agawande Jun 4, 2020

Choose a reason for hiding this comment

The 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;
Copy link
Collaborator

@agawande agawande Jun 4, 2020

Choose a reason for hiding this comment

The 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) {
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log something here?

}
81 changes: 81 additions & 0 deletions examples/producer.cpp
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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before <

#include <list>
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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());
}
}
12 changes: 12 additions & 0 deletions examples/wscript
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')
Loading