167 Commits
Author SHA1 Message Date
Saurab Dulal b2fea6d79f NLSR Release 0.5.0: Minor change to AUTHORS.md file
Change-Id: I79f62495583a57e24e1c589e80e47d0e1d8095e1
2019-02-24 15:53:00 -06:00
Saurab Dulal d3b60a8b24 Prepare release 0.5.0
Change-Id: I8ebb2f5779d7da0c0b6c2f11cc9c653e8d3b1d90
2019-02-23 17:34:26 -06:00
Davide Pesavento 0da3eab4da Add systemd unit file
Refs: #4594
Change-Id: I415bafa14902e9d43be4891f66349192e12b9166
2019-02-22 13:50:37 -06:00
dulalsaurab 82a34c2cd8 **breaking change** nlsr.conf: rename seq-dir as state-dir
update: conf file in seperate directory for runtime modification

refs:  #4823

Change-Id: I5378d831294814e382ad23a9e522d0b576180f20
2019-02-19 15:49:38 -06:00
Ashlesh Gawande 85998a1dc9 src: decouple classes from Nlsr object
refs: #1952, #2803, #3960, #4288

Change-Id: Ibe3ac3820f11e8107ee4b13e510d53c27467a6cb
2019-02-01 14:23:55 -06:00
Ashlesh Gawande 7e3f6d75c8 src: move and simplify canonize functionality to ConfFileProcessor
refs: #4817

Change-Id: I0a7f448f50994906d0403bcb97a3973dc1a25917
2019-02-01 11:54:48 -06:00
Davide Pesavento e3c741da9a main: fix error handling and normalize exit codes
Change-Id: I3b6d6dd1f5a8fac3ec4998bd81af80a232350337
2019-01-30 23:45:32 -05:00
Davide Pesavento 5859ed3dfb Use the official markdown version of the GPLv3
Change-Id: I5de645c2b29c29e2927e19b12831c0b336ad54b7
2019-01-29 19:49:09 -05:00
Davide Pesavento e556991595 build: various updates
* Upgrade waf to 2.0.14
 * Sync default compiler flags with ndn-cxx

Change-Id: I9e5bbbc7c13d1770e6ac0b0b5f5c0fbe17f89f23
2019-01-29 19:39:06 -05:00
Saurab Dulal 72b2b25cd2 route: remove redundant function
refs: #4811

Change-Id: I31b1031f57a344e7c3176b917ffbad2f6b2bd821
2019-01-25 05:06:50 -06:00
laqinfan 7c13ba5448 nlsrc: demarcate LS and HR routing table in dry run mode
refs: #4452

Change-Id: I522493e473810f90e4e982b35a58310154816cae
2019-01-22 21:47:51 -06:00
Junxiao Shi 008c9b18a5 tests: set CanBePrefix in test suites
refs #4581

Change-Id: Ia53e2a865dbc8a422626640d8d7f3878e49066ba
2019-01-13 23:15:56 +00:00
Saurab Dulal 7526cee087 update: Add/delete prefix to the conf file
refs: #4303

Change-Id: I401885bf76be90a5076365eebc311275461813c4
2019-01-08 20:56:09 -06:00
Ashlesh Gawande 939b6f8652 src: use psync::SegmentPublisher and fix proccessing of interests w/ segments
refs: #4784, #4760

Change-Id: Ia017a6f340e1cd35991068453c9da595c453ca1f
2018-12-22 15:45:50 -06:00
Ashlesh Gawande e5002b3fc4 fib: don't refresh neighbor router's FIB entry (it is already installed w/ expiry=never)
refs: #4799

Change-Id: Ib55687655ccd8673eeae14d8418e458ad8ab00aa
2018-12-21 12:18:49 -06:00
Ashlesh Gawande 32ec3fd51e communication: sync protocol adapater to add psync
refs: #4082

Change-Id: Ibe4649e709dfbc3cdc1f2afbfc4ff03f75a3f136
2018-12-10 10:38:41 -06:00
David Arjona 2fa23ea104 docs: Improving documentation for NLSR
Change-Id: Iada3c9bbc56b53fb66bfea1c99ef2204afaf9039
2018-12-07 12:29:20 -06:00
Ashlesh Gawande 744e481642 ci: enable leak sanitizer
src: fix memory leaks caused by segment fetcher

refs: #4682

Change-Id: I4fdf24f369e2d27845f1f6e6ca9978905110a024
2018-11-25 10:43:40 -08:00
ashiqopu 8433cfeace ci: install gcovr via apt
Change-Id: I0e24a2299c99d4e685a9bb5a1ddba34d06ba2f77
refs: #4771
2018-11-25 06:47:37 +00:00
David Arjona 2e6c8bb896 docs: A beginners' guide to installing and testing on Fedora
Change-Id: I2345fe8443981dab60782f8daa8c4ae0b107a1bf
2018-11-15 16:44:25 -06:00
Ashlesh Gawande 3494f7366a src: disallow interest loopbacks
refs: #4768

Change-Id: If5ec53fc9869b65e318c3eaf950708cfa36e658a
2018-11-06 17:30:40 -06:00
Ashlesh Gawande 05cb728c63 src+tools: use segment fetcher start
jenkins: re-compile ChronoSync on ndn-cxx change

refs: #4464

Change-Id: Ia627e00b8f13bad0068e213a6019f62a84cad41a
2018-09-25 17:55:43 -05:00
Ashlesh Gawande 057005460e hello-protocol: set canBePrefix to true
refs: #4691, #4679

Change-Id: I5f57d7bb6a75af074fc64206fe6061f2fc758b40
2018-08-28 11:13:28 -07:00
Ashlesh Gawande e8d8bd5276 adjacency-list: fix crash in equals operator
some minor code improvements

refs: #4705

Change-Id: I28805981a88a94c79f699956bb7e62a268d9ba49
2018-08-26 13:25:27 -05:00
Ashlesh Gawande 481010723b communication: use ChronoSync Logic instead of Socket
refs: #4623

Change-Id: I6950af9d92a254b4fe05f7570ab6bc8b8a9599c8
2018-06-08 13:12:04 -07:00
Davide Pesavento a08dc3f1f1 build: require gcc >= 5.3 and switch to C++14
Change-Id: I93c8fc238cc2654346bbc69a9d8ea83d1c0b099e
Refs: #3076, #4462
2018-06-06 16:27:47 -04:00
Saurab Dulal 301220346e docs: Prepare version 0.4.3 release notes
Change-Id: I0b3a6166eac489be67ea03ff69a13ffe35616f63
2018-05-21 12:54:11 -05:00
Ashlesh Gawande 8df15986ef tlv: avoid misaligned memory access
They cause unit test crashing on ARM platform.

refs: #4609

Change-Id: Ifdb0401529de48b5c08ebcf6938d80ba87ff883d
2018-05-19 22:21:25 -07:00
Ryan Wickman f3c79a6f87 src: make LSA's isEqualContent methods of type const
refs: #4137
Change-Id: Idb1cdea33d4efbc3af3c07d901a620d3ef253979
2018-05-10 20:15:01 -05:00
Ashlesh Gawande cba0ae2f56 **breaking** Change NLSR to nlsr for various prefixes
src: register router prefix to fix remote requests

refs: #4543

Change-Id: I698484318bf8e641f955ea40e6c51c6865cad8bf
2018-04-19 14:34:29 -05:00
Eric Newberry f1a8ee66de build: find Boost lib architecture automatically
refs #4573

Change-Id: I383f821bc651926ba5d2ed830b20dd3116e8a3fc
2018-04-07 16:38:47 -07:00
Ashlesh Gawande d65786a0ea src/lsa-segment-storage: fix convergence w/o content store
refs: #4430

Change-Id: I5124e9fd49bd9850c904c31d221b42b4249553a3
2018-04-02 22:55:17 -05:00
Ashlesh Gawande e6ba9158e0 Fix build with clang-5.0
refs: #4547

Change-Id: I7fd0411b3dc7c62651875aa035bbfb6ca269bf81
2018-03-30 16:20:27 -05:00
Eric Newberry aa41b04807 docs: disable sphinxcontrib-googleanalytics
refs #4553

Change-Id: I94529272787b0facd9370f9c6fca06435a636093
2018-03-26 15:16:43 -07:00
Alexander Afanasyev 67758b1fba build: update waf to version 2.0.6
Fix discovered build issues

Change-Id: I9a861c955283c1b20cc5065a4baa22bd7c2ab0c1
2018-03-11 12:17:41 -04:00
Ashlesh Gawande 350d58489b docs: Prepare version 0.4.2 release notes
Change-Id: I36780f66b803b6049e5399fde6e1a097c40a65b3
2018-03-05 12:04:31 -06:00
Ashlesh Gawande 8c6d8c831a lsa-segment-storage: fix segfault in scheduled erase of lsa segment
refs: #4520

Change-Id: I597604b4be9e063a08ff5031faa8d305408b676d
2018-03-01 12:54:15 -06:00
Ashlesh Gawande 0b27c1ff5c Update symlink to latest release notes
Change-Id: I0956f0be737af0b4d43810ff7c7c91fd89982c8a
2018-02-26 14:35:53 -06:00
Ashlesh Gawande 39cf81a110 docs: Prepare version 0.4.1 release notes
Change-Id: I91db5b65dfe06187ddb0e9df32905dc2c8797ddc
2018-02-22 17:37:51 -06:00
Alexander Afanasyev b0bf8df1bd Hard-code fixed session name for ChronoSync sockets
This commit reverts behavior of the hard-coded fixed session name that
was feature in old nsync-based implementation.

Also fixing an initialized configuration parameter.

refs: #4513

Change-Id: I44559e729c949f90511a5c53282fd4a240356157
2018-02-21 13:49:40 -08:00
laqinfan a073e2e23e publisher: fix encoding bug in routing table publisher
refs: #4453

Change-Id: I03e819e963f0957f3d40ff25e378f2b9b17357b7
2018-02-16 12:30:36 +00:00
Saurab Dulal 9da6aa7fce Routing: Print labels on adjacency matrix when logging
refs: #2045

Change-Id: I0fa36eed1a6afdca6f135c80a20aa062a5e8cd63
2018-02-15 12:20:15 -08:00
Ashlesh Gawande 304bebf64f Remove some unused functions
Change-Id: Ic99891d2037e928ac927651607559e7660bd677f
2018-02-15 12:41:43 -06:00
Ashlesh Gawande 982a58fae5 Add version number after ChronoSync prefix
Change-Id: I5c6782461e6c00129850ab00df407a1f59f4353b
2018-02-14 17:39:12 -06:00
Alexander Afanasyev 7afe22f410 Output extended diagnostic information on fatal errors
Change-Id: I36bdd60df742837aeffb16ab78a93b93d5b24887
2018-02-13 16:17:40 -05:00
Ashlesh Gawande f7da9c542c conf: make ChronoSync's sync interest lifetime configurable
refs: #4490

Change-Id: Id3eabeed1049d1208ba49c47206f73f798f37a35
2018-02-09 15:24:47 -06:00
Muktadir Chowdhury c3ea26f000 Serve other routers' certificate and LSA
refs #4448, #4430

Change-Id: I3a9a9ae613770774be06effe26dfb866ea49f05a
2018-01-29 23:23:19 +00:00
Ashlesh Gawande 0d2c38299e Change certificate validity period to 1 year
Change certificate freshness period to 1 year
Catch Malformed URI error

refs: #4473, #4474

Change-Id: Ia341cba1e72b541c13eb480dfa53f26f89d854fa
2018-01-25 10:34:01 -06:00
Nick Gordon 563611eb20 communication: improve constness
Change-Id: Iabc5093d3c8e84540ddef4f6f2ff768dd9f3d0da
refs: #4472
2018-01-23 14:08:26 -06:00
Nick Gordon af87575012 nlsr: refactor equality operator
Change-Id: Iaaef9511e6569d597afcc5fa083b98ce86d8f78d
refs: #4127
2018-01-23 11:36:54 -08:00
Nick Gordon 4964870e9d src: improve constness
Change-Id: I8b3084e311642578628ea7c1017dc2a58979ab83
refs: #4472
2018-01-23 08:45:37 -08:00
dmcoomes b2ef6adbd3 Remove log4cxx from Jenkins
refs: #3949

Change-Id: I7ff3da932fe8a011aa391766c501b475118eaea5
2018-01-22 16:22:50 -06:00
dmcoomes cf8d0eda75 Use ndn-cxx logging facility
refs: #3949

Change-Id: I5d0931c3576c88e0c2fa52bdd0a716946400e0bc
2018-01-22 13:24:35 -06:00
Davide Pesavento 437adfeed6 ci: expand Travis-CI build matrix
Change-Id: I6ef5a461eaed9d66bed12189cde28cab30e55df8
2018-01-11 18:57:47 -05:00
laqinfan 357318540d publisher: implement routing table dataset publisher
refs: #3631, #3634

Change-Id: I7e961fdd0857690bee65d2bdfa4cf3de90ccac06
2018-01-11 12:08:27 +00:00
Ashlesh Gawande 14ab329746 Fix NLSR not converging without content store
refs: #4430

Change-Id: I8bff1facf528a07a3c2d90e8f512128c0420d799
2017-12-29 12:03:26 -06:00
Nick Gordon ed473c6c47 docs: mention the contributing guide
Change-Id: Ie14448f2fdf228db380f8332bee3dbe0b769fa50
refs: #4412
2017-12-21 14:02:30 -06:00
laqinfan ac4b65664f communication: fix dry-run mode not working
refs: #4394

Change-Id: I6b7eba5e36af307b9da6b5c198d44f9915db6358
2017-12-08 11:33:52 +00:00
Ashlesh Gawande d88c1dfdc2 ci+docs: remove all references to cryptopp/crypto++
Also update COPYING

refs: #3946

Change-Id: I87ded823f806857bb27079648e51619bb9dde6bc
2017-12-05 16:37:22 -06:00
Ashlesh Gawande 9e955bcec7 docs: Prepare version 0.4.0 release notes
Split the long release notes similar to NFD

Change-Id: If5ce5247bf74a4e402a33d92a35a686e7193dea1
2017-11-30 21:03:03 -06:00
Muktadir Chowdhury f04f98943d Convert to v2::security and adapt to ndn-cxx changes
Change-Id: I54f1b758cfb8f3f6cbc66a1aec5120ae1640b0ec
refs: #3964
2017-11-30 20:54:47 +00:00
Nick Gordon 2f62338d12 lsa: added noexcept and docs
Change-Id: Ic8c8566ced9654185a0619eca614ee1c6d108674
refs: #4354
2017-11-03 13:49:31 -05:00
Nick Gordon ae0a047c41 lsa: improved printing and logging
refs: #4354

Change-Id: I27cc99c6d01ba22668f4f56ad57b6f34f24f8af2
2017-11-02 13:55:56 -05:00
dmcoomes 5bcb39e255 rename log macros to comply with ISO C++ standard
refs: #4341

Change-Id: Idb05f59660f42c01a7bf014c6fff4125a28327f2
2017-11-01 09:36:53 -05:00
Nick Gordon 0fa4c77987 lsa: simplify initializeFromContent and improve naming
refs: #4354

Change-Id: I5ddd5a9f482f59e6ca52061ac92514feab8c3070
2017-10-30 17:09:24 -05:00
Nick Gordon 22cc1a8d17 lsa: simplified key getter
refs: #4354

Change-Id: Id886d41ff98530e1953066593640232d31b93b26
2017-10-27 10:18:57 -07:00
Nick Gordon 96861ca49c npl: npls more conveniently instantiable
NPLs can now be instantiated using brace-init lists, as well as by passing
any iterator-capable container.

refs: #4345

Change-Id: Ib43373d5899d0ac14861027c34431fa928eec191
2017-10-26 15:25:59 -07:00
Nick Gordon faf49f4c32 lsa: leverage class hierarchy when serializing.
refs: #4354

Change-Id: Ia3e79694c785b208184137d8ef0813629d61cc83
2017-10-26 11:08:25 -05:00
Nick Gordon 9212bd43bb lsa: make base class abstract
refs: #4353

Change-Id: If95c1689727f541c123623d21aec78ab8bdd58e6
2017-10-23 13:56:46 -05:00
Nick Gordon 727d4830d7 lsa: change type variable to enum class
Change-Id: I7fba951649771700ce6ccc4be7fb400546607e96
refs: #4340
2017-10-19 15:44:06 -07:00
Nick Gordon ff9a62713b style: made container APIs more consistent.
Change-Id: Ib4feedfc4c9fb497dfcd67e7e6a33ee03db58d7f
refs: #4337
2017-10-13 16:03:27 -07:00
Nick Gordon e18296c270 hello: move constructor definition to implementation file.
Change-Id: Ia176b5cad081a61368f45ac137dc6c9474101751
refs: #4334
2017-10-11 14:41:09 -07:00
Nick Gordon 2a1ac616b3 adjacency-list: improve constness of equality operator
refs: #4331

Change-Id: Ia57a82859abb2a32b22a7dbff471d1843d8237f0
2017-10-11 11:55:49 -07:00
dmcoomes a47255c2c5 docs: add commit ids for dependencies to README.md
refs: #4260

Change-Id: I096d5502a1cdc5fe712021fc0046d883a456173b
2017-10-04 11:24:48 -05:00
dmcoomes ffb62fa3fb docs: update authors
refs: #4231

Change-Id: Idbee3121d59d10ee96ff6b044cc55552f3b64c94
2017-09-29 10:29:17 -05:00
Nick Gordon 114537f6e0 publisher: simplified LSDB dataset interest handler.
refs: #4235

Change-Id: Ia3f606947884304e8b01211b5887ad62488f7167
2017-09-08 14:47:52 -07:00
Nick Gordon 922714a0d9 nlsr: Added a finally() to canonizeNeighborUris
Change-Id: I0046ae7a07be69f20a8f9d2b4acb33d8533a28e7
refs: #4128
2017-09-08 10:25:45 -07:00
Nick Gordon 5867b5233f fib: merged redundant functions
Change-Id: Iebec912fa7a3b8ab2cfe36835868dbdb068d7076
refs: #4105
2017-09-07 08:48:11 -07:00
Nick Gordon d40a588e25 routing: use unique_ptr for signal container
Change-Id: I1912f8630d0e26d8c25c2050208f6b8b0ffd9009
refs: #4268
2017-09-06 14:51:26 -07:00
Nick Gordon 8f23b5d58e sync: improved unit tests
refs: #4264

Change-Id: I981f3d8f653e4750ee6f9d77f2c89188f11d8ebb
2017-09-06 14:23:16 -07:00
Nick Gordon 9eac4d9830 sync: removed ref to lsdb.
Sync now emits to a signal whenever a new LSA is detected, and the LSDB
listens to this signal.  Sync consults a function object gotten at ctor time
to determine LSA newness.  This means Sync no longer needs a reference to
the LSDB, and LSA newness criteria can be freely manipulated.

Change-Id: Ifce3ebfc921ad846fcfa12d99c78f3b337180827
refs: #4264
2017-09-05 12:20:53 -07:00
Davide Pesavento 6ebfd7c182 build+ci: enable code-coverage reporting
This required changing the CI scripts to run the
unit tests against the debug version of NLSR.

Also sync default-compiler-flags.py with NFD.

Change-Id: I31f37e3dfef2c1237393512e0c238f5e6bcbe525
2017-08-31 13:49:13 -04:00
Nick Gordon b7b5839197 route: communicate routing changes using signals
The RoutingTable now has a signal that it emits upon finishing
calculation, which other modules can subscribe to. The NamePrefixTable
now references this emitted container to update its local copies of
routing information.

Change-Id: Id601776258ad0367cc47461ea8f86a710eada132
refs: #4249
2017-08-29 13:18:38 -07:00
Davide Pesavento 813df80e20 ci: sync CI scripts with NFD
Notable changes include:
  - support WAF_JOBS env var
  - use two parallel build jobs on Travis-CI
  - use "limited builds" for code-coverage and Travis-CI
  - upgrade Travis-CI osx from xcode8.2 to xcode8.3
  - enable ASan on Travis-CI

Change-Id: I4101499ebc590478d67ec8134c0395c4aafb8fb6
2017-08-26 17:06:00 -04:00
Davide Pesavento 0bd37314fe ci: speed up Travis-CI osx jobs by upgrading only the packages we need
Synchronize the rest of the file with NFD.

Change-Id: If2f5fba0eb614a881b51396b15a5a30e7939f728
2017-08-26 17:06:00 -04:00
Davide Pesavento 6a81b77260 ci: preserve PATH when running waf under sudo
Change-Id: I85bdc5b69de2c2c7b8c0dc5a7aa2927b495e2168
Refs: #4186
2017-08-26 17:06:00 -04:00
Nick Gordon c0c6bcf7e2 route: updates to name prefixes are more efficent.
With this change, only entries that have changed next-hops will
cause any change in the name prefix table.  Consequently, routing
table calculations no longer cause RIB registrations for unchanged
prefixes.  However, this is not a problem because FIB entries
refresh themselves.  This resulted in the removal of a test from the
TestNlsr suite.

refs: #2864

Change-Id: If28a04cb7bb47a3a6c32cd24578c68885d08d6b3
2017-08-24 16:54:39 -05:00
Nick Gordon 098aae410a tests: make LSDB tests more deterministic
TestLsdb/LsdbSync now iterates over all sent Interests to
check that any of them match, as opposed to checking
positionally, which cannot be guaranteed to pass.

Change-Id: Ib9e3a4b0aea4e1a4dd9f1c7e65d1b2a299863a9c
refs: #4257
2017-08-23 14:47:29 -07:00
Nick Gordon e40377d570 routing: improved routing map data structure.
Change-Id: I1cde5b2b9cffcec5cbfd78c5dd4262b5fb919a73
refs: #4240
2017-08-23 12:57:19 -05:00
Nick Gordon 7afcab4652 tests: make sync tests more deterministic
This change makes the UpdateForOther{LS,HR} tests more deterministic by
removing the temporal ordering requirement of sent interests.

Change-Id: Iceab5735baa2ff2fb97b18babfcf2bb32110a3c2
refs: #4253
2017-08-22 14:05:43 -07:00
Nick Gordon e98480b5d1 nlsr: removed references to ndn-cxx/common aliases and improved namespacing
Change-Id: I65e4691305b0157f334fc68d96998c119ef8b03b
refs: #3406
2017-08-22 13:37:21 -05:00
Nick Gordon d0a7df337f docs: wrote Doxygen comments for all files
refs: #4118

Change-Id: Ib0e7f1926cdabcca5aa401b59b24519412a099f7
2017-08-21 14:30:50 -07:00
Alejandro Gil Torres e0d2048d5f src: Implement packet statistics collection
refs: #2955, #2956

Change-Id: I57476a63562dbd378e566ad0280c89ccc5883e3e
2017-08-17 11:59:53 -07:00
Nick Gordon f14ec357d5 nlsr: Add support for sources to NamePrefixList
Added support for string sources to NamePrefixList entries.  Required was
some tweaking of the API, and refactoring usage around the codebase.

Change-Id: I44813e024a88dc1f591f427b0fad568a7d5353ab
refs: #4177
2017-08-16 15:00:14 -07:00
Davide Pesavento c58cc7f596 build+ci: enable AddressSanitizer and LeakSanitizer for unit tests
Refs: #2589, #4206

Change-Id: Ie9770134ff87fce438029b97c9ed61dbef3a71a3
2017-08-16 12:35:52 -07:00
Nick Gordon 22b5c957c0 routing: made map more container-agnostic
Change-Id: Ib18a41bac7627a9eb0bbafa6ccad0335d420dd68
refs: #4239
2017-08-15 09:06:28 -07:00
Ashlesh Gawande 90173ad966 Resolve ASan errors that will be thrown once it is turned on
Plus few minor spelling and code-style issues

refs: #4230

Change-Id: Ia665bab546a9628347af45836dcbe765dc91c54f
2017-08-14 10:54:15 -05:00
Nick Gordon 608061b95d tests: wrote select-cheapest-hop test.
Change-Id: I1eaed69675010bbf7b85221b72c4fcea71ebd9f0
refs: #4169
2017-08-11 10:38:40 -07:00
Ashlesh Gawande 793e8707a1 src: fix prefix advertise runtime error
Don't schedule Hello after receiving face changes in dataset,
let it be on its schedule. Also don't schedule routing calc (HR)
or AdjLsa (LS) let them be scheduled on Hello Data.

refs: #4215

Change-Id: I5c3881943f83b2f7683316fa3e22e6c280b6b64d
2017-08-10 16:21:34 -05:00
Laqin Fan 54a43f06e1 update: Refactor to use ndn-cxx dispatcher for prefix update/readvertise
refs: #3728

Change-Id: I3186433ed460850753f033a1d03fe27fd1fe889c
2017-08-04 12:46:50 -07:00
Ashlesh Gawande 820bb66350 src/lsdb: fix heap buffer overflow
refs: #4217

Change-Id: I902dfd7fcb856b5fd5cd285ef4d498956029848e
2017-08-03 16:14:19 -05:00
Ashlesh Gawande 9b71bbc970 wscript: install nlsr.conf as sample in the system
refs: #4197

Change-Id: If4fa9282f71661450950d8d6e44bf2ac4fe2bcee
2017-08-01 11:00:44 -07:00
Ashlesh Gawande 3909aa160a src: fix incorrect error on face-dataset-fetch-interval valid values
refs: #4211

Change-Id: I9ec04483a633ecf31797dd1637229d147d436d35
2017-07-31 12:30:13 -05:00
Nick Gordon d5c1a378d1 nlsr: discover Faces from NFD
refs: #2954

Change-Id: I072972d88bce0e1012e96f33577657048b7df1e1
2017-07-21 08:39:11 -07:00
Ashlesh Gawande f6bfb14def src/logger: use unix timestamp as default
refs: #4187

Change-Id: I235c1ba60d981b7c52d50b14b6fefafca049679a
2017-07-19 15:41:44 -05:00
laqinfan d22da51783 publisher: use ndn-cxx dispatcher for dataset publisher
Change-Id: I836a718ba40ff471bcdac7a7cc684c13914c4ea5
refs: #3728
2017-07-07 10:46:25 -05:00
Nick Gordon a75fdb27c5 build: fix build issues with pegged ndn-cxx
Change-Id: I0f000455d1eaf974d85ed76414af8710bc44dad4
2017-07-06 14:10:43 -05:00
laqinfan cd7ca05378 route: refactor Fib::removeOldNextHopsFromFibEntryAndNfd()
Change-Id: I6ef61fcec6b934c0238ecb697c14564c02cacfe2
refs: #3820
2017-06-28 08:45:13 -05:00
Muktadir R Chowdhury b00dc2acea Accommodate n-Dimensional HR coordinates
refs: #3751

Change-Id: Ib705b671daba56f58e09876a48d8b31649bd7ab1
2017-06-26 15:52:48 -05:00
Nick Gordon 0f1bf1dfcd Revert "sync: remove check-for-self in sync updates"
This reverts commit b23f279353.

Change-Id: I8630be544195a01e09b3a2e4d85d102ac00cfc72
refs: #4134
2017-06-22 13:47:55 -07:00
Ashlesh Gawande 8bfd124212 Use network name in sync prefix to avoid sync leaks from other networks
refs: #4101

Change-Id: I97d76d54571a124de33c6e62e07115c0df26882c
2017-06-22 09:15:27 -07:00
Ashlesh Gawande 7600c90882 Complete remaining changes for ChronoSync dependency issue
refs: #2400

Change-Id: If0cf9d3140f3ef65d86394fad3b6a6c7c58064f9
2017-06-21 14:25:03 -05:00
Nick Gordon e9733ed876 nlsr: refactor Adjacent to use FaceUri objects
Change-Id: Ib46f70570669c381572182eeea5c047a38a05104
refs: #4063
2017-06-20 15:02:55 -07:00
Nick Gordon b9e2c650e6 build: Fixed ChronoSync not being found on OS X.
Change-Id: I79dfa5bb8c25d6922c1e7b7529953fb2fb2fcae2
2017-06-20 13:12:02 -07:00
Nick Gordon 494de4033d nlsr: remove writeLog in NamePrefixList
Change-Id: Id54152684d1aa366b5eec8eeb79c046dedf6da7c
refs: #4131
2017-06-15 09:15:29 -07:00
Nick Gordon 56d1fae10a nlsr: implement NameLsa::isEqualContent
Change-Id: Ibf9021144f5ff253515875ac61de97740a1fecd7
refs: #2962
2017-06-15 09:15:24 -07:00
Nick Gordon adad2490e5 nlsr: LSA getData() now uses ostream instead of manually building the string
Change-Id: Ib4f6e27ccbe614140dbda63e6a5c7f4a78baedb7
refs: #2346
2017-06-13 12:15:43 -07:00
Nick Gordon b23f279353 sync: remove check-for-self in sync updates
Change-Id: Iba7e80370acc7c7144725bb6de1d018a8493b9b7
refs: #4117
2017-06-12 17:17:06 -05:00
Ashlesh Gawande 3e105a0493 Use separate name prefix and sequence number for each LSA type
refs: #1523

Change-Id: I9db6b3a3ea9ce5e17e132d2a4e2ae9f30dd4f591
2017-06-09 13:54:24 -05:00
Nick Gordon b9c5cecfb2 build: specify pre-v2 change version of ndn-cxx, ChronoSync in Jenkins file
Change-Id: I4c1a13542444821df6455958cdbbd9685c017337
refs: #3920 #4119
2017-06-09 10:37:12 -05:00
Nick Gordon f8852c2d27 nlsr: change configuration parameter output level to info
Change-Id: I32ec91457aaa45e0dbd87c599b3a6bd0b5ac92a6
refs: #2850
2017-05-25 10:07:53 -05:00
Nick Gordon 9461afb721 nlsr: canonize Adjacent FaceURIs on startup
Change-Id: I6a2b31631918c1ece79c3fc13e392917162efc2d
refs: #4063
2017-05-24 10:42:57 -07:00
Nick Gordon 2108808ae3 nlsr: remove deprecated ndn-cxx header includes
Change-Id: Ia016bf6f29304bbc2232db45003fedb331f43ee6
refs: #4088
2017-05-24 10:57:49 -05:00
Ashlesh Gawande 6fa00d923c Add missing dispatcher header to fix compilation
Change-Id: I7a7c637e74974c546bfc2c70fa39e850e8dbeaa2
2017-05-19 19:31:46 -05:00
Ashlesh Gawande b4567f40fb docs+README: improve documentation
Change-Id: I562508869f7e60ccf465b8c1acdf63e27c905c7a
2017-05-05 10:25:24 -05:00
Ashlesh Gawande 415676b6cc make chronosync a dependency
refs: #2400

Change-Id: I8b488f165a4f9a2c9a7731931be3b6d2e3c43c89
2017-05-02 14:26:16 -05:00
Nick Gordon c780a6986b nlsr: refactor AdjacencyList to use iterators instead of bare ptrs
Change-Id: I42225ee63c3d64eb80e58bc51c8d1afd20dd2ce2
refs: #4068
2017-04-28 10:43:08 -05:00
dmcoomes 9eaf3f4417 nlsr: Improve logging throughout lsdb.cpp and others
refs: #3934

Change-Id: I2365c88b795316c83dbeac2eab82f371c0275f88
2017-04-27 12:37:18 -05:00
dmcoomes c2c3ae0fd2 nlsr: update manpages for nlsrc when security is enabled
refs: #3911

Change-Id: Idf496ed2c3826c2aafd015a42b9a61d9ec4ecceb
2017-04-24 13:34:13 -05:00
Ashlesh Gawande 812af97447 ci: check boost version change on OSX
refs: #4060

Change-Id: I70819d428c6285ed4e18d2da9478d2c99333d37a
2017-04-24 10:31:49 -05:00
dmcoomes e689dd6d8b Make header guards comply with Rule 3.2
refs: #3984

Change-Id: Iec7a0d9ff49cf6124af9e554432ee5f09a199651
2017-04-12 09:24:42 -05:00
Nick Gordon 4d2c6c07ae nlsr: accept NFD-RIB-style register/unregister commands
refs: #3818

Change-Id: I7a5455bdec815bdcbe53ad535dab44249d1a18ce
2017-03-31 12:22:42 -05:00
Ashlesh Gawande 30096b8f37 docs: update NLSR paper
Change-Id: Ia8fda3373c5873db77db43f30165ec41dd4d05b2
2017-03-30 18:16:11 -05:00
Muktadir Chowdhury 3be6466a85 route: Refresh FIB entries independently of routing table calculation
refs: #2778

Change-Id: I3536faa9c097152bfb99ebc0270221ca359cba35
2017-03-28 10:58:30 -05:00
Muktadir R Chowdhury f023a88ec1 docs+build: Prepare release for version 0.3.2
refs: #3995

Change-Id: If9ea3e69eee886abce90700e33f37c0102e367a7
2017-03-16 09:19:50 -07:00
Alexander Afanasyev 4c2bb361ae Remove more use of deprecated code
Change-Id: I4322ab4aedb9287acf2eb608f96b7eefbc5f7dba
Refs: #3988
2017-03-14 12:29:19 -07:00
Alexander Afanasyev 1de901f161 Remove use of deprecated code
Change-Id: I197471c48c54c5671bb8f641c4332b3ac7893824
Refs: #3988
2017-03-11 13:50:28 -08:00
dmcoomes 9f93666519 nlsr: Don't use ndn aliases provided by ndn-cxx/common.hpp
refs: #3983

Change-Id: I31da8d68e0285dcfe9c7d3e5e678c00397d22bef
2017-03-09 12:12:40 -06:00
Nick Gordon 48daea20d7 nlsr: enable dispatcher for LOCALHOST_PREFIX
refs: #3938

Change-Id: I532b69aa7e2ade22929588f42de55366fccb80d2
2017-02-27 15:33:10 -06:00
Ashlesh Gawande 218aaef118 utility: temp fix for face already exists (409)
refs: #3976

Change-Id: I930ae5dae8938c83b7deff5079a499b7c5dcc639
2017-02-25 21:34:36 -06:00
Davide Pesavento 87911dacd5 src: use ndn::nfd::ROUTE_ORIGIN_NLSR instead of a magic number
Change-Id: I88dc8e8bc5893820085f305abb52bfd1b654dfcd
Refs: #3903
2017-02-21 22:13:25 -05:00
Ashlesh Gawande 54e726cf5e update config file for /localhop LSA
refs: #3899

Change-Id: I028ed7067724a2d3506ceca0813aea89efea528d
2017-02-14 11:04:08 -06:00
Laqin Fan a4cf402084 nlsr: Pass keyChain to NLSR constructor
refs: #3742

Change-Id: I186784da2989aa8bcc396c81c4fc80254a6f313a
2017-02-01 10:18:05 -08:00
Nick Gordon f590fecfc2 docs+build: Prepare release for version 0.3.1
Change-Id: I01d0b8e71ee4fdf37957a323e11e87f69672d473
2017-01-22 11:03:28 -08:00
Ashlesh Gawande 6077ea910c src: use /localhop component in LSA prefix
refs: #3899

Change-Id: Ibbb42adf3cc34e4a09e267bd73ffb248aad715d5
2017-01-21 16:23:34 -08:00
Nick Gordon d1f4f33cfd nlsr: Add dispatcher to NLSR class
refs: #3930

Change-Id: I69d3a1a87558118ea25258f08f7441e0d7ebe73d
2017-01-20 14:50:20 -06:00
Laqin Fan d8c9d8cdab Fix typos in the sample configuration file.
Change-Id: I66d66bef84aeb3508af654f7e664ca59bc5fee53
refs: #3113
2017-01-19 15:54:12 +00:00
Nick Gordon feae5574b8 boilerplate: Update copyright year in .cpp files
refs: #3923

Change-Id: I8a46f2634527094d82c85c605384f25ddd172732
2017-01-13 12:18:32 -06:00
Alexander Afanasyev 4fc69e49a9 ci: Fix macOS build with Travis-CI
Change-Id: Iabdfd71c4ba8b3c35f6de117da3b42b61cb1dc4e
2017-01-11 13:31:43 -08:00
Nick Gordon c6a852234d nlsr: Updated license boilerplate for all NLSR files.
refs: #3909

Change-Id: I7186b62e2e3506e23a28c70b95b7e6a225a8d78b
2017-01-03 16:56:17 -06:00
Ashlesh Gawande 44395237b8 src: use /localhop component in Sync prefix
refs: #3627

Change-Id: I666f4072601cf7b66bcde632c31c632fabe6e684
2016-12-13 14:35:44 -06:00
Ashlesh Gawande c5fa320239 hello-protocol: re-calculate HR nexthops on status change of a neighbor
refs: #3874

Change-Id: I8295248d95e047e24cced9700eabd458ab3e9112
2016-12-05 12:06:25 -08:00
Eric Newberry 41330f4256 ci: set Travis CI Xcode version and update NODE_LABELS to 10.11
refs #3833

Change-Id: I4c9f98d11e01ce1b712295c884d49fc14def37e2
2016-11-01 15:33:36 -07:00
Alexander Afanasyev 96bf2f0db8 build: Do not fail the build in debug mode when using deprecated declarations
The original motivation of this change was to avoid compilation failure
in debug mode on macOS 10.12.

Change-Id: Ibc006a6be6f5d9aba80dfe4b5f9b13a758bafcc7
Refs: #3795
2016-11-01 15:33:20 -07:00
Laqin Fan 2b057af9e1 hello-protocol: delete redundant call to Nlsr::setStragies()
ref: #3743

Change-Id: Ic793b0e78639adceec0932ded5a87514b9af94ea
2016-09-27 18:32:02 +00:00
Nick Gordon b71684744f src: Fib and FaceMap now use map instead of list as their table data structure.
ref: #2781

Change-Id: I93ad23266ee7b79fd5c53b538c30af76565abc4b
2016-09-26 10:54:41 -05:00
Nick Gordon b50e51b374 Name prefix table entries keep pointers instead of keeping a copy of the object for routing table entries.
refs: #2863

Change-Id: I3271c9f96dfc8721a0ca7c900542c6ddb0b321ac
2016-09-12 10:36:32 -07:00
Junxiao Shi 3e5120c543 include ndn-cxx/mgmt/nfd/*
refs #3760

Change-Id: Iaa0e127a2035960fc96a7c6f958538d3bc3cdee6
2016-09-10 16:58:34 +00:00
Vince Lehman ef21d8eab0 src: Sort NextHops on NexthopList insertion
refs: #2721

Change-Id: I39893c5fb6b5fac93220901ab3190090f0d2cc57
2016-09-06 19:41:31 -05:00
Nick G 97e3494256 docs: improve Doxygen comments.
refs: #1435

Change-Id: I21624ef4eec393c82a50229a07e8277fb6ae4ddf
2016-09-02 12:11:42 -07:00
Nick G d69f9a3c82 Copied ndn-cxx's .jenkins script for better compatibility.
refs: #3695

Change-Id: I909fd9b486e16939a58f07d42e356885d809ef9a
2016-08-24 13:25:39 -05:00
Junxiao Shi 63bd0348b3 adapt to Controller::CommandFailCallback with ControlResponse
refs #3739

Change-Id: I193fb11fd96bd91808fc6e3af22a8da2511246e2
2016-08-17 16:57:14 +00:00
Muktadir R Chowdhury b9d43d06cc docs: Mention change in configuration file in release note.
Change-Id: I70dda0a904e03bdd93b3f2f4404f70ecd108b65d
2016-08-15 09:50:39 -07:00
Nick Gordon e2d3fe9d9a Brought script into POSIX-compliance for find.
refs: #3695

Change-Id: Id35218b560f55a19fec81409950fed5a4f8504d5
2016-08-12 14:00:52 -07:00
Nick Gordon 7b5872ec86 face-map.hpp: Fixed class formatting per style rule 1.4
refs: #3737

Change-Id: Iee14f98a967a3887c34700c3c2a004dcb8b6d97d
2016-08-12 13:57:01 -07:00
Nick Gordon fad8e257c0 Fixed namespace formatting across all files.
refs: #3735

Change-Id: Ia04f0895de9906e280d6140f775bb6609db714e6
2016-08-12 13:49:12 -07:00
Nick Gordon f8b5bcd27e Fixed copyright dates across all files.
refs: #3736

Change-Id: Ibe089fd2e8c4ddc8a4c68d073b435f7d3060d1a4
2016-08-11 15:14:18 -05:00
286 changed files with 17108 additions and 14639 deletions

No files matched your search

+32 -7
View File
@@ -1,7 +1,32 @@
.DS*
.waf-1*
.waf3-*
.lock*
**/*.pyc
build/
VERSION
# Emacs
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
.\#*
# Visual Studio Code
.vscode/
# KDevelop
*.kdev*
# macOS
.DS_Store
.AppleDouble
.LSOverride
._*
# Waf build system
/build/
.waf-*-*/
.waf3-*-*/
.lock-waf*
# Compiled python code
__pycache__/
*.py[cod]
# Other
/VERSION
+4 -3
View File
@@ -3,7 +3,8 @@ set -e
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
for i in $( find "$DIR/.jenkins.d" -type f -perm +111 | sort ); do
echo "Run: $i"
"$i"
for file in "$DIR"/.jenkins.d/*; do
[[ -f $file && -x $file ]] || continue
echo "Run: $file"
"$file"
done
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
set -x
if has OSX $NODE_LABELS; then
FORMULAE=(boost pkg-config openssl)
brew update
if [[ -n $TRAVIS ]]; then
# travis images come with a large number of brew packages
# pre-installed, don't waste time upgrading all of them
for FORMULA in "${FORMULAE[@]}"; do
brew outdated $FORMULA || brew upgrade $FORMULA
done
else
brew upgrade
fi
brew install "${FORMULAE[@]}"
brew cleanup
fi
if has Ubuntu $NODE_LABELS; then
sudo apt-get -qq update
sudo apt-get -qy install build-essential pkg-config libboost-all-dev \
libsqlite3-dev libssl-dev
if [[ $JOB_NAME == *"code-coverage" ]]; then
sudo apt-get -qy install gcovr lcov libgd-perl
fi
fi
-28
View File
@@ -1,28 +0,0 @@
#!/usr/bin/env bash
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
if has OSX $NODE_LABELS && ! has OSX-10.8-c++11-64bit $NODE_LABELS; then
# OSX 10.8 requires special handling of dependencies
set -x
brew update
brew upgrade
brew install boost pkg-config sqlite cryptopp log4cxx protobuf openssl
brew link --force openssl log4cxx protobuf
brew cleanup
fi
if has Ubuntu $NODE_LABELS; then
BOOST_PKG=libboost-all-dev
if has Ubuntu-12.04 $NODE_LABELS; then
BOOST_PKG=libboost1.48-all-dev
fi
set -x
sudo apt-get update -qq -y
sudo apt-get -qq -y install build-essential pkg-config $BOOST_PKG \
libcrypto++-dev libsqlite3-dev \
liblog4cxx10-dev protobuf-compiler libprotobuf-dev libssl-dev
fi
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
set -x
pushd "${CACHE_DIR:-/tmp}" >/dev/null
INSTALLED_VERSION=
if has OSX $NODE_LABELS; then
BOOST=$(brew ls --versions boost)
OLD_BOOST=$(cat boost.txt || :)
if [[ $OLD_BOOST != $BOOST ]]; then
echo "$BOOST" > boost.txt
INSTALLED_VERSION=NONE
fi
fi
if [[ -z $INSTALLED_VERSION ]]; then
INSTALLED_VERSION=$(git -C ndn-cxx rev-parse HEAD 2>/dev/null || echo NONE)
fi
sudo rm -Rf ndn-cxx-latest
git clone --depth 1 git://github.com/named-data/ndn-cxx ndn-cxx-latest
LATEST_VERSION=$(git -C ndn-cxx-latest rev-parse HEAD 2>/dev/null || echo UNKNOWN)
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
sudo rm -Rf ndn-cxx
mv ndn-cxx-latest ndn-cxx
else
sudo rm -Rf ndn-cxx-latest
fi
sudo rm -f /usr/local/bin/ndnsec*
sudo rm -fr /usr/local/include/ndn-cxx
sudo rm -f /usr/local/lib/libndn-cxx*
sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx.pc
pushd ndn-cxx >/dev/null
./waf configure --color=yes --enable-shared --disable-static --without-osx-keychain
./waf build --color=yes -j${WAF_JOBS:-1}
sudo env "PATH=$PATH" ./waf install --color=yes
popd >/dev/null
popd >/dev/null
if has Linux $NODE_LABELS; then
sudo ldconfig
elif has FreeBSD10 $NODE_LABELS; then
sudo ldconfig -m
fi
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
set -x
pushd "${CACHE_DIR:-/tmp}" >/dev/null
INSTALLED_VERSION=
NDN_CXX=$(ndnsec version)
OLD_NDN_CXX=$(cat ndn_cxx_chrono.txt || :)
if [[ $OLD_NDN_CXX != $NDN_CXX ]]; then
echo "$NDN_CXX" > ndn_cxx_chrono.txt
INSTALLED_VERSION=NONE
fi
if [[ -z $INSTALLED_VERSION ]]; then
INSTALLED_VERSION=$(git -C ChronoSync rev-parse HEAD 2>/dev/null || echo NONE)
fi
sudo rm -Rf ChronoSync-latest
git clone --depth 1 git://github.com/named-data/ChronoSync ChronoSync-latest
LATEST_VERSION=$(git -C ChronoSync-latest rev-parse HEAD 2>/dev/null || echo UNKNOWN)
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
sudo rm -Rf ChronoSync
mv ChronoSync-latest ChronoSync
else
sudo rm -Rf ChronoSync-latest
fi
sudo rm -fr /usr/local/include/ChronoSync
sudo rm -f /usr/local/lib/libChronoSync*
sudo rm -f /usr/local/lib/pkgconfig/ChronoSync*
pushd ChronoSync >/dev/null
if has FreeBSD10 $NODE_LABELS; then
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
fi
./waf configure --color=yes
./waf build --color=yes -j${WAF_JOBS:-1}
sudo env "PATH=$PATH" ./waf install --color=yes
popd >/dev/null
popd >/dev/null
if has Linux $NODE_LABELS; then
sudo ldconfig
elif has FreeBSD10 $NODE_LABELS; then
sudo ldconfig -m
fi
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
set -x
pushd "${CACHE_DIR:-/tmp}" >/dev/null
INSTALLED_VERSION=
NDN_CXX=$(ndnsec version)
OLD_NDN_CXX=$(cat ndn_cxx_psync.txt || :)
if [[ $OLD_NDN_CXX != $NDN_CXX ]]; then
echo "$NDN_CXX" > ndn_cxx_psync.txt
INSTALLED_VERSION=NONE
fi
if [[ -z $INSTALLED_VERSION ]]; then
INSTALLED_VERSION=$(git -C PSync rev-parse HEAD 2>/dev/null || echo NONE)
fi
sudo rm -Rf PSync-latest
git clone --depth 1 git://github.com/named-data/PSync PSync-latest
LATEST_VERSION=$(git -C PSync-latest rev-parse HEAD 2>/dev/null || echo UNKNOWN)
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
sudo rm -Rf PSync
mv PSync-latest PSync
else
sudo rm -Rf PSync-latest
fi
sudo rm -fr /usr/local/include/PSync
sudo rm -f /usr/local/lib/libPSync*
sudo rm -f /usr/local/lib/pkgconfig/PSync*
pushd PSync >/dev/null
if has FreeBSD10 $NODE_LABELS; then
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
fi
./waf configure --color=yes
./waf build --color=yes -j${WAF_JOBS:-1}
sudo env "PATH=$PATH" ./waf install --color=yes
popd >/dev/null
popd >/dev/null
if has Linux $NODE_LABELS; then
sudo ldconfig
elif has FreeBSD10 $NODE_LABELS; then
sudo ldconfig -m
fi
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
set -x
git submodule init
git submodule sync
git submodule update
if [[ $JOB_NAME == *"code-coverage" ]]; then
COVERAGE="--with-coverage"
elif [[ -z $DISABLE_ASAN ]]; then
ASAN="--with-sanitizer=address"
fi
# Cleanup
sudo env "PATH=$PATH" ./waf --color=yes distclean
if [[ $JOB_NAME != *"code-coverage" && $JOB_NAME != *"limited-build" ]]; then
# Configure/build in optimized mode with tests
./waf --color=yes configure --with-tests
./waf --color=yes build -j${WAF_JOBS:-1}
# Cleanup
sudo env "PATH=$PATH" ./waf --color=yes distclean
# Configure/build in optimized mode without tests
./waf --color=yes configure
./waf --color=yes build -j${WAF_JOBS:-1}
# Cleanup
sudo env "PATH=$PATH" ./waf --color=yes distclean
fi
# Configure/build in debug mode with tests
./waf --color=yes configure --debug --with-tests $ASAN $COVERAGE
./waf --color=yes build -j${WAF_JOBS:-1}
# (tests will be run against debug version)
# Install
sudo env "PATH=$PATH" ./waf --color=yes install
-42
View File
@@ -1,42 +0,0 @@
#!/usr/bin/env bash
set -x
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
pushd /tmp >/dev/null
INSTALLED_VERSION=$((cd ndn-cxx && git rev-parse HEAD) 2>/dev/null || echo NONE)
sudo rm -Rf ndn-cxx-latest
git clone --depth 1 git://github.com/named-data/ndn-cxx ndn-cxx-latest
LATEST_VERSION=$((cd ndn-cxx-latest && git rev-parse HEAD) 2>/dev/null || echo UNKNOWN)
if [[ $INSTALLED_VERSION != $LATEST_VERSION ]]; then
sudo rm -Rf ndn-cxx
mv ndn-cxx-latest ndn-cxx
else
sudo rm -Rf ndn-cxx-latest
fi
sudo rm -Rf /usr/local/include/ndn-cxx
sudo rm -f /usr/local/lib/libndn-cxx*
sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
pushd ndn-cxx >/dev/null
./waf configure -j1 --color=yes --enable-shared --disable-static --without-osx-keychain
./waf -j1 --color=yes
sudo ./waf install -j1 --color=yes
popd >/dev/null
popd >/dev/null
if has Linux $NODE_LABELS; then
sudo ldconfig
elif has FreeBSD $NODE_LABELS; then
sudo ldconfig -a
fi
-37
View File
@@ -1,37 +0,0 @@
#!/usr/bin/env bash
set -x
set -e
git submodule init
git submodule sync
git submodule update
COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
# Cleanup
sudo ./waf -j1 --color=yes distclean
# Configure/build in debug mode
./waf -j1 --color=yes configure --with-tests --debug
./waf -j1 --color=yes build
# Cleanup
sudo ./waf -j1 --color=yes distclean
# Configure/build in optimized mode without tests
./waf -j1 --color=yes configure
./waf -j1 --color=yes build
# Cleanup
sudo ./waf -j1 --color=yes distclean
# Configure/build in optimized mode with tests
./waf -j1 --color=yes configure --with-tests $COVERAGE
./waf -j1 --color=yes build
# (tests will be run against optimized version)
./waf configure --color=yes --with-tests $COVERAGE
./waf -j1 --color=yes
sudo ./waf install --color=yes
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -e
set -x
# Prepare environment
rm -Rf ~/.ndn
ut_log_args() {
echo --log_level=test_suite
}
ASAN_OPTIONS="color=always"
ASAN_OPTIONS+=":detect_stack_use_after_return=true"
ASAN_OPTIONS+=":check_initialization_order=true"
ASAN_OPTIONS+=":strict_init_order=true"
ASAN_OPTIONS+=":detect_invalid_pointer_pairs=1"
ASAN_OPTIONS+=":detect_container_overflow=false"
ASAN_OPTIONS+=":strict_string_checks=true"
ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
export ASAN_OPTIONS
# Run unit tests
./build/unit-tests-nlsr $(ut_log_args)
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "$JDIR"/util.sh
set -x
if [[ $JOB_NAME == *"code-coverage" ]]; then
lcov --quiet \
--capture \
--directory . \
--no-external \
--rc lcov_branch_coverage=1 \
--output-file build/coverage-with-tests.info
lcov --quiet \
--remove build/coverage-with-tests.info "$PWD/tests/*" \
--rc lcov_branch_coverage=1 \
--output-file build/coverage.info
genhtml --branch-coverage \
--demangle-cpp \
--frames \
--legend \
--output-directory build/coverage \
--title "NLSR unit tests" \
build/coverage.info
fi
-7
View File
@@ -1,7 +0,0 @@
#!/usr/bin/env bash
set -x
set -e
rm -Rf ~/.ndn
./build/unit-tests-nlsr -l test_suite
+36
View File
@@ -0,0 +1,36 @@
CONTINUOUS INTEGRATION SCRIPTS
==============================
Environment Variables Used in Build Scripts
-------------------------------------------
- `NODE_LABELS`: the variable defines a list of OS properties. The set values are used by the
build scripts to select proper behavior for different OS.
The list should include at least `[OS_TYPE]`, `[DISTRO_TYPE]`, and `[DISTRO_VERSION]`.
Possible values for Linux:
* `[OS_TYPE]`: `Linux`
* `[DISTRO_TYPE]`: `Ubuntu`
* `[DISTRO_VERSION]`: `Ubuntu-16.04`, `Ubuntu-18.04`
Possible values for OS X / macOS:
* `[OS_TYPE]`: `OSX`
* `[DISTRO_TYPE]`: `OSX` (can be absent)
* `[DISTRO_VERSION]`: `OSX-10.11`, `OSX-10.12`, `OSX-10.13`
- `JOB_NAME`: optional variable to define type of the job. Depending on the defined job type,
the build scripts can perform different tasks.
Possible values:
* empty: default build process
* `code-coverage` (Ubuntu Linux is assumed): debug build with tests and code coverage analysis
* `limited-build`: only a single debug build with tests
- `CACHE_DIR`: the variable defines a path to folder containing cached files from previous builds,
e.g., a compiled version of ndn-cxx library. If not set, `/tmp` is used.
- `WAF_JOBS`: number of parallel build jobs used by waf, defaults to 1.
Executable → Regular
+13 -4
View File
@@ -1,9 +1,18 @@
has() {
local saved_xtrace
[[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x
set +x
local p=$1
shift
local x
for x in "$@"; do
[[ "${x}" == "${p}" ]] && return 0
local i ret=1
for i in "$@"; do
if [[ "${i}" == "${p}" ]]; then
ret=0
break
fi
done
return 1
set ${saved_xtrace}
return ${ret}
}
+16
View File
@@ -0,0 +1,16 @@
A K M Mahmudul Hoque <akmhoque@gmail.com>
<agawande@memphis.edu> <ashu2493@gmail.com>
Nick Gordon <nmgordon@memphis.edu>
Laqin Fan <lfan1@memphis.edu>
Syed Obaid Amin <soamin@memphis.edu>
Syed Obaid Amin <soamin@memphis.edu> <obaidasyed@gmail.com>
Syed Obaid Amin <soamin@memphis.edu> <obaid@Obaids-MacBook.local>
Syed Obaid Amin <soamin@memphis.edu> <obaid@obaids-macbook.memphis.edu>
Syed Obaid Amin <soamin@memphis.edu> <soamin@mira.cs.memphis.edu>
Syed Obaid Amin <soamin@memphis.edu> <soamin@wd222yx4.memphis.edu>
Muktadir R Chowdhury <mrchwdhr@memphis.edu>
Muktadir R Chowdhury <mrchwdhr@memphis.edu> <muktadir.rahman.c@gmail.com>
<aa@cs.fiu.edu> <alexander.afanasyev@ucla.edu>
<davidepesa@gmail.com> <davide.pesavento@lip6.fr>
<enewberry@email.arizona.edu> <enewberry@cs.arizona.edu>
Md Ashiqur Rahman <marahman@email.arizona.edu>
+89 -16
View File
@@ -1,24 +1,97 @@
language: cpp
dist: xenial
sudo: required
language: generic
env:
global:
- JOB_NAME=limited-build
- WAF_JOBS=2
matrix:
include:
# Linux/gcc
# https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test/+packages
- os: linux
dist: trusty
env:
- CXX=g++
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
env: COMPILER=g++-5
- os: linux
dist: trusty
env:
- CXX=clang++
- NODE_LABELS="Linux Ubuntu Ubuntu-14.04"
env: COMPILER=g++-6
- os: linux
env: COMPILER=g++-7
- os: linux
env: COMPILER=g++-8
# Linux/clang
# https://apt.llvm.org/
- os: linux
env: COMPILER=clang++-3.5
- os: linux
env: COMPILER=clang++-3.6
- os: linux
env: COMPILER=clang++-3.7 DISABLE_ASAN=yes
- os: linux
env: COMPILER=clang++-3.8
- os: linux
env: COMPILER=clang++-3.9
- os: linux
env: COMPILER=clang++-4.0
- os: linux
env: COMPILER=clang++-5.0
- os: linux
env: COMPILER=clang++-6.0
- os: linux
env: COMPILER=clang++-7
# macOS/clang
# https://docs.travis-ci.com/user/reference/osx/#OS-X-Version
- os: osx
env:
- CXX=clang++
- NODE_LABELS="OSX OSX-10.9"
notifications:
email:
on_success: always
on_failure: always
osx_image: xcode7.3
env: OSX_VERSION=10.11
- os: osx
osx_image: xcode8.3
env: OSX_VERSION=10.12
- os: osx
osx_image: xcode9.3
env: OSX_VERSION=10.13
allow_failures:
- env: COMPILER=g++-6
- env: COMPILER=g++-7
- env: COMPILER=g++-8
- env: COMPILER=clang++-3.5
- env: COMPILER=clang++-3.6
- env: COMPILER=clang++-3.7 DISABLE_ASAN=yes
- env: COMPILER=clang++-3.8
- env: COMPILER=clang++-3.9
- env: COMPILER=clang++-4.0
- env: COMPILER=clang++-5.0
- env: COMPILER=clang++-6.0
- env: COMPILER=clang++-7
fast_finish: true
install: |
case ${COMPILER} in
g++-[6789])
travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
travis_retry sudo apt-get -qq update
travis_retry sudo apt-get -qy install "${COMPILER}"
;;
clang++-*)
CLANG_VERSION=${COMPILER/clang++}
if [[ ${CLANG_VERSION} != "-3."* ]]; then
wget -O - "https://apt.llvm.org/llvm-snapshot.gpg.key" | sudo apt-key add -
travis_retry sudo add-apt-repository -y "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial${CLANG_VERSION/-7} main"
fi
travis_retry sudo apt-get -qq update
travis_retry sudo apt-get -qy install "clang${CLANG_VERSION}"
;;
esac
before_script:
- if [[ ${TRAVIS_OS_NAME} == linux ]]; then export NODE_LABELS="Linux Ubuntu Ubuntu-16.04"; fi
- if [[ ${TRAVIS_OS_NAME} == osx ]]; then export NODE_LABELS="OSX OSX-${OSX_VERSION}"; fi
- if [[ -n ${COMPILER} ]]; then export CXX=${COMPILER}; fi
- ${CXX:-c++} --version
- python --version
script:
- ./.jenkins
+220 -76
View File
@@ -30,15 +30,15 @@ When using this tool, the wscript will look like:
Options are generated, in order to specify the location of boost includes/libraries.
The `check_boost` configuration function allows to specify the used boost libraries.
It can also provide default arguments to the --boost-static and --boost-mt command-line arguments.
It can also provide default arguments to the --boost-mt command-line arguments.
Everything will be packaged together in a BOOST component that you can use.
When using MSVC, a lot of compilation flags need to match your BOOST build configuration:
- you may have to add /EHsc to your CXXFLAGS or define boost::throw_exception if BOOST_NO_EXCEPTIONS is defined.
Errors: C4530
- boost libraries will try to be smart and use the (pretty but often not useful) auto-linking feature of MSVC
So before calling `conf.check_boost` you might want to disabling by adding:
conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
So before calling `conf.check_boost` you might want to disabling by adding
conf.env.DEFINES_BOOST += ['BOOST_ALL_NO_LIB']
Errors:
- boost might also be compiled with /MT, which links the runtime statically.
If you have problems with redefined symbols,
@@ -52,24 +52,54 @@ import sys
import re
from waflib import Utils, Logs, Errors
from waflib.Configure import conf
from waflib.TaskGen import feature, after_method
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib', '/usr/lib/x86_64-linux-gnu', '/usr/lib/i386-linux-gnu', '/usr/local/ndn/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include', '/usr/local/ndn/include']
BOOST_LIBS = ['/usr/lib', '/usr/local/lib', '/opt/local/lib', '/sw/lib', '/lib']
BOOST_INCLUDES = ['/usr/include', '/usr/local/include', '/opt/local/include', '/sw/include']
BOOST_VERSION_FILE = 'boost/version.hpp'
BOOST_VERSION_CODE = '''
#include <iostream>
#include <boost/version.hpp>
int main() { std::cout << BOOST_LIB_VERSION << ":" << BOOST_VERSION << std::endl; }
'''
BOOST_SYSTEM_CODE = '''
BOOST_ERROR_CODE = '''
#include <boost/system/error_code.hpp>
int main() { boost::system::error_code c; }
'''
PTHREAD_CODE = '''
#include <pthread.h>
static void* f(void*) { return 0; }
int main() {
pthread_t th;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_create(&th, &attr, &f, 0);
pthread_join(th, 0);
pthread_cleanup_push(0, 0);
pthread_cleanup_pop(0);
pthread_attr_destroy(&attr);
}
'''
BOOST_THREAD_CODE = '''
#include <boost/thread.hpp>
int main() { boost::thread t; }
'''
BOOST_LOG_CODE = '''
#include <boost/log/trivial.hpp>
#include <boost/log/utility/setup/console.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
int main() {
using namespace boost::log;
add_common_attributes();
add_console_log(std::clog, keywords::format = "%Message%");
BOOST_LOG_TRIVIAL(debug) << "log is working" << std::endl;
}
'''
# toolsets from {boost_dir}/tools/build/v2/tools/common.jam
PLATFORM = Utils.unversioned_sys_platform()
detect_intel = lambda env: (PLATFORM == 'win32') and 'iw' or 'il'
@@ -101,34 +131,37 @@ BOOST_TOOLSETS = {
def options(opt):
opt = opt.add_option_group('Boost Options')
opt.add_option('--boost-includes', type='string',
default='', dest='boost_includes',
help='''path to the directory where the boost includes are, e.g., /path/to/boost_1_55_0/stage/include''')
help='''path to the directory where the boost includes are,
e.g., /path/to/boost_1_55_0/stage/include''')
opt.add_option('--boost-libs', type='string',
default='', dest='boost_libs',
help='''path to the directory where the boost libs are, e.g., /path/to/boost_1_55_0/stage/lib''')
opt.add_option('--boost-static', action='store_true',
default=False, dest='boost_static',
help='link with static boost libraries (.lib/.a)')
help='''path to the directory where the boost libs are,
e.g., path/to/boost_1_55_0/stage/lib''')
opt.add_option('--boost-mt', action='store_true',
default=False, dest='boost_mt',
help='select multi-threaded libraries')
opt.add_option('--boost-abi', type='string', default='', dest='boost_abi',
help='''select libraries with tags (dgsyp, d for debug), see doc Boost, Getting Started, chapter 6.1''')
help='''select libraries with tags (gd for debug, static is automatically added),
see doc Boost, Getting Started, chapter 6.1''')
opt.add_option('--boost-linkage_autodetect', action="store_true", dest='boost_linkage_autodetect',
help="auto-detect boost linkage options (don't get used to it / might break other stuff)")
opt.add_option('--boost-toolset', type='string',
default='', dest='boost_toolset',
help='force a toolset e.g. msvc, vc90, gcc, mingw, mgw45 (default: auto)')
help='force a toolset e.g. msvc, vc90, \
gcc, mingw, mgw45 (default: auto)')
py_version = '%d%d' % (sys.version_info[0], sys.version_info[1])
opt.add_option('--boost-python', type='string',
default=py_version, dest='boost_python',
help='select the lib python with this version (default: %s)' % py_version)
help='select the lib python with this version \
(default: %s)' % py_version)
@conf
def __boost_get_version_file(self, d):
if not d:
return None
dnode = self.root.find_dir(d)
if dnode:
return dnode.find_node(BOOST_VERSION_FILE)
@@ -141,18 +174,15 @@ def boost_get_version(self, d):
if node:
try:
txt = node.read()
except (OSError, IOError):
except EnvironmentError:
Logs.error("Could not read the file %r" % node.abspath())
else:
re_but1 = re.compile('^#define\\s+BOOST_LIB_VERSION\\s+"(.+)"', re.M)
m1 = re_but1.search(txt)
re_but2 = re.compile('^#define\\s+BOOST_VERSION\\s+(\\d+)', re.M)
m2 = re_but2.search(txt)
if m1 and m2:
return (m1.group(1), m2.group(1))
return self.check_cxx(fragment=BOOST_VERSION_CODE, includes=[d], execute=True, define_ret=True).split(":")
@conf
@@ -160,7 +190,7 @@ def boost_get_includes(self, *k, **kw):
includes = k and k[0] or kw.get('includes', None)
if includes and self.__boost_get_version_file(includes):
return includes
for d in Utils.to_list(self.environ.get('INCLUDE', '')) + BOOST_INCLUDES:
for d in self.environ.get('INCLUDE', '').split(';') + BOOST_INCLUDES:
if self.__boost_get_version_file(d):
return d
if includes:
@@ -195,7 +225,9 @@ def __boost_get_libs_path(self, *k, **kw):
path = self.root.find_dir(libs)
files = path.ant_glob('*boost_*')
if not libs or not files:
for d in Utils.to_list(self.environ.get('LIB', [])) + BOOST_LIBS:
for d in self.environ.get('LIB', '').split(';') + BOOST_LIBS:
if not d:
continue
path = self.root.find_dir(d)
if path:
files = path.ant_glob('*boost_*')
@@ -226,15 +258,10 @@ def boost_get_libs(self, *k, **kw):
according to the parameters
'''
path, files = self.__boost_get_libs_path(**kw)
t = []
if kw.get('mt', False):
t.append('mt')
if kw.get('abi', None):
t.append(kw['abi'])
tags = t and '(-%s)+' % '-'.join(t) or ''
files = sorted(files, key=lambda f: (len(f.name), f.name), reverse=True)
toolset = self.boost_get_toolset(kw.get('toolset', ''))
toolset_pat = '(-%s[0-9]{0,3})+' % toolset
version = '(-%s)+' % self.env.BOOST_VERSION
toolset_pat = '(-%s[0-9]{0,3})' % toolset
version = '-%s' % self.env.BOOST_VERSION
def find_lib(re_lib, files):
for file in files:
@@ -248,28 +275,110 @@ def boost_get_libs(self, *k, **kw):
name = name[3:]
return name[:name.rfind('.')]
libs = []
for lib in Utils.to_list(k and k[0] or kw.get('lib', None)):
py = (lib == 'python') and '(-py%s)+' % kw['python'] or ''
# Trying libraries, from most strict match to least one
for pattern in ['boost_%s%s%s%s%s' % (lib, toolset_pat, tags, py, version),
'boost_%s%s%s%s' % (lib, tags, py, version),
'boost_%s%s%s' % (lib, tags, version),
# Give up trying to find the right version
'boost_%s%s%s%s' % (lib, toolset_pat, tags, py),
'boost_%s%s%s' % (lib, tags, py),
'boost_%s%s' % (lib, tags)]:
self.to_log('Trying pattern %s' % pattern)
file = find_lib(re.compile(pattern), files)
if file:
libs.append(format_lib_name(file.name))
break
else:
self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
self.fatal('The configuration failed')
def match_libs(lib_names, is_static):
libs = []
lib_names = Utils.to_list(lib_names)
if not lib_names:
return libs
t = []
if kw.get('mt', False):
t.append('-mt')
if kw.get('abi', None):
t.append('%s%s' % (is_static and '-s' or '-', kw['abi']))
elif is_static:
t.append('-s')
tags_pat = t and ''.join(t) or ''
ext = is_static and self.env.cxxstlib_PATTERN or self.env.cxxshlib_PATTERN
ext = ext.partition('%s')[2] # remove '%s' or 'lib%s' from PATTERN
return path.abspath(), libs
for lib in lib_names:
if lib == 'python':
# for instance, with python='27',
# accepts '-py27', '-py2', '27' and '2'
# but will reject '-py3', '-py26', '26' and '3'
tags = '({0})?((-py{2})|(-py{1}(?=[^0-9]))|({2})|({1}(?=[^0-9]))|(?=[^0-9])(?!-py))'.format(tags_pat, kw['python'][0], kw['python'])
else:
tags = tags_pat
# Trying libraries, from most strict match to least one
for pattern in ['boost_%s%s%s%s%s$' % (lib, toolset_pat, tags, version, ext),
'boost_%s%s%s%s$' % (lib, tags, version, ext),
# Give up trying to find the right version
'boost_%s%s%s%s$' % (lib, toolset_pat, tags, ext),
'boost_%s%s%s$' % (lib, tags, ext),
'boost_%s%s$' % (lib, ext),
'boost_%s' % lib]:
self.to_log('Trying pattern %s' % pattern)
file = find_lib(re.compile(pattern), files)
if file:
libs.append(format_lib_name(file.name))
break
else:
self.end_msg('lib %s not found in %s' % (lib, path.abspath()))
self.fatal('The configuration failed')
return libs
return path.abspath(), match_libs(kw.get('lib', None), False), match_libs(kw.get('stlib', None), True)
@conf
def _check_pthread_flag(self, *k, **kw):
'''
Computes which flags should be added to CXXFLAGS and LINKFLAGS to compile in multi-threading mode
Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3,
boost/thread.hpp will trigger a #error if -pthread isn't used:
boost/config/requires_threads.hpp:47:5: #error "Compiler threading support
is not turned on. Please set the correct command line options for
threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
Based on _BOOST_PTHREAD_FLAG(): https://github.com/tsuna/boost.m4/blob/master/build-aux/boost.m4
'''
var = kw.get('uselib_store', 'BOOST')
self.start_msg('Checking the flags needed to use pthreads')
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
# (none): in case threads are in libc; should be tried before -Kthread and
# other compiler flags to prevent continual compiler warnings
# -lpthreads: AIX (must check this before -lpthread)
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
# -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
# -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads)
# -pthreads: Solaris/GCC
# -mthreads: MinGW32/GCC, Lynx/GCC
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
# doesn't hurt to check since this sometimes defines pthreads too;
# also defines -D_REENTRANT)
# ... -mt is also the pthreads flag for HP/aCC
# -lpthread: GNU Linux, etc.
# --thread-safe: KAI C++
if Utils.unversioned_sys_platform() == "sunos":
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
# a function called by this macro, so we could check for that, but
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
boost_pthread_flags = ["-pthreads", "-lpthread", "-mt", "-pthread"]
else:
boost_pthread_flags = ["", "-lpthreads", "-Kthread", "-kthread", "-llthread", "-pthread",
"-pthreads", "-mthreads", "-lpthread", "--thread-safe", "-mt"]
for boost_pthread_flag in boost_pthread_flags:
try:
self.env.stash()
self.env['CXXFLAGS_%s' % var] += [boost_pthread_flag]
self.env['LINKFLAGS_%s' % var] += [boost_pthread_flag]
self.check_cxx(code=PTHREAD_CODE, msg=None, use=var, execute=False)
self.end_msg(boost_pthread_flag)
return
except self.errors.ConfigurationError:
self.env.revert()
self.end_msg('None')
@conf
def check_boost(self, *k, **kw):
@@ -282,7 +391,10 @@ def check_boost(self, *k, **kw):
if not self.env['CXX']:
self.fatal('load a c++ compiler first, conf.load("compiler_cxx")')
params = {'lib': k and k[0] or kw.get('lib', None)}
params = {
'lib': k and k[0] or kw.get('lib', None),
'stlib': kw.get('stlib', None)
}
for key, value in self.options.__dict__.items():
if not key.startswith('boost_'):
continue
@@ -291,48 +403,64 @@ def check_boost(self, *k, **kw):
var = kw.get('uselib_store', 'BOOST')
self.find_program('dpkg-architecture', var='DPKG_ARCHITECTURE', mandatory=False)
if self.env.DPKG_ARCHITECTURE:
deb_host_multiarch = self.cmd_and_log([self.env.DPKG_ARCHITECTURE[0], '-qDEB_HOST_MULTIARCH'])
BOOST_LIBS.insert(0, '/usr/lib/%s' % deb_host_multiarch.strip())
self.start_msg('Checking boost includes')
self.env['INCLUDES_%s' % var] = inc = self.boost_get_includes(**params)
versions = self.boost_get_version(inc)
self.env.BOOST_VERSION = versions[0]
self.env.BOOST_VERSION_NUMBER = int(versions[1])
self.end_msg("%d.%d.%d" % (int(versions[1]) / 100000,
int(versions[1]) / 100 % 1000,
int(versions[1]) % 100))
int(versions[1]) / 100 % 1000,
int(versions[1]) % 100))
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % self.env['INCLUDES_%s' % var])
if not params['lib']:
if not params['lib'] and not params['stlib']:
return
if 'static' in kw or 'static' in params:
Logs.warn('boost: static parameter is deprecated, use stlib instead.')
self.start_msg('Checking boost libs')
suffix = params.get('static', None) and 'ST' or ''
path, libs = self.boost_get_libs(**params)
self.env['%sLIBPATH_%s' % (suffix, var)] = [path]
self.env['%sLIB_%s' % (suffix, var)] = libs
path, libs, stlibs = self.boost_get_libs(**params)
self.env['LIBPATH_%s' % var] = [path]
self.env['STLIBPATH_%s' % var] = [path]
self.env['LIB_%s' % var] = libs
self.env['STLIB_%s' % var] = stlibs
self.end_msg('ok')
if Logs.verbose:
Logs.pprint('CYAN', ' path : %s' % path)
Logs.pprint('CYAN', ' libs : %s' % libs)
Logs.pprint('CYAN', ' shared libs : %s' % libs)
Logs.pprint('CYAN', ' static libs : %s' % stlibs)
def has_shlib(lib):
return params['lib'] and lib in params['lib']
def has_stlib(lib):
return params['stlib'] and lib in params['stlib']
def has_lib(lib):
return has_shlib(lib) or has_stlib(lib)
if has_lib('thread'):
# not inside try_link to make check visible in the output
self._check_pthread_flag(k, kw)
def try_link():
if 'system' in params['lib']:
self.check_cxx(
fragment=BOOST_SYSTEM_CODE,
use=var,
execute=False,
)
if 'thread' in params['lib']:
self.check_cxx(
fragment=BOOST_THREAD_CODE,
use=var,
execute=False,
)
if has_lib('system'):
self.check_cxx(fragment=BOOST_ERROR_CODE, use=var, execute=False)
if has_lib('thread'):
self.check_cxx(fragment=BOOST_THREAD_CODE, use=var, execute=False)
if has_lib('log'):
if not has_lib('thread'):
self.env['DEFINES_%s' % var] += ['BOOST_LOG_NO_THREADS']
if has_shlib('log'):
self.env['DEFINES_%s' % var] += ['BOOST_LOG_DYN_LINK']
self.check_cxx(fragment=BOOST_LOG_CODE, use=var, execute=False)
if params.get('linkage_autodetect', False):
self.start_msg("Attempting to detect boost linkage flags")
toolset = self.boost_get_toolset(kw.get('toolset', ''))
if toolset in ['vc']:
if toolset in ('vc',):
# disable auto-linking feature, causing error LNK1181
# because the code wants to be linked against
self.env['DEFINES_%s' % var] += ['BOOST_ALL_NO_LIB']
@@ -356,14 +484,14 @@ def check_boost(self, *k, **kw):
try:
try_link()
self.end_msg("ok: winning cxxflags combination: %s" % (self.env["CXXFLAGS_%s" % var]))
e = None
exc = None
break
except Errors.ConfigurationError as exc:
except Errors.ConfigurationError as e:
self.env.revert()
e = exc
exc = e
if e is not None:
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=e)
if exc is not None:
self.end_msg("Could not auto-detect boost linking flags combination, you may report it to boost.py author", ex=exc)
self.fatal('The configuration failed')
else:
self.end_msg("Boost linkage flags auto-detection not implemented (needed ?) for this toolchain")
@@ -376,3 +504,19 @@ def check_boost(self, *k, **kw):
self.end_msg("Could not link against boost libraries using supplied options")
self.fatal('The configuration failed')
self.end_msg('ok')
@feature('cxx')
@after_method('apply_link')
def install_boost(self):
if install_boost.done or not Utils.is_win32 or not self.bld.cmd.startswith('install'):
return
install_boost.done = True
inst_to = getattr(self, 'install_path', '${BINDIR}')
for lib in self.env.LIB_BOOST:
try:
file = self.bld.find_file(self.env.cxxshlib_PATTERN % lib, self.env.LIBPATH_BOOST)
self.bld.install_files(inst_to, self.bld.root.find_node(file))
except:
continue
install_boost.done = False
+4 -6
View File
@@ -1,17 +1,15 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
#
# Copyright (c) 2014, Regents of the University of California
#
# GPL 3.0 license, see the COPYING.md file for more information
from waflib import TaskGen
def options(opt):
opt.add_option('--with-coverage', action='store_true', default=False, dest='with_coverage',
help='''Set compiler flags for gcc to enable code coverage information''')
opt.add_option('--with-coverage', action='store_true', default=False,
help='Add compiler flags to enable code coverage information')
def configure(conf):
if conf.options.with_coverage:
if not conf.options.debug:
conf.fatal('Code coverage flags require debug mode compilation (add --debug)')
conf.check_cxx(cxxflags=['-fprofile-arcs', '-ftest-coverage', '-fPIC'],
linkflags=['-fprofile-arcs'], uselib_store='GCOV', mandatory=True)
+93 -68
View File
@@ -1,44 +1,67 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
from waflib import Logs, Configure, Utils
from waflib import Configure, Logs, Utils
def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False, dest='debug',
help='''Compile in debugging mode without optimizations (-O0 or -Og)''')
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
help='Compile in debugging mode with minimal optimizations (-O0 or -Og)')
def configure(conf):
cxx = conf.env['CXX_NAME'] # CXX_NAME represents generic name of the compiler
conf.start_msg('Checking C++ compiler version')
cxx = conf.env.CXX_NAME # generic name of the compiler
ccver = tuple(int(i) for i in conf.env.CC_VERSION)
ccverstr = '.'.join(conf.env.CC_VERSION)
errmsg = ''
warnmsg = ''
if cxx == 'gcc':
flags = GccFlags()
if ccver < (5, 3, 0):
errmsg = ('The version of gcc you are using is too old.\n'
'The minimum supported gcc version is 5.3.0.')
conf.flags = GccFlags()
elif cxx == 'clang':
flags = ClangFlags()
if ccver < (3, 6, 0):
errmsg = ('The version of clang you are using is too old.\n'
'The minimum supported clang version is 3.6.0.')
conf.flags = ClangFlags()
else:
flags = CompilerFlags()
Logs.warn('The code has not yet been tested with %s compiler' % cxx)
warnmsg = 'Note: %s compiler is unsupported' % cxx
conf.flags = CompilerFlags()
areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
if errmsg:
conf.end_msg(ccverstr, color='RED')
conf.fatal(errmsg)
elif warnmsg:
conf.end_msg(ccverstr, color='YELLOW')
Logs.warn(warnmsg)
else:
conf.end_msg(ccverstr)
# General flags are always applied (e.g., selecting C++11 mode)
generalFlags = flags.getGeneralFlags(conf)
conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
# General flags are always applied (e.g., selecting C++ language standard)
generalFlags = conf.flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
conf.env.DEFINES += generalFlags['DEFINES']
@Configure.conf
def check_compiler_flags(conf):
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
# corresponding environment variables are not set.
# DEFINES are always applied.
if conf.options.debug:
extraFlags = flags.getDebugFlags(conf)
if areCustomCxxflagsPresent:
extraFlags = conf.flags.getDebugFlags(conf)
if conf.areCustomCxxflagsPresent:
missingFlags = [x for x in extraFlags['CXXFLAGS'] if x not in conf.env.CXXFLAGS]
if len(missingFlags) > 0:
Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
% " ".join(conf.env.CXXFLAGS))
Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
if missingFlags:
Logs.warn('Selected debug mode, but CXXFLAGS is set to a custom value "%s"'
% ' '.join(conf.env.CXXFLAGS))
Logs.warn('Default flags "%s" will not be used' % ' '.join(missingFlags))
else:
extraFlags = flags.getOptimizedFlags(conf)
extraFlags = conf.flags.getOptimizedFlags(conf)
if not areCustomCxxflagsPresent:
if not conf.areCustomCxxflagsPresent:
conf.add_supported_cxxflags(extraFlags['CXXFLAGS'])
conf.add_supported_linkflags(extraFlags['LINKFLAGS'])
@@ -55,12 +78,13 @@ def add_supported_cxxflags(self, cxxflags):
self.start_msg('Checking supported CXXFLAGS')
supportedFlags = []
for flag in cxxflags:
if self.check_cxx(cxxflags=['-Werror', flag], mandatory=False):
supportedFlags += [flag]
for flags in cxxflags:
flags = Utils.to_list(flags)
if self.check_cxx(cxxflags=['-Werror'] + flags, mandatory=False):
supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.CXXFLAGS = supportedFlags + self.env.CXXFLAGS
self.env.prepend_value('CXXFLAGS', supportedFlags)
@Configure.conf
def add_supported_linkflags(self, linkflags):
@@ -73,15 +97,19 @@ def add_supported_linkflags(self, linkflags):
self.start_msg('Checking supported LINKFLAGS')
supportedFlags = []
for flag in linkflags:
if self.check_cxx(linkflags=['-Werror', flag], mandatory=False):
supportedFlags += [flag]
for flags in linkflags:
flags = Utils.to_list(flags)
if self.check_cxx(linkflags=['-Werror'] + flags, mandatory=False):
supportedFlags += flags
self.end_msg(' '.join(supportedFlags))
self.env.LINKFLAGS = supportedFlags + self.env.LINKFLAGS
self.env.prepend_value('LINKFLAGS', supportedFlags)
class CompilerFlags(object):
def getCompilerVersion(self, conf):
return tuple(int(i) for i in conf.env.CC_VERSION)
def getGeneralFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
@@ -98,17 +126,30 @@ class GccBasicFlags(CompilerFlags):
"""
This class defines basic flags that work for both gcc and clang compilers
"""
def getGeneralFlags(self, conf):
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
flags['CXXFLAGS'] += ['-std=c++14']
if Utils.unversioned_sys_platform() == 'linux':
flags['LINKFLAGS'] += ['-fuse-ld=gold']
elif Utils.unversioned_sys_platform() == 'freebsd':
flags['LINKFLAGS'] += ['-fuse-ld=lld']
return flags
def getDebugFlags(self, conf):
flags = super(GccBasicFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-O0',
'-Og', # gcc >= 4.8, clang >= 4.0
'-g3',
'-pedantic',
'-Wall',
'-Wextra',
'-Werror',
'-Wno-unused-parameter',
'-Wnon-virtual-dtor',
'-Wno-error=deprecated-declarations', # Bug #3795
'-Wno-error=maybe-uninitialized', # Bug #1615
'-Wno-unused-parameter',
]
flags['LINKFLAGS'] += ['-Wl,-O1']
return flags
def getOptimizedFlags(self, conf):
@@ -118,74 +159,58 @@ class GccBasicFlags(CompilerFlags):
'-pedantic',
'-Wall',
'-Wextra',
'-Wnon-virtual-dtor',
'-Wno-unused-parameter',
]
flags['LINKFLAGS'] += ['-Wl,-O1']
return flags
class GccFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(GccFlags, self).getGeneralFlags(conf)
version = tuple(int(i) for i in conf.env['CC_VERSION'])
if version < (4, 6, 0):
conf.fatal('The version of gcc you are using (%s) is too old.\n' %
'.'.join(conf.env['CC_VERSION']) +
'The minimum supported gcc version is 4.6.0.')
elif version < (4, 7, 0):
flags['CXXFLAGS'] += ['-std=c++0x']
else:
flags['CXXFLAGS'] += ['-std=c++11']
if version < (4, 8, 0):
flags['DEFINES'] += ['_GLIBCXX_USE_NANOSLEEP'] # Bug #2499
return flags
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
version = tuple(int(i) for i in conf.env['CC_VERSION'])
if version < (5, 1, 0):
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-Og', # gcc >= 4.8
'-fdiagnostics-color', # gcc >= 4.9
]
flags['CXXFLAGS'] += ['-fdiagnostics-color']
return flags
def getOptimizedFlags(self, conf):
flags = super(GccFlags, self).getOptimizedFlags(conf)
version = tuple(int(i) for i in conf.env['CC_VERSION'])
if version < (5, 1, 0):
flags['CXXFLAGS'] += ['-Wno-missing-field-initializers']
flags['CXXFLAGS'] += ['-fdiagnostics-color'] # gcc >= 4.9
flags['CXXFLAGS'] += ['-fdiagnostics-color']
return flags
class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
flags['CXXFLAGS'] += ['-std=c++11']
if Utils.unversioned_sys_platform() == 'darwin':
flags['CXXFLAGS'] += ['-stdlib=libc++']
flags['LINKFLAGS'] += ['-stdlib=libc++']
if Utils.unversioned_sys_platform() == 'darwin' and self.getCompilerVersion(conf) >= (9, 0, 0):
# Bug #4296
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include'], # for Homebrew
['-isystem', '/opt/local/include']] # for MacPorts
if Utils.unversioned_sys_platform() == 'freebsd':
flags['CXXFLAGS'] += [['-isystem', '/usr/local/include']] # Bug #4790
return flags
def getDebugFlags(self, conf):
flags = super(ClangFlags, self).getDebugFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
'-Wextra-semi',
'-Wundefined-func-template',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
'-Wno-error=unneeded-internal-declaration', # Bug #1588
'-Wno-error=deprecated-register',
'-Wno-error=keyword-macro', # Bug #3235
'-Wno-nested-anon-types',
'-Wno-sign-compare',
'-Wno-keyword-macro',
'-Wno-error=ignored-qualifiers',
'-Wno-error=infinite-recursion',
]
version = self.getCompilerVersion(conf)
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
if version < (6, 0, 0):
flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
return flags
def getOptimizedFlags(self, conf):
flags = super(ClangFlags, self).getOptimizedFlags(conf)
flags['CXXFLAGS'] += ['-fcolor-diagnostics',
'-Wextra-semi',
'-Wundefined-func-template',
'-Wno-unused-local-typedef', # Bugs #2657 and #3209
'-Wno-nested-anon-types',
'-Wno-sign-compare',
'-Wno-keyword-macro',
]
version = self.getCompilerVersion(conf)
if version < (3, 9, 0) or (Utils.unversioned_sys_platform() == 'darwin' and version < (8, 1, 0)):
flags['CXXFLAGS'] += ['-Wno-unknown-pragmas']
if version < (6, 0, 0):
flags['CXXFLAGS'] += ['-Wno-missing-braces'] # Bug #4721
return flags
+1 -1
View File
@@ -85,7 +85,7 @@ class doxygen(Task.Task):
# Override with any parameters passed to the task generator
if getattr(self.generator, 'pars', None):
for k, v in self.generator.pars.iteritems():
for k, v in self.generator.pars.items():
self.pars[k] = v
self.doxy_inputs = getattr(self, 'doxy_inputs', [])
-47
View File
@@ -1,47 +0,0 @@
#! /usr/bin/env python
# encoding: utf-8
'''
When using this tool, the wscript will look like:
def options(opt):
opt.tool_options('openssl')
def configure(conf):
conf.load('compiler_cxx openssl')
conf.check_openssl()
def build(bld):
bld(source='main.cpp', target='app', use='OPENSSL')
'''
from waflib import Options
from waflib.Configure import conf
@conf
def check_openssl(self,*k,**kw):
root = k and k[0] or kw.get('path', None) or Options.options.with_openssl
mandatory = kw.get('mandatory', True)
var = kw.get('uselib_store', 'OPENSSL')
if root:
libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
msg='Checking for OpenSSL library',
define_name='HAVE_%s' % var,
global_define=True,
uselib_store=var,
mandatory=mandatory,
includes="%s/include" % root,
libpath="%s/lib" % root)
else:
libcrypto = self.check_cxx(lib=['ssl', 'crypto'],
msg='Checking for OpenSSL library',
define_name='HAVE_%s' % var,
uselib_store=var,
mandatory=mandatory)
def options(opt):
opt.add_option('--with-openssl', type='string', default=None,
dest='with_openssl', help='''Path to OpenSSL''')
-47
View File
@@ -1,47 +0,0 @@
#!/usr/bin/env python
# encoding: utf-8
# Philipp Bender, 2012
# Matt Clarkson, 2012
from waflib.Task import Task
from waflib.TaskGen import extension
"""
A simple tool to integrate protocol buffers into your build system.
def configure(conf):
conf.load('compiler_cxx cxx protoc')
def build(bld):
bld(
features = 'cxx cxxprogram'
source = 'main.cpp file1.proto proto/file2.proto',
include = '. proto',
target = 'executable')
"""
class protoc(Task):
run_str = '${PROTOC} ${PROTOC_FLAGS} ${PROTOC_ST:INCPATHS} ${SRC[0].abspath()}'
color = 'BLUE'
ext_out = ['.h', 'pb.cc']
@extension('.proto')
def process_protoc(self, node):
cpp_node = node.change_ext('.pb.cc')
hpp_node = node.change_ext('.pb.h')
self.create_task('protoc', node, [cpp_node, hpp_node])
self.source.append(cpp_node)
if 'cxx' in self.features and not self.env.PROTOC_FLAGS:
self.env.PROTOC_FLAGS = '--cpp_out=%s' % node.parent.get_bld().abspath()
use = getattr(self, 'use', '')
if not 'PROTOBUF' in use:
self.use = self.to_list(use) + ['PROTOBUF']
def configure(conf):
conf.check_cfg(package="protobuf", uselib_store="PROTOBUF", args=['--cflags', '--libs'])
conf.find_program('protoc', var='PROTOC')
conf.env.PROTOC_ST = '-I%s'
+22
View File
@@ -0,0 +1,22 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
def options(opt):
opt.add_option('--with-sanitizer', action='store', default='', dest='sanitizers',
help='Comma-separated list of compiler sanitizers to enable [default=none]')
def configure(conf):
for san in conf.options.sanitizers.split(','):
if not san:
continue
sanflag = '-fsanitize=%s' % san
conf.start_msg('Checking if compiler supports %s' % sanflag)
if conf.check_cxx(cxxflags=['-Werror', sanflag, '-fno-omit-frame-pointer'],
linkflags=[sanflag], mandatory=False):
conf.end_msg('yes')
conf.env.append_unique('CXXFLAGS', [sanflag, '-fno-omit-frame-pointer'])
conf.env.append_unique('LINKFLAGS', [sanflag])
else:
conf.end_msg('no', color='RED')
conf.fatal('%s sanitizer is not supported by the current compiler' % san)
+20 -10
View File
@@ -1,16 +1,19 @@
NLSR Authors
===========
============
NLSR is an open source project includes contributions from the members of the
[NDN project team](http://named-data.net/project/participants/).
## Project lead:
## Project co-leads:
* Vince Lehman <http://vslehman.com>
* Ashlesh Gawande <https://www.linkedin.com/in/agawande>
* Saurab Dulal <https://dulalsaurab.github.io>
## Past project leads:
* A K M Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
* Vince Lehman <http://vslehman.com>
* Nicholas Gordon <nmgordon@memphis.edu>
## Technical advisors:
@@ -24,26 +27,33 @@ NLSR is an open source project includes contributions from the members of the
* The University of Memphis
* A K M Mahmudul Hoque <https://sites.google.com/site/akmhoque/home>
* Ashlesh Gawande <agawande@memphis.edu>
* Minsheng Zhang <mzhang4@memphis.edu>
* Ashlesh Gawande <https://www.linkedin.com/in/agawande>
* Minsheng Zhang <https://www.linkedin.com/in/minsheng-zhang-032023a1>
* Syed Obaid Amin <http://obaidamin.weebly.com/>
* Vince Lehman <http://vslehman.com>
* Muktadir R Chowdhury <mrchwdhr@memphis.edu>
* Nicholas Gordon <nmgordon@memphis.edu>
* Laqin Fan <lfan1@memphis.edu>
* Damian Coomes <dmcoomes@memphis.edu>
* Saurab Dulal <sdulal@memphis.edu>
* University of California, Los Angeles
* Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/web/index.html>
* Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
* Spyridon Mastorakis <http://cs.ucla.edu/~mastorakis/>
* Jiewen Tan <alanwake@ucla.edu>
* Jiewen Tan <https://www.linkedin.com/in/jiewentan>
* University of Arizona
* Universidad Autónoma de San Luis Potosí (UASLP)
* Junxiao Shi <https://www.cs.arizona.edu/people/shijunxiao/>
* Pedro David Arjona Villicaña <david.arjona@uaslp.mx>
* Individual Contributor(s)
* Junxiao Shi <https://www.linkedin.com/in/shijunxiao>
* Davide Pesavento <https://www.linkedin.com/in/davidepesavento>
## Queries about NLSR
Any question related to NLSR should be directed to Ashlesh Gawande (agawande@memphis.edu),
Muktadir R Chowdhury (mrchwdhr@memphis.edu), and Nicholas Gordon (nmgordon@memphis.edu).
Any question related to NLSR should be directed to Ashlesh Gawande (agawande@memphis.edu), Saurab Dulal (sdulal@memphis.edu),
Muktadir R Chowdhury (mrchwdhr@memphis.edu).
+367 -388
View File
File diff suppressed because it is too large. Load diff
+6 -3
View File
@@ -28,10 +28,13 @@ Include the following header in all `.hpp` and `.cpp` files:
If you are affiliated with an NSF-supported NDN project institution,
please use the [NDN Team License Boilerplate]
(http://redmine.named-data.net/projects/nlsr/wiki/NDN_Team_License_Boilerplate_(NLSR)).
(https://redmine.named-data.net/projects/nlsr/wiki/NDN_Team_License_Boilerplate_(NLSR)).
Recommendations
---------------
NSLR code is subject to the code style, defined here:
http://redmine.named-data.net/projects/nfd/wiki/CodeStyle
NLSR code is subject to the code style, defined here:
https://redmine.named-data.net/projects/nfd/wiki/CodeStyle
NLSR Developer's guide can be found here:
https://github.com/named-data/NLSR/blob/developers-guide/NLSR-Developers-Guide.pdf
+14 -6
View File
@@ -4,6 +4,9 @@ NLSR - Named Data Link State Routing Protocol
For complete documentation and more extensive information,
please visit the [NLSR homepage](http://named-data.net/doc/NLSR/current/).
If you are new to the NDN community of software generally, read the
[Contributor's Guide](https://github.com/named-data/NFD/blob/master/CONTRIBUTING.md).
## Overview
NLSR is a routing protocol in NDN that populates NDN's Routing Information Base. NLSR
@@ -13,10 +16,10 @@ NLSR is an open and free software package licensed under the GPL 3.0 license and
Internet users and developers. For more information about the licensing details and
limitations, refer to [COPYING.md](https://github.com/named-data/NLSR/blob/master/COPYING.md).
NLSR is developed by the members of the [NSF-sponsored NDN project team](http://named-data.net/project/participants/).
NLSR is developed by the members of the [NSF-sponsored NDN project team](https://named-data.net/project/participants/).
For more details, please refer to [AUTHORS.md](https://github.com/named-data/NLSR/blob/master/AUTHORS.md).
Bug reports and feedback are highly appreciated and can be made through the
[Redmine site](http://redmine.named-data.net/projects/nlsr).
[Redmine site](https://redmine.named-data.net/projects/nlsr).
The main design goal of NLSR is to provide a routing protocol to populate NDN's FIB.
NLSR calculates the routing table using link-state or hyperbolic routing and produces
@@ -31,13 +34,18 @@ Source releases
The source code and source-code installation instructions are always available at
the following links:
- [Installation](http://named-data.net/doc/NLSR/current/INSTALL.html)
- [Getting Started with NLSR](http://named-data.net/doc/NLSR/current/GETTING-STARTED.html)
- [Installation](https://named-data.net/doc/NLSR/current/INSTALL.html)
- [Getting Started with NLSR](https://named-data.net/doc/NLSR/current/GETTING-STARTED.html)
- [GitHub NLSR repository](https://github.com/named-data/NLSR)
Additional information
----------------------
- [NLSR Wiki](http://redmine.named-data.net/projects/nlsr/wiki/)
- [Contributor's Guide](https://github.com/named-data/NFD/blob/master/CONTRIBUTING.md)
- [NLSR Wiki](https://redmine.named-data.net/projects/nlsr/wiki/)
- Feature requests and bug reports are welcome on our
[NLSR on NDN Redmine](http://redmine.named-data.net/projects/nlsr)
[NLSR on NDN Redmine](https://redmine.named-data.net/projects/nlsr)
- [NLSR Mailing List Sign Up](https://listserv.memphis.edu/scripts/wa.exe?GETPW1)
- [NLSR Mailing List](https://listserv.memphis.edu/scripts/wa.exe?SUBED1=NLSR-HELP-L&A=1)
- [NLSR Mailing List Archives](https://listserv.memphis.edu/scripts/wa.exe?A0=NLSR-HELP-L)
- [NLSR Developer's guide](https://github.com/named-data/NLSR/blob/developers-guide/NLSR-Developers-Guide.pdf)
+44 -2
View File
@@ -14,6 +14,20 @@ Installation
:doc:`INSTALL`
Important Notes About Configuration
-----------------------------------
Since v0.4.0, NLSR no longer creates Faces for the neighbors that are
specified in ``nlsr.conf``. Instead, it relies on the pre-existence of
the Faces in NFD. NLSR will obtain this information from NFD, and
configure its neighbors using this information.
For people who were relying on NLSR to automagically configure their
networks, this must now be done with ``nfdc``. Its documentation can
be found `here
<https://named-data.net/doc/NFD/current/manpages/nfdc.html>`_
Configuration
-------------
@@ -39,8 +53,36 @@ You can also run ``nlsr -f`` with the absolute path of the configuration file:
nlsr -f /usr/local/etc/ndn/nlsr.conf
To run NLSR as daemon, use the ``-d`` flag:
Logging
-------
NLSR uses the ndn-cxx logging facility. All levels listed below the selected log-level
value are enabled.
::
nlsr -d
Valid values:
TRACE trace messages (most verbose)
DEBUG debugging messages
INFO informational messages
WARN warning messages
ERROR error messages
FATAL fatal (will be logged unconditionally)
To obtain logs for NLSR, set the NDN_LOG environment variable with the correct prefix and
log-level settings. For example, running the following command will display all log
messages in NLSR with a DEBUG level or below.
::
NDN_LOG='nlsr.*=DEBUG' nlsr
If the user is presented with an error message `User does not have read and write
permission on the directory` it can be circumvented by running the application with sudo:
::
sudo env NDN_LOG='nlsr.*=DEBUG' nlsr
Use `man ndn-log` for more detailed instructions.
+11 -35
View File
@@ -7,52 +7,28 @@ NLSR Installation Instructions
Prerequisites
-------------
- `NFD <http://named-data.net/doc/NFD/current/>`_ and its requirements:
- `NFD <https://named-data.net/doc/NFD/>`_ and its requirements:
Refer to `Getting started with NFD <http://named-data.net/doc/NFD/current/INSTALL.html>`_
Refer to `Getting started with NFD <https://named-data.net/doc/NFD/current/INSTALL.html>`_
for detailed installation and running instruction.
- log4cxx library
- ChronoSync library:
On Ubuntu Linux:
Download the ChronoSync library and build it according to the instructions at the following
address:
::
sudo apt-get install liblog4cxx10-dev
https://github.com/named-data/ChronoSync#build
On OS X with MacPorts:
- PSync library:
Download the PSync library and build it according to the instructions at the following
address:
::
sudo port install log4cxx
- protobuf
On Ubuntu Linux:
::
sudo apt-get install libprotobuf-dev protobuf-compiler
On OS X with MacPorts:
::
sudo port install protobuf-cpp
- openssl
On Ubuntu Linux:
::
sudo apt-get install libssl-dev
On OS X with MacPorts:
::
sudo port install openssl
https://github.com/named-data/PSync#build
Build
-----
+3 -183
View File
@@ -1,184 +1,4 @@
Release Notes
=============
NLSR Release Notes
==================
NLSR version 0.3.0 (changes since version 0.2.2)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: August 1, 2016
**Code changes**:
- Do not advertise Adjacency LSAs when hyperbolic routing is enabled (:issue:`2402`)
- Do not distribute coordinate LSAs when using link-state routing. (:issue:`3661`)
- LSAs should be segmented before they are published (:issue:`2965`)
- Don't use DummyClientFace::sentDatas (:issue:`3383`)
- Remove disabled security files (:issue:`2960`)
- Lsa type should be argument for base class LSA constructor (:issue:`2788`)
- Use ndn-cxx/DummyClientFace (:issue:`2637`)
**Bug fixes**:
- Unit tests cases are installed with `./waf install` (:issue:`3359`)
NLSR version 0.2.2 (changes since version 0.2.1)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: January 5, 2016
**Code changes**:
- Adapt code to changes in NFD/ndn-cxx version 0.4.0 release
NLSR version 0.2.1 (changes since version 0.2.0)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: June 30, 2015
**Code changes**:
- Using a configuration file without ``prefix-update-validator`` disables runtime advertise/withdraw instead of exiting (:issue:`2814`)
**Bug fixes**:
- Prevent incomplete removal of NPT entry (:issue:`2785`)
- Correct bidirectional links with differing costs (:issue:`2801`)
- Fix non-incrementing Adjacency number in AdjLsa::writeLog (:issue:`2594`)
- Remove FaceDestroyEvent test's reliance on nlsrSeqNo.txt (:issue:`2881`)
- Test ACTIVE/INACTIVE Adjacencies in LSA construction (:issue:`2735`)
NLSR version 0.2.0 (changes since version 0.1.0)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: April 30, 2015
**Build**:
- The code now requires C++11. The minimum supported gcc version is 4.6, as earlier versions do not have proper support for C++11 features. (:issue:`1930`)
- Require OpenSSL (:issue:`2375`)
**New features**:
- Add nlsrc command-line tool (:issue:`1834`)
- Advertise/Withdraw name prefixes at runtime (:issue:`1834`)
- Assign zero cost to hyperbolic direct neighbors (:issue:`1975`)
- Only hyperbolic costs are adjusted before registering (:issue:`1974`)
- Add ability to specify different logging levels (:issue:`1935`)
- Add LSDB dataset publishers (:issue:`2280`)
- Add LSDB dataset tlv abstractions (:issue:`2280`)
- Allow zero cost neighbors for hyperbolic routing table calculation (:issue:`1982`)
- Faces are now created with canonical Face URI (:issue:`1911`)
- Add configurable router event intervals (:issue:`2071`)
- Add router-dead-interval configuration setting (:issue:`1878`)
- Add log formatting specified by log4cxx configuration file (:issue:`1950`)
- Face URIs in configuration file are checked for validity on load (:issue:`2070`)
- Configuration variables with default values are now optional (:issue:`1949`)
- Recalculate routing table after face destroy event (:issue:`2635`)
- Add Travis-CI build script
**Code changes**:
- Change adjacency status from uint32_t to enum (:issue:`1946`)
- Remove scheduler from NLSR class (:issue:`1981`)
- Change hyperbolic cost adjustment factor from 100 to 1000 (:issue:`1974`)
- Remove use of outdated namespace ``ndn::Tlv`` (:issue:`2079`)
- Remove use of deprecated ``ndn::nfd::Controller(Face&)`` constructor (:issue:`2133`)
- Routing update publishing is abstracted to SyncLogicHandler (:issue:`2289`)
- Make ConfParameter variable types consistent with min and max values (:issue:`2084`)
- Replace LSA string literals with constants (:issue:`2310`)
- Subscribe to FaceMonitor notifications using connect (:issue:`2350`)
- Log exceptions thrown in event loop
- Change ``ndn::ptr_lib::shared_ptr`` to ``std::shared_ptr`` (:issue:`2110`)
- Avoid deprecated ``ndn::Name::set`` method (:issue:`2505`)
- Update waf to version 1.8.8-dev
- Add sorting tiebreaker to NexthopList (:issue:`2715`)
- Update Jenkins-CI build scripts
**Bug fixes**:
- Fix python3 build error (:issue:`1956`)
- Fix typos in nlsr.conf security section (:issue:`1985`)
- Stop SyncLogicHandler from fetching a router’s own LSAs (:issue:`2005`)
- Fix Name LSA comparison which could cause incorrect advertised names to be removed (:issue:`2029`)
- Fix issue where more faces than max-faces-per-prefix could be applied to a prefix (:issue:`2018`)
- Stop LSDB from retrieving and out of date LSA when a new one is detected (:issue:`1987`)
- Correct mistakes in documentation
- Correct bitmask used to copy Name LSA sequence number (:issue:`2323`)
NLSR version 0.1.0 (initial release)
++++++++++++++++++++++++++++++++++++
Release date: August 25, 2014
The main design goal of NLSR is to provide a routing protocol to populate `NFD's
<http://named-data.net/doc/NFD/current/>`_ RIB. NLSR calculates the routing table using
link-state or hyperbolic routing and produces multiple faces for each reachable name
prefix in a single authoritative domain.
**Included features**:
- Advertise availability of content through the configured router
- Use `ChronoSync <https://github.com/named-data/ChronoSync>`_ to synchronize routers' LSA sequence numbers and Interest/Data to retrieve LSAs
- Produce a list of ranked forwarding options for each name prefix to facilitate NDN's adaptive forwarding strategies
- Configure maximum number of faces per prefix in NFD’s RIB
- Set up NFD tunnels to neighbors automatically and maintain the tunnels to neighbors
- Provide two routing protocols:
+ Link State routing: calculate route cost based on link costs
+ Hyperbolic routing: calculate route cost based on hyperbolic coordinates
- Use a hierarchical trust model for routing within a single administrative domain
- Keep NFD’s RIB updated on failure and recovery
.. include:: release-notes-latest.rst
+102 -25
View File
@@ -35,6 +35,9 @@ The number represents the connecting face id. For example,
We will walk through setting up the faces and creating the configuration file for
``/ndn/edu/memphis/%C1.Router/router1``.
It is recommended to configure security as described at :doc:`SECURITY-CONFIG`, before
starting router configuration.
Step 1. Ensuring nfd is running
-------------------------------
@@ -42,12 +45,21 @@ Type the following in the terminal:
::
nfd-status -f
nfd-status
If you see ``ERROR: error while connecting to the forwarder (No such file or directory)``,
If you see ``error while connecting to the forwarder (No such file or directory)``,
``nfd`` is not running. Follow the instructions in `Getting started with NFD
<http://named-data.net/doc/NFD/current/INSTALL.html>`_ to run nfd.
Since v0.4.0, NLSR no longer creates Faces for the neighbors that are
specified in ``nlsr.conf``. Instead, it relies on the pre-existence of
the Faces in NFD. NLSR will obtain this information from NFD, and
configure its neighbors using this information.
To create faces it is now necessary to use the ``nfdc`` command. Its documentation can
be found `here
<https://named-data.net/doc/NFD/current/manpages/nfdc.html>`_
Step 2. Determining FaceUri
---------------------------
@@ -83,11 +95,7 @@ configuration commands follows:
; InterestLifetime (in seconds) for LSA fetching
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
; log-level is to set the levels of log for NLSR
log-level INFO ; default value INFO, valid value DEBUG, INFO
log-dir /var/log/nlsr/
seq-dir /var/lib/nlsr/
; log4cxx-conf /path/to/log4cxx-conf
state-dir /var/lib/nlsr/ ; state directory to store all dynamic changes to NLSR
}
; the neighbors section contains the configuration for router's neighbors and hello's behavior
@@ -106,11 +114,12 @@ configuration commands follows:
hello-interval 60 ; interest sending interval in seconds. Default value 60
; valid values 30-90
; adj-lsa-build-interval is the time to wait in seconds after an Adjacency LSA build is scheduled
; before actually building the Adjacency LSA
; adj-lsa-build-interval is the time to wait in seconds after an Adjacency LSA
; build is scheduled before actually building the Adjacency LSA
adj-lsa-build-interval 5 ; default value 5. Valid values 0-5. It is recommended that
; adj-lsa-build-interval have a lower value than routing-calc-interval
; adj-lsa-build-interval have a lower value than
; routing-calc-interval
; first-hello-interval is the time to wait in seconds before sending the first Hello Interest
@@ -121,8 +130,8 @@ configuration commands follows:
neighbor
{
name /ndn/edu/arizona/%C1.Router/router3 ; name prefix of the neighbor router consists
; of network, site-name and router-name
name /ndn/edu/arizona/%C1.Router/router3 ; name prefix of the neighbor router consists
; of network, site-name and router-name
face-uri udp4://router3.arizona.edu ; face uri of the face connected to the neighbor
link-cost 25 ; cost of the connecting link to neighbor
@@ -130,7 +139,7 @@ configuration commands follows:
neighbor
{
name /ndn/edu/colostate/%C1.Router/router2 ; name prefix of the neighbor router consists
name /ndn/edu/colostate/%C1.Router/router2 ; name prefix of the neighbor router consists
; of network, site-name and router-name
face-uri udp4://79.123.10.145 ; face uri of the face connected to the neighbor
@@ -147,9 +156,9 @@ configuration commands follows:
; commands in this section follows a strict order
; the switch is used to set hyperbolic routing calculation in NLSR
state off ; default value 'off', set value 'on' to enable hyperbolic routing table
; calculation which turns link state routing 'off'. set value to 'dry-run'
; to test hyperbolic routing and compare with link state routing.
state off ; default value 'off', set value 'on' to enable hyperbolic routing table
; calculation which turns link state routing 'off'. set value to 'dry-run'
; to test hyperbolic routing and compare with link state routing.
radius 123.456 ; radius of the router in hyperbolic coordinate system
@@ -164,8 +173,8 @@ configuration commands follows:
; the max-faces-per-prefix is used to limit the number of faces for each name prefixes
; by NLSR in ndn FIB
max-faces-per-prefix 3 ; default value 0. Valid value 0-60. By default (value 0) NLSR adds
; all available faces for each reachable name prefixes in NDN FIB
max-faces-per-prefix 3 ; default value 0. Valid value 0-60. By default (value 0) NLSR adds
; all available faces for each reachable name prefixes in NDN FIB
}
@@ -182,10 +191,78 @@ configuration commands follows:
prefix /ndn/news/memphis/politics/lutherking
}
.. note::
By default NLSR's sequence file directory is set to ``/var/lib/nlsr/``. User must create this
directory before starting NLSR. Since this is a system directory, NLSR must either be executed
as root, or NLSR can be run as user "nlsr" after configuring the filesystem to grant "nlsr"
read and write permissions. If user lacks permissions, the following error will occur:
Security configuration is discussed in :doc:`SECURITY-CONFIG`, which will be also part
of this configuration file
::
User does not have read and write permission on the directory
Error in configuration file processing! Exiting from NLSR
To avoid this, the directory can be set in a user-owned directory. For example:
::
general
{
...
state-dir /home/username/nlsr/log ; path for sequence directory and other dynamic changes (Absolute path)
}
...
The user will encounter errors such as the following if security is not configured:
::
Cannot read certificate from file: /home/username/NLSR/root.cert
To get rid of this and similar errors relating to security one has to configure security
as described in :doc:`SECURITY-CONFIG`. Security can be disabled for testing purposes as follows:
::
...
trust-anchor
{
type any
;file-name "root.cert"
}
...
trust-anchor
{
type any
;file-name "site.cert"
}
; cert-to-publish "root.cert"
; cert-to-publish "router.cert"
; cert-to-publish "site.cert"
; cert-to-publish "router.cert"
Or by simply replacing the whole security section with:
::
security
{
validator
{
trust-anchor
{
type any
}
}
prefix-update-validator
{
trust-anchor
{
type any
}
}
}
Step 4: Running NLSR on /ndn/memphis.edu/router1
-------------------------------------------------
@@ -207,9 +284,9 @@ The same process needs to be followed for ``/ndn/arizona.edu/router3`` and
Expected Output
----------------
Assuming that all three routers are configured correctly and routing has converged, ``nfd-status`` in
``/ndn/edu/colostate/%C1.Router/router2`` will have the following entries for the name
advertised by ``/ndn/edu/memphis/%C1.Router/router1``:
Assuming that all three routers are configured correctly and routing has converged,
``nfd-status`` in ``/ndn/edu/colostate/%C1.Router/router2`` will have the following (or similar)
entries for the name advertised by ``/ndn/edu/memphis/%C1.Router/router1``:
RIB:
@@ -219,7 +296,7 @@ RIB:
/ndn/memphis/sports/basketball/grizzlies route={faceid=17 (origin=128 cost=25 ChildInherit), faceid=7 (origin=128 cost=58 ChildInherit)}
/ndn/news/memphis/politics/lutherking route={faceid=17 (origin=128 cost=25 ChildInherit, faceid=7 (origin=128 cost=58 ChildInherit)}
This output can be seen by typing ``nfd-status -r`` in the terminal. Please refer to the
This output can be seen by typing ``nfdc route list`` in the terminal. Please refer to the
network figure for face IDs.
.. _hyperbolic routing table calculation: http://arxiv.org/abs/0805.1266
+15 -7
View File
@@ -20,7 +20,7 @@ The trust model of NLSR is semi-hierarchical. An example certificate signing hie
router1 router2 router3 router4 router5 router6 router7
| | | | | | |
+ + + + + + +
NLSR NSLR NSLR NSLR NSLR NSLR NSLR
NLSR NLSR NLSR NLSR NLSR NLSR NLSR
Each entity's name and corresponding certificate name follow the
convention below:
@@ -28,14 +28,22 @@ convention below:
======== ===================================================== ================================= ===============================================
Entity Identity Name Example Certificate Name Example
-------- ----------------------------------------------------- --------------------------------- -----------------------------------------------
root /\<network\> /ndn /ndn/KEY/ksk-1/ID-CERT/%01
site /\<network\>/\<site\> /ndn/edu/ucla /ndn/edu/ucla/KEY/ksk-2/ID-CERT/%01
operator /\<network\>/\<site\>/%C1.Operator/\<operator-name\> /ndn/edu/ucla/%C1.Operator/op1 /ndn/edu/ucla/%C1.Operator/op1/KEY/ksk-3/ID-CERT/%01
router /\<network\>/\<site\>/%C1.Router/\<router-name\> /ndn/edu/ucla/%C1.Router/rt1 /ndn/edu/ucla/%C1.Router/rt1/KEY/ksk-4/ID-CERT/%01
NLSR /\<network\>/\<site\>/%C1.Router/\<router-name\>/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR/KEY/ksk-5/ID-CERT/%01
root /\<network\> /ndn /ndn/KEY/1/%00/%01
site /\<network\>/\<site\> /ndn/edu/ucla /ndn/edu/ucla/KEY/2/%00/%01
operator /\<network\>/\<site\>/%C1.Operator/\<operator-name\> /ndn/edu/ucla/%C1.Operator/op1 /ndn/edu/ucla/%C1.Operator/op1/KEY/3/%00/%01
router /\<network\>/\<site\>/%C1.Router/\<router-name\> /ndn/edu/ucla/%C1.Router/rt1 /ndn/edu/ucla/%C1.Router/rt1/KEY/4/%00/%01
NLSR /\<network\>/\<site\>/%C1.Router/\<router-name\>/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR /ndn/edu/ucla/%C1.Router/rt1/NLSR/KEY/5/%00/%01
======== ===================================================== ================================= ===============================================
Users should create keys according to the naming and signing hierarchies above.
Users should create keys according to the naming and signing hierarchies above. The
``%C1.Operator`` and ``%C1.Router`` labels are NDN keywords that should not be modified
by the user.
.. note::
Detailed information about key setup is given in NLSR Developer's Guide and the
:doc:`beginners-guide`.
Certificate Publishing
----------------------
+888
View File
@@ -0,0 +1,888 @@
==========================================================
A beginners guide to installing and testing NLSR on Fedora
==========================================================
:Authors: David Arjona-Villicaña, Octavio Renteria-Vidales, Ashlesh Gawande
:Date: November, 2018
:Abstract: This is an easy to follow guide on how to install and test the NLSR routing protocol for NDN using two Fedora 28 machines. The commands and the paths used in this guide have been tested only in Fedora, although a similar procedure should be used for other linux systems. Specifically, the testing section (§ `5 <#test>`__) is platform independent. Therefore users who have NLSR already installed may skip to this section. Since neither NDN, NLSR nor Fedora are static software developments, it is expected that some commands and features in this guide will change over time. However, this guide is as accurate as it could be at the time it was published.
.. role:: raw-latex(raw)
:format: latex
.. _intro:
1. Introduction
===============
The following instructions are based on the information provided at the
Named Data Networking project web page [NDNmain]_.
Before installing NLSR it is necessary to install different libraries
and programs: ndn-cxx, NFD, ChronoSync, and PSync. This document describes the
necessary steps to correctly install these programs (§ `2 <#ndncxx>`__,
`3 <#nfd>`__ and `4 <#nlsr>`__) and a brief guide on how to configure
and test NLSR using a simple two-node network (§ `5 <#test>`__).
Many of the commands in this guide need to be executed as *root*.
Starting from Fedora 28, there is no need to set a root user
[Kolman2018]_. However it is possible to define it,
using the following command:
::
$ sudo -i
And then using the *passwd* command to set up a password. After setting
up the root user, it is possible to become root by employing the
following command and providing the root password when prompted:
::
$ su -
Fedora employs the *dnf* command to install and verify installed
packages. The following commands may become useful during the
installation process and should be executed as root:
- To verify that all installed packages are up to date
::
$ dnf update
- To verify if a package is already installed in the system
::
$ dnf list --installed <package-name>
- To search for information about a package or family of packages (not
necessarily installed in the system).
::
$ dnf info <package-name>
- To install a package in the system.
::
$ dnf install <package-name>
It is also a good installation practice to download and install all the
NDN programs in a common directory. Therefore, it is recommended to
create a directory at the home directory where all the following
programs may get installed. The name of this directory is not important.
However, the following are provided as suggestions: project, NDNproject,
NDNprograms. Each of the programs in the following sections should be
downloaded to their own directory using the *git* command, and then
compiled in this directory.
.. _ndncxx:
2. Installing ndn-cxx
=====================
2.1 Before installing ndn-cxx
-----------------------------
An updated list of the packages and programs that need to be installed
before installing ndn-cxx, is provided at [NDN-cxx]_.
This list is also reproduced bellow with the commands to verify that all
the packages have been installed in the system. The following commands
should be run as root:
#. gcc and gcc-c++
::
$ dnf list --installed gcc
$ dnf list --installed gcc-c++
#. Python version 2.6 or later
::
$ python -V
#. libsqlite3
::
$ dnf list --installed sqlite
$ dnf list --installed sqlite-devel
#. openssl version 1.0.1 or later
::
$ openssl version
$ dnf list --installed openssl-devel
#. pkgconf that replaces pkg-config
::
$ dnf list --installed pkgconf*
#. boost libraries version 1.54 or later
::
$ dnf list --installed boost
$ dnf list --installed boost-devel
#. doxygen
::
$ dnf list --installed doxygen
#. graphviz
::
$ dnf list --installed graphviz
#. python2-sphinx that replaces python-sphinx
::
$ dnf list --installed python2-sphinx
#. After verifying that the python-sphinx package has been installed, it
is necessary to run the following two commands:
::
$ pip-3 install sphinxcontrib-doxylink
$ pip install sphinxcontrib-googleanalytics
Note: When the two previous commands are run before correctly
installing python-sphinx, the following error message is produced
when trying to install this latter package: “Error unpacking rpm
package python2-urllib3-1.22-3.fc27.noarch”. To fix this problem, it
is necessary to run the following commands before installing
python-sphinx again:
::
$ dnf remove python2-sphinx
$ pip uninstall sphinxcontrib-googleanalytics
$ pip-3 uninstall sphinxcontrib-doxylink
$ pip uninstall urllib3
#. dpkg-architecture
::
$ dnf list --installed dpkg
$ dnf list --installed dpkg-dev
#. git and valgrind, which is used when installing NFD (§
`3 <#nfd>`__).
::
$ dnf list --installed valgrind
$ dnf list --installed valgrind-devel
$ dnf list --installed git
2.2 Downloading and installing ndn-cxx
--------------------------------------
The *git* command allows to download the ndn-cxx library in its own
folder, also called *ndn-cxx*. Therefore it is recommended to execute
this command at the directory created at § `1 <#intro>`__:
::
$ git clone --depth 1 https://github.com/named-data/ndn-cxx.git
Move to the ndn-cxx directory:
::
$ cd ndn-cxx
Use the following command to verify that everything is ready to compile.
If an error message displays, it is necessary to fix it before
continuing:
::
$ ./waf configure --with-examples
Compile the ndn-cxx library and install the compiled files at the
system’s directories:
::
$ ./waf
$ sudo ./waf install
2.3 Configuring ndn-cxx
-----------------------
The commands in this subsection need to be run as root. First, it is
necessary to create file *local.conf*, which contains a line with the
location for the ndn-cxx library:
::
$ echo /usr/local/lib64 >> /etc/ld.so.conf.d/local.conf
The following command configures the libraries:
::
$ ldconfig -v | grep ndn
This command should display a line similar to the following:
::
libndn-cxx.so.0.6.1 -> libndn-cxx.so.0.6.1
Configure the NDN path:
::
$ echo export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig >>
/etc/profile.d/ndn.sh
After this command has been executed, it is necessary to apply the
changes by either logging out and back in, and then running the
following command:
::
$ printenv | grep PKG
Or by executing the following command:
::
$ ./etc/profile.d/ndn.sh
For more information and examples about how to compile and configure
this library, users should read the ndn-cxx guide at
[NDN-cxx]_.
.. _nfd:
3. Installing NFD
=================
3.1 Before installing NFD
-------------------------
An updated list of the packages and programs that need to be installed
before NFD is provided at [NDNNFD]_. Before installing
NFD it is necessary to verify that the following packages are installed:
#. libpcap libraries
::
$ dnf list --installed libpcap
$ dnf list --installed libpcap-devel
3.2 Downloading and installing NFD
----------------------------------
This library is downloaded and installed in a folder called *NFD*, which
should be created at the directory defined at § `1 <#intro>`__. The
following commands need to be run as a regular user:
::
$ git clone --depth 1 https://github.com/named-data/NFD.git
$ cd NFD
$ ./waf configure
If the previous command prints an error message saying that waf cannot
find WebSocket, it is necessary to follow the instructions provided by
this same output, which tells the user to execute either of the
following two set of commands:
::
$ git submodule init && git submodule update
Or:
::
$ mkdir websocketpp
$ curl -L https://github.com/zaphoyd/websocketpp/archive/0.7.0.tar.gz
> websocket.tar.gz
$ tar zxf websocket.tar.gz -C websocketpp/ --strip 1
After executing either of these instructions, complete the configuration
by running *./waf configure* again. Then complete the installation by
means of the following commands:
::
$ ./waf
$ sudo ./waf install
3.3 Configuring NFD
-------------------
Create a configuration file by running the following command as root:
::
$ cp /usr/local/etc/ndn/nfd.conf.sample /usr/local/etc/ndn/nfd.conf
After the configuration file has been created, NFD’s behavior may be
changed by modifying this file. Once the configuration file has been
created, it is recommended to start NFD by using the following command:
::
$ nfd-start
This command does not properly allow to employ the command window to
enter new commands; however it displays the NFD logs. Therefore, it is
recommended to open a new command window. This second window may be used
to verify NDF’s status and then stop NFD by using the following
commands:
::
$ nfd-status
$ nfd-stop
.. _nlsr:
4. Installing NLSR
==================
4.1 Installing ChronoSync
-------------------------
Before installing NLSR, it is necessary to first download and install
ChronoSync, which is a synchronization library which allows NLSR routers
to synchronize Link State Advertisements (LSAs). More information about
ChronoSync may be found at [Chronosync]_. This library may be
installed by running the following commands as a regular user and at the
directory defined at § `1 <#intro>`__:
::
$ git clone --depth 1 https://github.com/named-data/ChronoSync.git
$ cd ChronoSync
$ ./waf configure
$ ./waf
$ sudo ./waf install
The following command needs to be used again to configure the libraries:
::
$ sudo ldconfig -v | grep -i chronosync
This command should display a line similar to the following:
::
libChronoSync.so.0.5.0 -> libChronoSync.so.0.5.0
4.2 Installing PSync
-------------------------
Before installing NLSR, it is also necessary to download and install
PSync. PSync is a synchronization library which allows NLSR to synchronize LSAs
similar to ChronoSync. More information about PSync may be found at [PSync]_.
This library may be installed by running the following commands as a regular
user and at the directory defined at § `1 <#intro>`__:
::
$ git clone --depth 1 https://github.com/named-data/PSync.git
$ cd PSync
$ ./waf configure
$ ./waf
$ sudo ./waf install
The following command needs to be used again to configure the libraries:
::
$ sudo ldconfig -v | grep -i psync
This command should display a line similar to the following:
::
libPSync.so.0.1.0 -> libPSync.so.0.1.0
4.3 Downloading and installing NLSR
-----------------------------------
NLSR is downloaded and installed in a folder called *NLSR* which should
be created at the directory defined at § `1 <#intro>`__. The following
commands need to be run as a regular user:
::
$ git clone --depth 1 https://github.com/named-data/NLSR.git
$ cd NLSR
$ ./waf configure
$ ./waf
$ sudo ./waf install
4.4 Configuring NLSR
--------------------
Create and configure the following directory by running the following
commands as root:
::
$ mkdir /var/lib/nlsr
$ chmod 777 /var/lib/nlsr
.. _test:
5. Configuring and Testing NLSR
===============================
To test NLSR, the first step is to configure the keys and certificates
that implement a secure communication between the routers. Then it is
necessary to verify that the computers in the test network are
connected, that NFD is running and the faces between the computers are
configured. Finally, the NLSR configuration file has to be edited before
running NLSR. The following subsections are provided as a guide to
define and configure a simple computer network between two computers:
router1 and router2.
.. _security:
5.1 Setting up the security
---------------------------
Configuring security in an NDN network requires to generate, exchange
and install, keys and certificates between the root, site, operator and
router computers that form the network
[NLSRsecconf]_, [NLSRdevguide]_, although in practice, it
is possible to keep more than one of these entities in a single machine.
The following example and *Figure 1* show how to configure security
for a single router, called Router X. In this example, the root, site,
operator and Router X are in different computers:
.. figure:: security_comp.png
:alt: Security configuration example for Router X.
:width: 19cm
:align: center
Fig. 1. Security configuration example for Router X.
#. At the root server, generate the root key:
::
$ ndnsec-key-gen /ndn/ > root.key
#. Generate the certificate for the root key at the root server:
::
$ ndnsec-cert-dump -i /ndn/ > root.cert
#. Install the root certificate at the root server:
::
$ ndnsec-cert-install -f root.cert
#. At the site server, generate the site key:
::
$ ndnsec-key-gen /ndn/edu/uaslp > site.key
#. Copy the site key to the root server and generate the certificate for
the site server:
::
$ ndnsec-cert-gen -s /ndn/ site.key > site.cert
#. Copy the site certificate to the site server and install it:
::
$ ndnsec-cert-install -f site.cert
#. At the operator server, generate the operator key:
::
$ ndnsec-key-gen /ndn/edu/uaslp/%C1.Operator/op > op.key
#. Copy the operator key to the site server and generate the certificate
for the operator server:
::
$ ndnsec-cert-gen -s /ndn/edu/uaslp op.key > op.cert
#. Copy the operator certificate to the operator server and install it:
::
$ ndnsec-cert-install -f op.cert
#. At the router, generate the router key:
::
$ ndnsec-key-gen /ndn/edu/uaslp/%C1.Router/routerX > routerX.key
#. Copy the router key to the operator server and generate the
certificate for the router:
::
$ ndnsec-cert-gen -s /ndn/edu/uaslp/%C1.Operator/op routerX.key >
routerX.cert
#. Copy the router certificate to the router and install it:
::
$ ndnsec-cert-install -f routerX.cert
In the previous steps, the *%C1.Router* and *%C1.Operator* labels are
NDN keywords and should not be changed. These labels will be also used
by the configuration file (§ `5.4 <#configfile>`__)
The following command may be used to verify that the certificates have
been installed in a computer:
::
$ ndnsec-list
This guide recommends that one machine functions as the root, site,
operator and router1, while a different computer only functions as
router2. *Figure 2* shows this
configuration. For router1, the twelve steps described before need to be
executed except for exchanging files between computers. For the router2,
only steps 10 to 12 are needed to generate this router’s certificate.
Additionally, the following command may be used to print a list and a
brief description of all the *ndnsec* commands:
::
$ man ndnsec
.. figure:: netwk1.png
:alt: Example network.
:width: 19cm
:align: center
Fig. 2. Example network.
5.2 Configuring the network
---------------------------
The first step is to configure the physical network. If two computers
are going to get connected using a single Ethernet cable, it is
necessary to verify that this cable is a crossover. The other option is
to employ a switch between two computers that are then connected using
two regular Ethernet cables.
After the physical network has been assembled, it is necessary to
configure the network addresses and cards for all the computers in the
network. It is important to remember that computers that are connected
to each other should use the same subnetwork address. It is possible to
verify the network configuration in a Linux computer by means of the *ip
addr* command
Once the physical network and network cards have been configured, it is
necessary to verify that the computers can communicate with each other.
The simplest way to do this is by using the *ping* command:
::
$ ping <remote-ip-address>
5.3 Starting and configuring NFD
--------------------------------
To start and configure NFD it is necessary to open two terminal windows.
The first one will be used to start NFD by means of the *nfd-start*
command. This terminal will also display the logs that NFD generates. By
default, NFD only generates informational logs (INFO). However, it is
possible to obtain different levels of verbosity for these logs. These
levels can be set before NFD starts by editing the
*/usr/local/etc/ndn/nfd.conf* file. Open this file using a regular text
editor, read the information provided about logging and then modify the
*default-level* variable at the *log* section according to the
instructions provided in the file. Additional information about NFD
configuration may be found at [NDNNFDusage]_.
The second terminal will be used to monitor the NFD status:
::
$ nfd-status
Employ the following command to configure each face that a computer uses
to connect to a neighboring computer:
::
$ nfdc face create udp4://<remote-ip-address>
The face id may be displayed by running either *nfd-status* or:
::
$ nfdc face list
The status of the face may be verified by using the following command:
::
$ nfdc face show id <face-id>
After finishing NLSR testing, it is necessary to destroy the face before
stopping NFD. This operation is described at § `5.6 <#turn_off>`__. For
the two computer network provided as an example (*Figure 2*), it is necessary that both
machines run NFD and that each one configures a face that connects to
the other machine.
.. _configfile:
5.4 Setting up the configuration file
-------------------------------------
Instructions on how to use the configuration file are already provided
at the NLSR’s Router Configuration page [NLSRrtrconf]_.
Read the information in this page to understand NLSR router
configuration. The following text describes the instructions that have
been modified at the default nlsr.conf file for router1:
::
; AT general SECTION:
{
network /ndn/ ; name of the network
site /edu/uaslp ; name of the site
router /%C1.Router/router1 ; name of the router: router1
}
;AT neighbors SECTION:
neighbors
{
neighbor
{
name /ndn/edu/uaslp/%C1.Router/router2 ; Neighbor router: router2
face-uri udp://140.220.80.124 ; face to the neighbor
link-cost 30 ; cost of the link
}
}
; AT advertising SECTION:
advertising
{
prefix /ndn/edu/uaslp/office/bldg1 ; Advertising destinations
prefix /ndn/edu/uaslp/office/bldg2 ; for router1
}
; AT security SECTION:
security
{
validator
{
...
trust-anchor
{
type file
file-name "root.cert" ; root certificate file
}
}
prefix-update-validator
{
...
trust-anchor
{
type file
file-name "site.cert" ; site certificate file
}
}
cert-to-publish "root.cert" ; root certificate file
cert-to-publish "site.cert" ; site certificate file
cert-to-publish "op.cert" ; operator certificate file
cert-to-publish "router1.cert" ; router1 certificate file
}
The following text shows the modified instructions for router2:
::
; AT general SECTION:
{
network /ndn/ ; name of the network
site /edu/uaslp ; name of the site
router /%C1.Router/router2 ; name of the router: router2
}
;AT neighbors SECTION:
neighbors
{
neighbor
{
name /ndn/edu/uaslp/%C1.Router/router1 ; Neighbor router: router1
face-uri udp://140.220.80.121 ; face to the neighbor
link-cost 30 ; cost of the link
}
}
; AT advertising SECTION:
advertising
{
prefix /ndn/edu/uaslp/labs/networks ; Advertising destinations
prefix /ndn/edu/uaslp/labs/hardware ; for router2
}
; AT security SECTION:
security
{
validator
{
...
trust-anchor
{
type file
file-name "root.cert" ; root certificate file
} ; this file needs to be copied to
} ; router2
prefix-update-validator
{
...
trust-anchor
{
type file
file-name "site.cert" ; site certificate file
} ; this file needs to be copied to
} ; router2
...
cert-to-publish "router2.cert" ; router2 certificate file
}
Notice that files *root.cert* and *site.cert*, which were generated at
router1, need to be copied to router2. Also notice that the *%C1.Router*
and *%C1.Operator* keywords employed at § `5.1 <#security>`__ are also
referenced by these configuration files.
.. _starting_nlsr:
5.5 Starting NLSR
-----------------
It is recommended to open a third command terminal and run NLSR in this
window. After the NLSR configuration file has been edited and saved as
*nlsr.conf*, it is possible to start NLSR by running either of the
following two commands:
::
$ nlsr
$ nlsr -f <configuration-file>
However, to verify what is NLSR doing, it becomes necessary to employ
NLSR’s logging facility [NLSRstarting]_. A brief
description on how to use NDN’s logging facility may be displayed by
entering the *man ndn-log* command. This guide recommends using one of
the following two instructions to start NLSR:
::
$ export NDN_LOG=nlsr.*=TRACE && nlsr
$ export NDN_LOG=nlsr.*=TRACE && nlsr -f <configuration-file>
The second terminal window may be used to run *nfd-status* again and it
should be possible to verify that the status has changed, specially at
the FIB and RIB sections of the generated report.
.. _turn_off:
5.6 Turning everything off
--------------------------
In order to stop NLSR and NFD, the following sequence of events is
recommended:
#. Stop NLSR by pressing the Ctrl+C keys at the third terminal window.
#. Destroy the face to the remote computers using either of the
following two commands at the second terminal window:
::
$ nfdc face destroy <face-id>
$ nfdc face destroy udp4://<remote-ip-address>
#. Stop NFD by entering the following command at the second terminal
window:
::
$ nfd-stop
#. The crossover Ethernet cable may be unplugged and the computers’
network configuration restored to its original settings.
5.7 Where to go from here
-------------------------
Users interested in building and configuring larger networks may want to
take a look at the NDN Ansible repository
[NDNAnsible]_. This repository uses Ansible, which is a
configuration management tool, to manage the official NDN testbed
deployment [NDNTestbed]_.
.. [NDNmain] *Named Data Networking*, http://named-data.net/, March 2018.
.. [Kolman2018] M. Kolman. *Anaconda improvements in Fedora 28*, Fedora Magazine, June 2018.
.. [NDN-cxx] *Getting started with ndn-cxx*, http://named-data.net/doc/ndn-cxx/current/INSTALL.html, April 2018.
.. [NDNNFD] *Getting started with NFD*, http://named-data.net/doc/NFD/current/INSTALL.html, April 2018.
.. [NDNNFDusage] *NFD usage*, http://named-data.net/doc/NFD/current/manpages/nfd.html, May 2018.
.. [Chronosync] Z. Zhu and A. Afanasyev. *Let’s ChronoSync: Decentralized dataset state synchronization in Named Data Networking*, in IEEE ICNP, October 2013.
.. [PSync] M. Zhang, V. Lehman, and L. Wang. *Scalable Name-based Data Synchronization for Named Data Networking*, in IEEE INFOCOM, May 2017.
.. [NLSRsecconf] *NLSR Security Configuration*, http://named-data.net/doc/NLSR/current/SECURITY-CONFIG.html June 2018.
.. [NLSRdevguide] V. Lehman, M. Chowdhury, N. Gordon, A. Gawande. *NLSR Developer’s Guide*, University of Memphis, November 2017.
.. [NLSRrtrconf] *NLSR Router Configuration*, http://named-data.net/doc/NLSR/current/ROUTER-CONFIG.html, April 2018.
.. [NLSRstarting] *Getting Started with NLSR*, http://named-data.net/doc/NLSR/current/GETTING-STARTED.html, May 2018.
.. [NDNAnsible] *NDN Ansible repository*, https://github.com/WU-ARL/NDN_Ansible, October 2018.
.. [NDNTestbed] *NDN Testbed*, https://named-data.net/ndn-testbed/, October 2018.
+7 -5
View File
@@ -12,6 +12,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import datetime
import sys
import os
@@ -30,7 +31,7 @@ sys.path.insert(0, os.path.abspath('.'))
# ones.
extensions = [
'sphinx.ext.todo',
'redmine_issue',
'redmine_issue'
]
def addExtensionIfExists(extension):
@@ -43,8 +44,9 @@ def addExtensionIfExists(extension):
sys.stderr.write("To install, use \n"
" sudo pip install %s\n" % extension.replace('.', '-'))
if os.getenv('GOOGLE_ANALYTICS', None):
addExtensionIfExists('sphinxcontrib.googleanalytics')
# sphinxcontrib.googleanalytics is currently not working with the latest version of sphinx
# if os.getenv('GOOGLE_ANALYTICS', None):
# addExtensionIfExists('sphinxcontrib.googleanalytics')
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -60,7 +62,7 @@ master_doc = 'index'
# General information about the project.
project = u'NLSR - Named Data Link State Routing Protocol'
copyright = u'2014-2015, Named Data Networking Project'
copyright = u'2014-{}, Named Data Networking Project'.format(datetime.date.today().year)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -251,4 +253,4 @@ if os.getenv('GOOGLE_ANALYTICS', None):
googleanalytics_id = os.environ['GOOGLE_ANALYTICS']
googleanalytics_enabled = True
redmine_project_url = "http://redmine.named-data.net/"
redmine_project_url = "https://redmine.named-data.net/"
+4 -4
View File
@@ -408,7 +408,7 @@ EXTRACT_PRIVATE = NO
# scope will be included in the documentation.
# The default value is: NO.
EXTRACT_PACKAGE = NO
EXTRACT_PACKAGE = YES
# If the EXTRACT_STATIC tag is set to YES all static members of a file will be
# included in the documentation.
@@ -2025,7 +2025,7 @@ MSCGEN_PATH =
# and usage relations if the target is undocumented or is not a class.
# The default value is: YES.
HIDE_UNDOC_RELATIONS = YES
HIDE_UNDOC_RELATIONS = NO
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz (see:
@@ -2150,7 +2150,7 @@ INCLUDED_BY_GRAPH = YES
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
CALL_GRAPH = NO
CALL_GRAPH = YES
# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
# dependency graph for every global function or class method.
@@ -2161,7 +2161,7 @@ CALL_GRAPH = NO
# The default value is: NO.
# This tag requires that the tag HAVE_DOT is set to YES.
CALLER_GRAPH = NO
CALLER_GRAPH = YES
# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
# hierarchy of all classes instead of a textual one.
+30 -7
View File
@@ -3,7 +3,7 @@ NLSR - Named Data Link State Routing Protocol
NLSR is a routing protocol in NDN that populates NDN's Routing Information Base. NLSR will
continue to evolve alongside the Named Data Networking `protocol
<http://named-data.net/doc/ndn-tlv/>`_.
<https://named-data.net/doc/ndn-tlv/>`_.
NLSR is an open and free software package licensed under the GPL 3.0 license and free to
all Internet users and developers. For more information about the licensing details and
@@ -11,7 +11,7 @@ limitations, refer to `COPYING.md
<https://github.com/named-data/NLSR/blob/master/COPYING.md>`_.
NLSR is developed by the members of the `NSF-sponsored NDN project team
<http://named-data.net/project/participants/>`_. For more details, please refer to
<https://named-data.net/project/participants/>`_. For more details, please refer to
`AUTHORS.md <https://github.com/named-data/NLSR/blob/master/AUTHORS.md>`_. Bug reports and
feedback are highly appreciated and can be made through the `NLSR Wiki`_.
@@ -29,33 +29,56 @@ NLSR Documentation
:hidden:
:maxdepth: 3
RELEASE-NOTES
GETTING-STARTED
INSTALL
ROUTER-CONFIG
SECURITY-CONFIG
ROUTER-CONFIG
RELEASE-NOTES
releases
manpages
beginners-guide
- :doc:`GETTING-STARTED`
- :doc:`INSTALL`
- :doc:`ROUTER-CONFIG`
- :doc:`SECURITY-CONFIG`
- :doc:`ROUTER-CONFIG`
- :doc:`RELEASE-NOTES`
- :doc:`releases`
- :doc:`manpages`
- :doc:`beginners-guide`
Downloading
-----------
- `GitHub NLSR repository <https://github.com/named-data/NLSR>`_
NLSR mailing list
-----------------
- `NLSR Mailing List`_
- `NLSR Mailing List Archives`_
`Sign up`_ is needed to post to the list or access the archives.
Additional information
----------------------
- `NLSR Wiki`_
- `NLSR Redmine`_
Feature requests and bug reports
- `NLSR Paper`_
Detailed explanation of the NLSR design
- `NLSR Developer's Guide`_
For NLSR Development
.. _NLSR Wiki: http://redmine.named-data.net/projects/nlsr
.. _NLSR Paper: http://www.cs.memphis.edu/~lanwang/paper/nlsr-final.pdf
.. _NLSR Wiki: https://redmine.named-data.net/projects/nlsr/wiki
.. _NLSR Paper: https://named-data.net/wp-content/uploads/2016/01/ndn-0037-1-nlsr.pdf
.. _NLSR Mailing List: https://listserv.memphis.edu/scripts/wa.exe?SUBED1=NLSR-HELP-L&A=1
.. _NLSR Mailing List Archives: https://listserv.memphis.edu/scripts/wa.exe?A0=NLSR-HELP-L
.. _NLSR Developer's Guide: https://github.com/named-data/NLSR/blob/developers-guide/NLSR-Developers-Guide.pdf
.. _Sign up: https://listserv.memphis.edu/scripts/wa.exe?GETPW1
.. _NLSR Redmine: https://redmine.named-data.net/projects/nlsr
+2 -12
View File
@@ -12,16 +12,12 @@ Usage
Description
-----------
``nlsr`` is a daemon that implements routing protocol in NDN to populates NDN's Routing
``nlsr`` is a process that implements routing protocol in NDN to populate NDN's Routing
Information Base.
Options:
--------
``-d``
Run in daemon mode
``-f <FILE>``
Specify configuration file name (default: ``./nlsr.conf``)
@@ -34,14 +30,8 @@ Options:
Examples
--------
To run NLSR daemon and use a configuration file from the ``/path/to`` directory.
To run NLSR and use a configuration file from the ``/path/to`` directory.
::
nlsr -f /path/to/nlsr.conf
To run NLSR as daemon, use the ``-d`` flag:
::
nlsr -d
+30 -1
View File
@@ -26,9 +26,15 @@ Options
``COMMAND``
``status``
``lsdb``
Retrieve LSDB status information
``routing``
Retrieve routing table status information
``status``
Retrieve LSDB status and routing table status information
``advertise``
Add a Name prefix to be advertised by NLSR
@@ -37,6 +43,11 @@ Options
``name``
The Name prefix to be advertised
``advertise <name> save``
``save``
Advertise a prefix and also save it to the nlsr.conf file residing in the state-dir for the next start of NLSR that operator may copy and use for the next start of NLSR
``withdraw``
Remove a Name prefix advertised through NLSR
@@ -45,6 +56,24 @@ Options
``name``
The Name prefix to be withdrawn
``withdraw <name> delete``
``delete``
Withdraw a prefix and also delete it from the nlsr.conf file residing in the state-dir
Notes
-----
When security is enabled, NLSR will not be allowed to successfully
advertise/withdraw names without first setting a default identity of operator.
If default identity is not set as operator, the user will be presented with the
error message: “Name prefix update error (code: 403)”. To remedy this
issue, use command 'ndn-sec-default'.
Example:
ndnsec-set-default /ndn/a-site/%C1.Operator/op
Exit Status
-----------
+6 -15
View File
@@ -12,7 +12,7 @@
<div class="row">
<div class="three columns">
<div id="logo">
<a href="http://named-data.net" title="A Future Internet Architecture"><img src="http://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
<a href="https://named-data.net" title="A Future Internet Architecture"><img src="https://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
</div><!--logo end-->
</div>
@@ -38,12 +38,14 @@
<h3>{{ _('Table Of Contents') }}</h3>
{{ toctree(includehidden=True) }}
<h3>{{ _('Additional documenation') }}</h3>
<h3>{{ _('Developer documentation') }}</h3>
<ul>
<li class="toctree-l1"><a class="reference external" href="http://redmine.named-data.net/projects/nlsr/wiki">NLSR Wiki</a></li>
<li class="toctree-l1"><a class="reference external" href="https://redmine.named-data.net/projects/nlsr/wiki">NLSR Wiki</a></li>
<li class="toctree-l1"><a class="reference internal" href="doxygen/annotated.html">API documentation (doxygen)</a></li>
<li class="toctree-l1"><a class="reference internal" href="code-style.html">ndn-cxx Code Style and Coding Guidelines</a></li>
</ul>
{%- endblock %}
{%- block sidebarsearch %}
<h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3>
<form class="search" action="{{ pathto('search') }}" method="get">
@@ -74,22 +76,11 @@
<div class="row">
<div class="twelve columns">
<div id="copyright">This research is partially supported by NSF (Award <a href="http://www.nsf.gov/awardsearch/showAward?AWD_ID=1040868" target="_blank>">CNS-1040868</a>)<br/><br/><a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US" target="_blank">Creative Commons Attribution 3.0 Unported License</a> except where noted.</div>
<div id="copyright">This research is partially supported by NSF (Award <a href="https://www.nsf.gov/awardsearch/showAward?AWD_ID=1040868" target="_blank>">CNS-1040868</a>)<br/><br/><a rel="license" href="https://creativecommons.org/licenses/by/3.0/deed.en_US" target="_blank">Creative Commons Attribution 3.0 Unported License</a> except where noted.</div>
</div>
</div>
</div><!--footer info end-->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22320603-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
{% endblock %}
{% block relbar1 %}{% endblock %}
@@ -0,0 +1,32 @@
<!-- start footer part -->
<!--BEGIN GENERATE_TREEVIEW-->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
$navpath
<li class="footer">$generatedby
<a href="https://www.doxygen.org/index.html">
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
</ul>
</div>
<!--END GENERATE_TREEVIEW-->
<!--BEGIN !GENERATE_TREEVIEW-->
<hr class="footer"/>
<address class="footer"><small>
$generatedby &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/>
</a> $doxygenversion
</small></address>
<!--END !GENERATE_TREEVIEW-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '@GOOGLE_ANALYTICS@', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>
+3 -1
View File
@@ -4,7 +4,7 @@
<ul>
$navpath
<li class="footer">$generatedby
<a href="http://www.doxygen.org/index.html">
<a href="https://www.doxygen.org/index.html">
<img class="footer" src="$relpath$doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
</ul>
</div>
@@ -18,5 +18,7 @@ $generatedby &#160;<a href="http://www.doxygen.org/index.html">
</small></address>
<!--END !GENERATE_TREEVIEW-->
<script type="text/javascript">
</script>
</body>
</html>
+4 -4
View File
@@ -1,5 +1,5 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
@@ -26,13 +26,13 @@ $mathjax
<div class="row">
<div class="three columns">
<div id="logo">
<a href="http://named-data.net" title="A Future Internet Architecture"><img src="http://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
<a href="https://named-data.net" title="A Future Internet Architecture"><img src="https://named-data.net/wp-content/uploads/cropped-20130722_Logo2.png" alt="" /></a>
</div><!--logo end-->
</div>
<!--top menu-->
<div class="nine columns" id="menu_container" >
<h1><a href="http://named-data.net/doc/NFD/$projectnumber/">$projectname $projectnumber documentation</a></h1>
<h1><a href="https://named-data.net/doc/NLSR/$projectnumber/">$projectname $projectnumber documentation</a></h1>
</div>
</div>
</div><!--header container end-->
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

+3 -3
View File
@@ -50,8 +50,8 @@ def make_link_node(rawtext, app, type, slug, options):
base = app.config.redmine_project_url
if not base:
raise AttributeError
except AttributeError, err:
raise ValueError('redmine_project_url configuration value is not set (%s)' % str(err))
except AttributeError:
raise ValueError('redmine_project_url configuration value is not set')
#
slash = '/' if base[-1] != '/' else ''
ref = base + slash + type + '/' + slug + '/'
@@ -67,4 +67,4 @@ def setup(app):
"""
app.add_role('issue', redmine_role)
app.add_config_value('redmine_project_url', None, 'env')
return
return
+1
View File
@@ -0,0 +1 @@
release-notes/release-notes-0.5.0.rst
@@ -0,0 +1,30 @@
NLSR version 0.1.0 (initial release)
++++++++++++++++++++++++++++++++++++
Release date: August 25, 2014
The main design goal of NLSR is to provide a routing protocol to populate `NFD's
<https://named-data.net/doc/NFD/>`_ RIB. NLSR calculates the routing table using
link-state or hyperbolic routing and produces multiple faces for each reachable name
prefix in a single authoritative domain.
**Included features**:
- Advertise availability of content through the configured router
- Use `ChronoSync <https://github.com/named-data/ChronoSync>`_ to synchronize routers' LSA sequence numbers and Interest/Data to retrieve LSAs
- Produce a list of ranked forwarding options for each name prefix to facilitate NDN's adaptive forwarding strategies
- Configure maximum number of faces per prefix in NFD’s RIB
- Set up NFD tunnels to neighbors automatically and maintain the tunnels to neighbors
- Provide two routing protocols:
+ Link State routing: calculate route cost based on link costs
+ Hyperbolic routing: calculate route cost based on hyperbolic coordinates
- Use a hierarchical trust model for routing within a single administrative domain
- Keep NFD’s RIB updated on failure and recovery
@@ -0,0 +1,94 @@
NLSR version 0.2.0 (changes since version 0.1.0)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: April 30, 2015
**Build**:
- The code now requires C++11. The minimum supported gcc version is 4.6, as earlier versions do not have proper support for C++11 features. (:issue:`1930`)
- Require OpenSSL (:issue:`2375`)
**New features**:
- Add nlsrc command-line tool (:issue:`1834`)
- Advertise/Withdraw name prefixes at runtime (:issue:`1834`)
- Assign zero cost to hyperbolic direct neighbors (:issue:`1975`)
- Only hyperbolic costs are adjusted before registering (:issue:`1974`)
- Add ability to specify different logging levels (:issue:`1935`)
- Add LSDB dataset publishers (:issue:`2280`)
- Add LSDB dataset tlv abstractions (:issue:`2280`)
- Allow zero cost neighbors for hyperbolic routing table calculation (:issue:`1982`)
- Faces are now created with canonical Face URI (:issue:`1911`)
- Add configurable router event intervals (:issue:`2071`)
- Add router-dead-interval configuration setting (:issue:`1878`)
- Add log formatting specified by log4cxx configuration file (:issue:`1950`)
- Face URIs in configuration file are checked for validity on load (:issue:`2070`)
- Configuration variables with default values are now optional (:issue:`1949`)
- Recalculate routing table after face destroy event (:issue:`2635`)
- Add Travis-CI build script
**Code changes**:
- Change adjacency status from uint32_t to enum (:issue:`1946`)
- Remove scheduler from NLSR class (:issue:`1981`)
- Change hyperbolic cost adjustment factor from 100 to 1000 (:issue:`1974`)
- Remove use of outdated namespace ``ndn::Tlv`` (:issue:`2079`)
- Remove use of deprecated ``ndn::nfd::Controller(Face&)`` constructor (:issue:`2133`)
- Routing update publishing is abstracted to SyncLogicHandler (:issue:`2289`)
- Make ConfParameter variable types consistent with min and max values (:issue:`2084`)
- Replace LSA string literals with constants (:issue:`2310`)
- Subscribe to FaceMonitor notifications using connect (:issue:`2350`)
- Log exceptions thrown in event loop
- Change ``ndn::ptr_lib::shared_ptr`` to ``std::shared_ptr`` (:issue:`2110`)
- Avoid deprecated ``ndn::Name::set`` method (:issue:`2505`)
- Update waf to version 1.8.8-dev
- Add sorting tiebreaker to NexthopList (:issue:`2715`)
- Update Jenkins-CI build scripts
**Bug fixes**:
- Fix python3 build error (:issue:`1956`)
- Fix typos in nlsr.conf security section (:issue:`1985`)
- Stop SyncLogicHandler from fetching a router’s own LSAs (:issue:`2005`)
- Fix Name LSA comparison which could cause incorrect advertised names to be removed (:issue:`2029`)
- Fix issue where more faces than max-faces-per-prefix could be applied to a prefix (:issue:`2018`)
- Stop LSDB from retrieving and out of date LSA when a new one is detected (:issue:`1987`)
- Correct mistakes in documentation
- Correct bitmask used to copy Name LSA sequence number (:issue:`2323`)
@@ -0,0 +1,20 @@
NLSR version 0.2.1 (changes since version 0.2.0)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: June 30, 2015
**Code changes**:
- Using a configuration file without ``prefix-update-validator`` disables runtime advertise/withdraw instead of exiting (:issue:`2814`)
**Bug fixes**:
- Prevent incomplete removal of NPT entry (:issue:`2785`)
- Correct bidirectional links with differing costs (:issue:`2801`)
- Fix non-incrementing Adjacency number in AdjLsa::writeLog (:issue:`2594`)
- Remove FaceDestroyEvent test's reliance on nlsrSeqNo.txt (:issue:`2881`)
- Test ACTIVE/INACTIVE Adjacencies in LSA construction (:issue:`2735`)
@@ -0,0 +1,8 @@
NLSR version 0.2.2 (changes since version 0.2.1)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: January 5, 2016
**Code changes**:
- Adapt code to changes in NFD/ndn-cxx version 0.4.0 release
@@ -0,0 +1,26 @@
NLSR version 0.3.0 (changes since version 0.2.2)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: August 1, 2016
**Code changes**:
- Updated validation checker for LSA rule in the configuration file (:issue:`2965`)
- Do not advertise Adjacency LSAs when hyperbolic routing is enabled (:issue:`2402`)
- Do not distribute coordinate LSAs when using link-state routing. (:issue:`3661`)
- LSAs should be segmented before they are published (:issue:`2965`)
- Don't use DummyClientFace::sentDatas (:issue:`3383`)
- Remove disabled security files (:issue:`2960`)
- Lsa type should be argument for base class LSA constructor (:issue:`2788`)
- Use ndn-cxx/DummyClientFace (:issue:`2637`)
**Bug fixes**:
- Unit tests cases are installed with `./waf install` (:issue:`3359`)
@@ -0,0 +1,34 @@
NLSR version 0.3.1 (changes since version 0.3.0)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: January 22, 2017
**Changes**
- **breaking change** Sync uses /localhop component in prefix to reduce duplicate NACKs (:issue:`3627`)
- **breaking change** LSA uses /localhop component in prefix to reduce duplicate NACKs (:issue:`3899`)
**Code Changes**:
- Fib and FaceMap use std::map instead of std::list (:issue:`2781`)
- NamePrefixTableEntries store RoutingTableEntries using a pointer (:issue:`2863`)
- Namespace closing comments are now consistent with ndn-cxx guidelines (:issue:`3735`)
- Update copyright date across all files (:issue:`3736`, `3909`, `3923`)
- Improve formatting of FaceMap and FaceMapEntry (:issue:`3737`)
- Sort NextHops on NexthopList insertion (:issue:`2721`)
**Bug fixes**:
- HR now recalculates paths after status change of a neighbor (:issue:`3874`)
- NLSR no longer sets strategies multiple times (:issue:`3743`)
- NLSR should enable use of ndn-cxx dispatcher (:issue:`3930`)
- Fix typos in the sample configuration file (:issue:`3113`)
@@ -0,0 +1,20 @@
NLSR version 0.3.2 (changes since version 0.3.1)
++++++++++++++++++++++++++++++++++++++++++++++++
Release date: March 15, 2017
**Changes**
- NLSR constructor now accept a KeyChain argument. (:issue:`3742`)
- Fix security rule for /localhop LSA prefix (:issue:`3899`)
- Use ndn::nfd::ROUTE_ORIGIN_NLSR instead of a magic number. (:issue:`3903`)
- Handle "Face Already Exists" error (error code 409) in NFD. (:issue:`3976`)
- Enable NLSR to register localhost prefix with dispatcher before top-level prefix. (:issue:`3938`)
- Don't use ndn aliases provided by ndn-cxx/common.hpp. (:issue:`3983`)
- Remove use of deprecated code. (:issue:`3988`)
@@ -0,0 +1,79 @@
NLSR version 0.4.0
++++++++++++++++++
**New features**:
- **breaking change** Discover Faces from NFD (:issue:`2954`)
- **breaking change** Accommodate n-Dimensional HR coordinates (:issue:`3751`)
**Changes**:
- **breaking change** Make chronosync a dependency (:issue:`2400`)
- **breaking change** Use separate name prefix and sequence number
for each LSA type (:issue:`3964`)
- **breaking change** Convert to ``v2::security`` and adapt to ndn-cxx changes (:issue:`3964`)
- Use unix timestamp as default (:issue:`4187`)
**Bug Fixes**:
- Add support for sources to NamePrefixList (:issue:`4177`)
- Fix incorrect error on face-dataset-fetch-interval valid values (:issue:`4211`)
- Fix prefix advertise runtime error (:issue:`4215`)
- Fix heap buffer overflow error (:issue:`4217`)
**Code Changes**:
- LSA getData() now uses ostream instead of manually building the string (:issue:`2346`)
- Refresh FIB entries independently of routing table calculation (:issue:`2778`)
- Change configuration parameter output level to info (:issue:`2850`)
- Updates to name prefixes are more efficient (:issue:`2864`)
- Implement statistics collector/recorder (:issue:`2956`)
- Implement ``NameLsa::isEqualContent`` (:issue:`2962`)
- Refactor ``Fib::removeOldNextHopsFromFibEntryAndNfd()`` for simplicity, readability. (:issue:`3820`)
- Improve logging throughout lsdb.cpp and others (:issue:`3934`)
- Enable dispatcher for LOCALHOST_PREFIX (:issue:`3938`)
- Don't use ndn aliases provided by ndn-cxx/common.hpp (:issue:`3983`)
- Canonize Adjacent FaceURIs on startup (:issue:`4063`)
- Refactor AdjacencyList to use iterators instead of bare ptrs (:issue:`4068`)
- Merge redundant functions (:issue:`4105`)
- Remove writeLog in NamePrefixList (:issue:`4131`)
- Check for self in ChronoSync updates (:issue:`4134`)
- Install nlsr.conf as sample in the system (:issue:`4197`)
- Enable AddressSanitizer and LeakSanitizer for unit tests (:issue:`4206`)
- Resolve all ASan errors in unit tests (:issue:`4230`)
- Simplified LSDB dataset interest handler. (:issue:`4235`)
- Made map more container-agnostic (:issue:`4239`)
- Improved routing map data structure. (:issue:`4240`)
- Increased independence of SyncLogicHandler (:issue:`4264`)
- Use unique_ptr for signal container (:issue:`4268`)
- Use network name in sync prefix to avoid sync leaks from other networks (:issue:`4101`)
@@ -0,0 +1,24 @@
NLSR version 0.4.1
++++++++++++++++++
**New features**:
- The routing table dataset publisher (:issue:`3630`)
- Use ndn-cxx logging facility, remove log4cxx dependency (:issue:`3949`)
- Automatic serving of other routers' certificates (:issue:`4448`)
**Bug Fixes**:
- Hard-code a fixed session name for ChronoSync sockets (:issue:`4513`)
- Fix encoding bug in the routing table publisher (:issue:`4453`)
- Fix NLSR not converging without content store (:issue:`4430`)
**Miscellaneous Changes**:
- Make ChronoSync's sync interest lifetime configurable (:issue:`4490`)
- Print labels on adjacency matrix when logging (:issue:`2045`)
@@ -0,0 +1,6 @@
NLSR version 0.4.2
++++++++++++++++++
**Bug Fixes**:
- Fix segfault in scheduled erase of lsa segment (:issue:`4520`)
@@ -0,0 +1,14 @@
NLSR version 0.4.3
++++++++++++++++++
**Changes**:
- **breaking change** Change NLSR to nlsr for various prefixes (:issue:`4543`)
**Bug Fixes**:
- Fix dry-run mode not working (:issue:`4394`)
- Fix convergence w/o content store (:issue:`4430`)
- Register router prefix to fix remote requests (:issue:`4543`)
- Fix build with clang-5.0 (:issue:`4547`)
- Avoid misaligned memory access (:issue:`4609`)
@@ -0,0 +1,35 @@
NLSR version 0.5.0
++++++++++++++++++
**New Features**
- Set CanBePrefix to false on Hello Interest (:issue:`4581`)
- Optionally write prefixes to a copy of config file via nlsrc advertise (:issue:`4303`)
- Use SegmentPublisher utility from PSync to publish LSA data (:issue:`4760`)
- Add PSync as a dependency and switch it as default in conf file. (:issue:`4082`)
**Changes**
- Decouple classes from Nlsr object for easier unit testing (:issue:`1952`)
- Set sequence number file in SequencingManager constructor. (:issue:`4288`)
- Read conf file in test prefix update processor instead of static string (:issue:`3960`)
- Canonize FaceUri in conf file processor (:issue:`4817`)
- Remove redundant function "calculateHypDryRoutingTable" (:issue:`4811`)
- In dry run mode, print HR and LS routing table in nlsrc separately (:issue:`4452`)
- Fix ASan memory leaks in unit tests (:issue:`4682`)
- Systemd service files dependency corrections for Ubuntu 18.04 (:issue:`4594`)
**Bug Fixes**
- Fix processing of interest w/ segments for segmented LSA data (:issue:`4784`)
- Fib: don't refresh neighbor router's FIB entry (:issue:`4799`)
- Disable Interest filter loopback where ever not needed (:issue:`4768`)
- Avoid crash when ndn-cxx is compiled with tests by setting canBePrefix (:issue:`4691`)
- Make sure NLSR is not using any deprecated API (:issue:`4679`)
- Fix crash in equals operator of adjacency-list (:issue:`4705`)
- Fix error handling and normalize exit codes
**Miscellaneous**
- Improving documentation for NLSR
- A beginners' guide to installing and testing on Fedora
+73
View File
@@ -0,0 +1,73 @@
NLSR Versions
+++++++++++++
.. toctree::
:hidden:
:maxdepth: 1
release-notes/release-notes-0.5.0
release-notes/release-notes-0.4.3
release-notes/release-notes-0.4.2
release-notes/release-notes-0.4.1
release-notes/release-notes-0.4.0
release-notes/release-notes-0.3.2
release-notes/release-notes-0.3.1
release-notes/release-notes-0.3.0
release-notes/release-notes-0.2.2
release-notes/release-notes-0.2.1
release-notes/release-notes-0.2.0
release-notes/release-notes-0.1.0
* **NLSR version 0.4.1**
(:doc:`Release Notes <release-notes/release-notes-0.4.1>`, `Documentation <https://named-data.net/doc/NLSR/0.4.1/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.4.1>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.4.1.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.4.1.tar.bz2.sha256>`__)
* **NLSR version 0.4.0**
(:doc:`Release Notes <release-notes/release-notes-0.4.0>`, `Documentation <https://named-data.net/doc/NLSR/0.4.0/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.4.0>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.4.0.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.4.0.tar.bz2.sha256>`__)
* **NLSR version 0.3.2**
(:doc:`Release Notes <release-notes/release-notes-0.3.2>`, `Documentation <https://named-data.net/doc/NLSR/0.3.2/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.3.2>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.3.2.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.3.2.tar.bz2.sha256>`__)
* **NLSR version 0.3.1**
(:doc:`Release Notes <release-notes/release-notes-0.3.1>`, `Documentation <https://named-data.net/doc/NLSR/0.3.1/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.3.1>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.3.1.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.3.1.tar.bz2.sha256>`__)
* **NLSR version 0.3.0**
(:doc:`Release Notes <release-notes/release-notes-0.3.0>`, `Documentation <https://named-data.net/doc/NLSR/0.3.0/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.3.0>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.3.0.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.3.0.tar.bz2.sha256>`__)
* **NLSR version 0.2.2**
(:doc:`Release Notes <release-notes/release-notes-0.2.2>`, `Documentation <https://named-data.net/doc/NLSR/0.2.2/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.2.2>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.2.2.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.2.2.tar.bz2.sha256>`__)
* **NLSR version 0.2.1**
(:doc:`Release Notes <release-notes/release-notes-0.2.1>`, `Documentation <https://named-data.net/doc/NLSR/0.2.1/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.2.1>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.2.1.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.2.1.tar.bz2.sha256>`__)
* **NLSR version 0.2.0**
(:doc:`Release Notes <release-notes/release-notes-0.2.0>`, `Documentation <https://named-data.net/doc/NLSR/0.2.0/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.2.0>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.2.0.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.2.0.tar.bz2.sha256>`__)
* **NLSR version 0.1.0**
(:doc:`Release Notes <release-notes/release-notes-0.1.0>`, `Documentation <https://named-data.net/doc/NLSR/0.1.0/>`__)
`src (git) <https://github.com/named-data/NLSR/releases/tag/NLSR-0.1.0>`__,
`src (tarball) <https://named-data.net/downloads/nlsr-0.1.0.tar.bz2>`__ (`checksum <https://named-data.net/downloads/nlsr-0.1.0.tar.bz2.sha256>`__)
Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

-11
View File
@@ -1,11 +0,0 @@
log4j.rootLogger=DEBUG, Rolling
log4j.appender.Rolling=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.Rolling.File=/tmp/testnlsrproperties.log
log4j.appender.Rolling.MaxSize=1MB
log4j.appender.Rolling.MaxBackupIndex=10
log4j.appender.Rolling.layout=PatternLayout
log4j.appender.Rolling.layout.ContextPrinting=enabled
log4j.appender.Rolling.layout.DateFormat=ISO8601
log4j.appender.Rolling.layout.ConversionPattern=%date{yyyyMMddHHmmssSSS} %p: [%c] %m%n
+39 -37
View File
@@ -11,7 +11,7 @@ general
; lsa-refresh-time is the time in seconds, after which router will refresh its LSAs
lsa-refresh-time 1800 ; default value 1800. Valid values 240-7200
; router-dead-interval is the time in seconds after which an inactive router's
; router-dead-interval is the time in seconds after which an inactive routers
; LSAs are removed
;router-dead-interval 3600 ; default value: 2*lsa-refresh-time. Value must be larger
; than lsa-refresh-time
@@ -19,27 +19,16 @@ general
; InterestLifetime (in seconds) for LSA fetching
lsa-interest-lifetime 4 ; default value 4. Valid values 1-60
; log-level is used to set the logging level for NLSR.
; All debugging levels listed above the selected value are enabled.
;
; Valid values:
;
; NONE ; no messages
; ERROR ; error messages
; WARN ; warning messages
; INFO ; informational messages (default)
; DEBUG ; debugging messages
; TRACE ; trace messages (most verbose)
; ALL ; all messages
; select sync protocol: chronosync or psync
sync-protocol psync
log-level INFO
; sync interest lifetime of ChronoSync/PSync in milliseconds
sync-interest-lifetime 60000 ; default value 60000. Valid values 1000-120,000
log-dir /var/log/nlsr/ ; path for log directory (Absolute path)
seq-dir /var/lib/nlsr/ ; path for sequence directory (Absolute path)
;log4cxx-conf /path/to/log4cxx-conf ; path for log4cxx configuration file (Absolute path)
state-dir /var/lib/nlsr ; path for intermediate state files including sequence directory (Absolute path)
}
; the neighbors section contains the configuration for router's neighbors and hello's behavior
; the neighbor's section contains the configuration for router's neighbors and hellos behavior
neighbors
{
@@ -65,6 +54,16 @@ neighbors
first-hello-interval 10 ; Default value 10. Valid values 0-10
face-dataset-fetch-tries 3 ; default is 3. Valid values 1-10. The FaceDataset is
; gotten from NFD, and is needed to configure NLSR
; correctly. It is recommended not to set this
; variable too high, because it could cause
; congestion for NFD.
face-dataset-fetch-interval 3600 ; default is 3600. Valid values 1800-5400.
; This controls how often (in seconds) NLSR will attempt to
; fetch a FaceStatus dataset from NFD.
; neighbor command is used to configure router's neighbor. Each neighbor will need
; one block of neighbor command
@@ -101,11 +100,11 @@ hyperbolic
radius 123.456 ; radius of the router in hyperbolic coordinate system
angle 1.45 ; angle of the router in hyperbolic coordinate system
angle 1.45,2.36 ; angle of the router in hyperbolic coordinate system
}
; the fib section is used to configure fib entry's type to ndn FIB updated by NLSR
; the fib section is used to configure fib entrys type to ndn FIB updated by NLSR
fib
{
@@ -140,12 +139,12 @@ security
{
rule
{
id "NSLR Hello Rule"
id "NLSR Hello Rule"
for data
filter
{
type name
regex ^[^<NLSR><INFO>]*<NLSR><INFO><><>$
regex ^[^<nlsr><INFO>]*<nlsr><INFO><><>$
}
checker
{
@@ -156,10 +155,10 @@ security
type name
hyper-relation
{
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><ksk-.*><ID-CERT>$
k-regex ^([^<KEY><nlsr>]*)<nlsr><KEY><>$
k-expand \\1
h-relation equal
p-regex ^([^<NLSR><INFO>]*)<NLSR><INFO><><>$
p-regex ^([^<nlsr><INFO>]*)<nlsr><INFO><><>$
p-expand \\1
}
}
@@ -168,12 +167,12 @@ security
rule
{
id "NSLR LSA Rule"
id "NLSR LSA Rule"
for data
filter
{
type name
regex ^[^<NLSR><LSA>]*<NLSR><LSA>
regex ^[^<nlsr><LSA>]*<nlsr><LSA>
}
checker
{
@@ -184,11 +183,11 @@ security
type name
hyper-relation
{
k-regex ^([^<KEY><NLSR>]*)<NLSR><KEY><ksk-.*><ID-CERT>$
k-regex ^([^<KEY><nlsr>]*)<nlsr><KEY><>$
k-expand \\1
h-relation equal
; the last four components in the prefix should be <lsaType><seqNo><version><segmentNo>
p-regex ^([^<NLSR><LSA>]*)<NLSR><LSA>(<>*)<><><><>$
p-regex ^<localhop>([^<nlsr><LSA>]*)<nlsr><LSA>(<>*)<><><><>$
p-expand \\1\\2
}
}
@@ -197,12 +196,12 @@ security
rule
{
id "NSLR Hierarchy Exception Rule"
id "NLSR Hierarchy Exception Rule"
for data
filter
{
type name
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><NLSR>]*<KEY><ksk-.*><ID-CERT><>$
regex ^[^<KEY><%C1.Router>]*<%C1.Router>[^<KEY><nlsr>]*<KEY><><><>$
}
checker
{
@@ -213,10 +212,10 @@ security
type name
hyper-relation
{
k-regex ^([^<KEY><%C1.Operator>]*)<%C1.Operator>[^<KEY>]*<KEY><ksk-.*><ID-CERT>$
k-regex ^([^<KEY><%C1.Operator>]*)<%C1.Operator>[^<KEY>]*<KEY><>$
k-expand \\1
h-relation equal
p-regex ^([^<KEY><%C1.Router>]*)<%C1.Router>[^<KEY>]*<KEY><ksk-.*><ID-CERT><>$
p-regex ^([^<KEY><%C1.Router>]*)<%C1.Router>[^<KEY>]*<KEY><><><>$
p-expand \\1
}
}
@@ -225,12 +224,12 @@ security
rule
{
id "NSLR Hierarchical Rule"
id "NLSR Hierarchical Rule"
for data
filter
{
type name
regex ^[^<KEY>]*<KEY><ksk-.*><ID-CERT><>$
regex ^[^<KEY>]*<KEY><><><>$
}
checker
{
@@ -255,7 +254,9 @@ security
filter
{
type name
regex ^<localhost><nlsr><prefix-update>[<advertise><withdraw>]<>$
; /<prefix>/<management-module>/<command-verb>/<control-parameters>
; /<timestamp>/<random-value>/<signed-interests-components>
regex ^<localhost><nlsr><prefix-update>[<advertise><withdraw>]<><><>$
}
checker
{
@@ -264,7 +265,7 @@ security
key-locator
{
type name
regex ^([^<KEY><%C1.Operator>]*)<%C1.Operator>[^<KEY>]*<KEY><ksk-.*><ID-CERT>$
regex ^([^<KEY><%C1.Operator>]*)<%C1.Operator>[^<KEY>]*<KEY><>$
}
}
}
@@ -276,7 +277,7 @@ security
filter
{
type name
regex ^[^<KEY>]*<KEY><ksk-.*><ID-CERT><>$
regex ^[^<KEY>]*<KEY><><><>$
}
checker
{
@@ -291,6 +292,7 @@ security
file-name "site.cert"
}
}
; cert-to-publish "root.cert" ; optional, a file containing the root certificate
; Only the router that is designated to publish the root cert
; needs to specify this
-3
View File
@@ -1,3 +0,0 @@
nsync is a copy of ChronoSync (https://github.com/bruinfish/ChronoSync/tree/master).
ChonoSync's license is GPL2.
-15
View File
@@ -1,15 +0,0 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014 University of Memphis,
* Regents of the University of California
*
* See COPYING.md for copyright and distribution information.
*/
// suppress Boost::archive warnings
#pragma GCC system_header
#pragma clang system_header
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/archive/iterators/dataflow_exception.hpp>
-21
View File
@@ -1,21 +0,0 @@
#ifndef NSYNC_OPENSSL_H
#define NSYNC_OPENSSL_H
// suppress deprecation warnings in OSX >= 10.7
#if defined(__APPLE__)
#ifdef __clang__
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif // __clang__
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif // __GNUC__
#endif
#include <openssl/evp.h>
#endif // NSYNC_OPENSSL_H
-74
View File
@@ -1,74 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-diff-leaf.h"
#include <boost/throw_exception.hpp>
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info;
using namespace Sync::Error;
namespace Sync {
DiffLeaf::DiffLeaf (NameInfoConstPtr info, const SeqNo &seq)
: Leaf (info, seq)
, m_op (UPDATE)
{
}
DiffLeaf::DiffLeaf (NameInfoConstPtr info)
: Leaf (info, SeqNo (0,0))
, m_op (REMOVE)
{
}
std::ostream &
operator << (std::ostream &os, Operation op)
{
switch (op)
{
case UPDATE:
os << "update";
break;
case REMOVE:
os << "remove";
break;
}
return os;
}
std::istream &
operator >> (std::istream &is, Operation &op)
{
std::string operation;
is >> operation;
if (operation == "update")
op = UPDATE;
else if (operation == "remove")
op = REMOVE;
else
BOOST_THROW_EXCEPTION (SyncDiffLeafOperationParseError () << errmsg_info (operation));
return is;
}
}
-91
View File
@@ -1,91 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_DIFF_LEAF_H
#define SYNC_DIFF_LEAF_H
#include "sync-leaf.h"
#include <boost/exception/all.hpp>
namespace Sync {
/**
* @ingroup sync
* @brief Annotation for SYNC leaf
*/
enum Operation
{
UPDATE, ///< @brief Leaf was added or updated
REMOVE ///< @brief Leaf was removed
};
/**
* @ingroup sync
* @brief Annotated SYNC leaf
*/
class DiffLeaf : public Leaf
{
public:
/**
* @brief Constructor to create an UPDATE diff leaf
* @param info Smart pointer to leaf's name
* @param seq Initial sequence number of the pointer
*/
DiffLeaf (NameInfoConstPtr info, const SeqNo &seq);
/**
* @brief Constructor to create an REMOVE diff leaf
* @param info Smart pointer to leaf's name
*
* This constructor creates a leaf with phony sequence number
* with 0 session ID and 0 sequence number
*/
DiffLeaf (NameInfoConstPtr info);
virtual ~DiffLeaf () { }
/**
* @brief Get diff leaf type
*/
Operation
getOperation () const { return m_op; }
private:
Operation m_op;
};
typedef shared_ptr<DiffLeaf> DiffLeafPtr;
typedef shared_ptr<const DiffLeaf> DiffLeafConstPtr;
std::ostream &
operator << (std::ostream &os, Operation op);
std::istream &
operator >> (std::istream &is, Operation &op);
namespace Error {
struct SyncDiffLeafOperationParseError : virtual boost::exception, virtual std::exception { };
} // Error
} // Sync
#endif // SYNC_DIFF_LEAF_H
-72
View File
@@ -1,72 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_DIFF_STATE_CONTAINER_H
#define SYNC_DIFF_STATE_CONTAINER_H
#include "sync-diff-state.h"
#include "sync-digest.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/tag.hpp>
// #include <boost/multi_index/ordered_index.hpp>
// #include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
// #include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
namespace mi = boost::multi_index;
namespace Sync {
/// @cond include_hidden
struct sequenced { };
struct timed { };
/// @endcond
/**
* \ingroup sync
* @brief Container for differential states
*/
struct DiffStateContainer : public mi::multi_index_container<
DiffStatePtr,
mi::indexed_by<
// For fast access to elements using DiffState hashes
mi::hashed_unique<
mi::tag<hashed>,
mi::const_mem_fun<DiffState, DigestConstPtr, &DiffState::getDigest>,
DigestPtrHash,
DigestPtrEqual
>
,
// sequenced index to access older/newer element (like in list)
mi::sequenced<mi::tag<sequenced> >
>
>
{
};
} // Sync
#endif // SYNC_DIFF_STATE_CONTAINER_H
-98
View File
@@ -1,98 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-diff-state.h"
#include "sync-diff-leaf.h"
#include <boost/foreach.hpp>
#include <boost/assert.hpp>
namespace Sync {
DiffState::DiffState ()
{
}
DiffState::~DiffState ()
{
}
DiffStatePtr
DiffState::diff () const
{
DiffStatePtr ret = make_shared<DiffState> ();
DiffStatePtr state = m_next;
while (state != 0)
{
*ret += *state;
state = state->m_next;
}
return ret;
}
DiffState &
DiffState::operator += (const DiffState &state)
{
BOOST_FOREACH (LeafConstPtr _leaf, state.getLeaves ())
{
DiffLeafConstPtr leaf = dynamic_pointer_cast<const DiffLeaf> (_leaf);
BOOST_ASSERT (leaf != 0);
if (leaf->getOperation () == UPDATE)
update (leaf->getInfo (), leaf->getSeq ());
else if (leaf->getOperation () == REMOVE)
remove (leaf->getInfo ());
else
{
BOOST_ASSERT (false);
}
}
return *this;
}
// from State
tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
DiffState::update (NameInfoConstPtr info, const SeqNo &seq)
{
m_leaves.erase (info);
DiffLeafPtr leaf = make_shared<DiffLeaf> (info, seq);
m_leaves.insert (leaf);
return make_tuple (true, false, SeqNo ());
}
bool
DiffState::remove (NameInfoConstPtr info)
{
m_leaves.erase (info);
DiffLeafPtr leaf = make_shared<DiffLeaf> (info);
m_leaves.insert (leaf);
return true;
}
} // ns3
-102
View File
@@ -1,102 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_DIFF_STATE_H
#define SYNC_DIFF_STATE_H
#include "sync-state.h"
#include <iostream>
namespace Sync {
class DiffState;
typedef shared_ptr<DiffState> DiffStatePtr;
typedef shared_ptr<DiffState> DiffStateConstPtr;
/**
* @ingroup ccnx
* @brief Differential SYNC state
*/
class DiffState : public State
{
public:
/**
* @see Default constructor
*/
DiffState ();
virtual ~DiffState ();
/**
* @brief Set successor for the diff state
* @param next successor state
*/
void
setNext (DiffStatePtr next)
{
m_next = next;
}
/**
* @brief Set digest for the diff state (obtained from a corresponding full state)
* @param digest A read only smart pointer to a digest object (that should be unmodified anywhere else)
*/
void
setDigest (DigestConstPtr digest) { m_digest = digest; }
/**
* @brief Get digest for the diff state
*/
DigestConstPtr
getDigest () const { return m_digest; }
/**
* @brief Accumulate differences from `this' state to the most current state
* @returns Accumulated differences from `this' state to the most current state
*/
DiffStatePtr
diff () const;
/**
* @brief Combine differences from `this' and `state'
* @param state Differential state to combine with
* @return Combined differences
*
* In case of collisions, `this' leaf will be replaced with the leaf of `state'
*/
DiffState&
operator += (const DiffState &state);
// from State
virtual tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
update (NameInfoConstPtr info, const SeqNo &seq);
virtual bool
remove (NameInfoConstPtr info);
private:
DiffStatePtr m_next;
DigestConstPtr m_digest;
};
} // Sync
#endif // SYNC_DIFF_STATE_H
-262
View File
@@ -1,262 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-digest.h"
#include <string.h>
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
// for printing, may be disabled in optimized build
// #ifdef DIGEST_BASE64
// #include <boost/archive/iterators/base64_from_binary.hpp>
// #include <boost/archive/iterators/binary_from_base64.hpp>
// #endif
#include "boost-archive.h"
using namespace boost;
using namespace boost::archive::iterators;
using namespace std;
// Other options: VP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha256, EVP_dss, EVP_dss1, EVP_mdc2, EVP_ripemd160
#define HASH_FUNCTION EVP_sha256
#define HASH_FUNCTION_LEN 32
// #ifndef DIGEST_BASE64
template<class CharType>
struct hex_from_4_bit
{
typedef CharType result_type;
CharType operator () (CharType ch) const
{
const char *lookup_table = "0123456789abcdef";
// cout << "New character: " << (int) ch << " (" << (char) ch << ")" << "\n";
BOOST_ASSERT (ch < 16);
return lookup_table[static_cast<size_t>(ch)];
}
};
typedef transform_iterator<hex_from_4_bit<std::vector<uint8_t>::const_iterator::value_type>,
transform_width<std::vector<uint8_t>::const_iterator, 4, 8, std::vector<uint8_t>::const_iterator::value_type> > string_from_binary;
template<class CharType>
struct hex_to_4_bit
{
typedef CharType result_type;
CharType operator () (CharType ch) const
{
const signed char lookup_table [] = {
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
};
// cout << "New character: " << hex << (int) ch << " (" << (char) ch << ")" << "\n";
signed char value = -1;
if ((unsigned)ch < 128)
value = lookup_table [(unsigned)ch];
if (value == -1)
BOOST_THROW_EXCEPTION (Sync::Error::DigestCalculationError () << errmsg_info_int ((int)ch));
return value;
}
};
typedef transform_width<transform_iterator<hex_to_4_bit<string::const_iterator::value_type>, string::const_iterator>, 8, 4> string_to_binary;
namespace Sync {
Digest::Digest ()
{
m_context = EVP_MD_CTX_create ();
reset ();
}
Digest::~Digest ()
{
EVP_MD_CTX_destroy (m_context);
}
bool
Digest::empty () const
{
return m_buffer.empty ();
}
bool
Digest::isZero () const
{
if (m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest has not been yet finalized"));
return (m_buffer.size () == 1 && m_buffer[0] == 0);
}
void
Digest::reset ()
{
m_buffer.clear ();
int ok = EVP_DigestInit_ex (m_context, HASH_FUNCTION (), 0);
if (!ok)
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("EVP_DigestInit_ex returned error")
<< errmsg_info_int (ok));
}
void
Digest::finalize ()
{
if (!m_buffer.empty ()) return;
m_buffer.resize (HASH_FUNCTION_LEN);
unsigned int tmp;
int ok = EVP_DigestFinal_ex (m_context,
&m_buffer[0], &tmp);
if (!ok)
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("EVP_DigestFinal_ex returned error")
<< errmsg_info_int (ok));
}
std::size_t
Digest::getHash () const
{
if (isZero ()) return 0;
if (sizeof (std::size_t) > m_buffer.size ())
{
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Hash is not zero and length is less than size_t")
<< errmsg_info_int (m_buffer.size ()));
}
// just getting first sizeof(std::size_t) bytes
// not ideal, but should work pretty well
return *(reinterpret_cast<const std::size_t*> (&m_buffer[0]));
}
bool
Digest::operator == (const Digest &digest) const
{
if (m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest1 is empty"));
if (digest.m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest2 is empty"));
return m_buffer == digest.m_buffer;
}
void
Digest::update (const uint8_t *buffer, size_t size)
{
// cout << "Update: " << (void*)buffer << " / size: " << size << "\n";
// cannot update Digest when it has been finalized
if (!m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest has been already finalized"));
bool ok = EVP_DigestUpdate (m_context, buffer, size);
if (!ok)
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("EVP_DigestUpdate returned error")
<< errmsg_info_int (ok));
}
Digest &
Digest::operator << (const Digest &src)
{
if (src.m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest has not been yet finalized"));
update (&src.m_buffer[0], src.m_buffer.size ());
return *this;
}
std::ostream &
operator << (std::ostream &os, const Digest &digest)
{
BOOST_ASSERT (!digest.m_buffer.empty ());
ostreambuf_iterator<char> out_it (os); // ostream iterator
// need to encode to base64
copy (string_from_binary (digest.m_buffer.begin ()),
string_from_binary (digest.m_buffer.end ()),
out_it);
return os;
}
std::istream &
operator >> (std::istream &is, Digest &digest)
{
string str;
is >> str; // read string first
if (str.size () == 0)
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Input is empty"));
// uint8_t padding = (3 - str.size () % 3) % 3;
// for (uint8_t i = 0; i < padding; i++) str.push_back ('=');
// only empty digest object can be used for reading
if (!digest.m_buffer.empty ())
BOOST_THROW_EXCEPTION (Error::DigestCalculationError ()
<< errmsg_info_str ("Digest has been already finalized"));
digest.m_buffer.clear ();
copy (string_to_binary (str.begin ()),
string_to_binary (str.end ()),
std::back_inserter (digest.m_buffer));
return is;
}
} // Sync
-199
View File
@@ -1,199 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_DIGEST_H
#define SYNC_DIGEST_H
#include "sync-common.h"
#include <vector>
#include "openssl.h"
namespace Sync {
/**
* @ingroup sync
* @brief A simple wrapper for libcrypto hash functions
*/
class Digest
{
public:
/**
* @brief Default constructor. Will initialize internal libssl structures
*/
Digest ();
/**
* @brief Check if digest is empty
*/
bool
empty () const;
/**
* @brief Reset digest to the initial state
*/
void
reset ();
/**
* @brief Destructor
*/
~Digest ();
/**
* @brief Obtain a short version of the hash (just first sizeof(size_t) bytes
*
* Side effect: finalize() will be called on `this'
*/
std::size_t
getHash () const;
/**
* @brief Finalize digest. All subsequent calls to "operator <<" will fire an exception
*/
void
finalize ();
/**
* @brief Compare two full digests
*
* Side effect: Finalize will be called on `this' and `digest'
*/
bool
operator == (const Digest &digest) const;
bool
operator != (const Digest &digest) const
{ return ! (*this == digest); }
/**
* @brief Add existing digest to digest calculation
* @param src digest to combine with
*
* The result of this combination is hash (hash (...))
*/
Digest &
operator << (const Digest &src);
/**
* @brief Add string to digest calculation
* @param str string to put into digest
*/
inline Digest &
operator << (const std::string &str);
/**
* @brief Add uint64_t value to digest calculation
* @param value uint64_t value to put into digest
*/
inline Digest &
operator << (uint64_t value);
/**
* @brief Checks if the stored hash is zero-root hash
*
* Zero-root hash is a valid hash that optimally represents an empty state
*/
bool
isZero () const;
private:
Digest &
operator = (Digest &digest) { (void)digest; return *this; }
/**
* @brief Add size bytes of buffer to the hash
*/
void
update (const uint8_t *buffer, size_t size);
friend std::ostream &
operator << (std::ostream &os, const Digest &digest);
friend std::istream &
operator >> (std::istream &is, Digest &digest);
private:
EVP_MD_CTX *m_context;
std::vector<uint8_t> m_buffer;
};
namespace Error {
struct DigestCalculationError : virtual boost::exception, virtual std::exception { };
}
typedef shared_ptr<Digest> DigestPtr;
typedef shared_ptr<const Digest> DigestConstPtr;
Digest &
Digest::operator << (const std::string &str)
{
update (reinterpret_cast<const uint8_t*> (str.c_str ()), str.size ());
return *this;
}
inline Digest &
Digest::operator << (uint64_t value)
{
update (reinterpret_cast<const uint8_t*> (&value), sizeof (uint64_t));
return *this;
}
std::ostream &
operator << (std::ostream &os, const Digest &digest);
std::istream &
operator >> (std::istream &is, Digest &digest);
// template<class INT>
// Digest &
// Digest::operator << (INT value)
// {
// update (&value, sizeof (INT));
// return *this;
// }
struct DigestPtrHash : public std::unary_function<Digest, std::size_t>
{
std::size_t
operator() (DigestConstPtr digest) const
{
// std::cout << "digest->getHash: " << digest->getHash () << " (" << *digest << ")" << std::endl;
return digest->getHash ();
}
};
struct DigestPtrEqual : public std::unary_function<Digest, std::size_t>
{
bool
operator() (DigestConstPtr digest1, DigestConstPtr digest2) const
{
// std::cout << boost::cref(*digest1) << " == " << boost::cref(*digest2) << " : " << (*digest1 == *digest2) << std::endl;
return *digest1 == *digest2;
}
};
} // Sync
#endif // SYNC_DIGEST_H
-35
View File
@@ -1,35 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_EVENT_H
#define SYNC_EVENT_H
#include "sync-common.h"
namespace Sync
{
typedef function< void ( ) > Event;
} // Sync
#endif // SYNC_EVENT_H
-49
View File
@@ -1,49 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-full-leaf.h"
namespace Sync {
FullLeaf::FullLeaf (NameInfoConstPtr info, const SeqNo &seq)
: Leaf (info, seq)
{
updateDigest ();
}
void
FullLeaf::updateDigest ()
{
m_digest.reset ();
m_digest << getInfo ()->getDigest () << *getSeq ().getDigest ();
m_digest.finalize ();
}
// from Leaf
void
FullLeaf::setSeq (const SeqNo &seq)
{
Leaf::setSeq (seq);
updateDigest ();
}
} // Sync
-71
View File
@@ -1,71 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_FULL_LEAF_H
#define SYNC_FULL_LEAF_H
#include "sync-leaf.h"
namespace Sync {
/**
* @ingroup sync
* @brief SYNC leaf for the full state (with support of Digest calculation)
*/
class FullLeaf : public Leaf
{
public:
/**
* @brief Constructor to create an UPDATE diff leaf
* @param info Smart pointer to leaf's name
* @param seq Initial sequence number of the pointer
*/
FullLeaf (NameInfoConstPtr info, const SeqNo &seq);
virtual ~FullLeaf () { }
/**
* @brief Get hash digest of the leaf
*
* The underlying Digest object is recalculated on every update or removal
* (including updates of child classes)
*/
const Digest &
getDigest () const { return m_digest; }
// from Leaf
virtual void
setSeq (const SeqNo &seq);
private:
void
updateDigest ();
private:
Digest m_digest;
};
typedef shared_ptr<FullLeaf> FullLeafPtr;
typedef shared_ptr<const FullLeaf> FullLeafConstPtr;
} // Sync
#endif // SYNC_FULL_LEAF_H
-118
View File
@@ -1,118 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-full-state.h"
#include <boost/assert.hpp>
#include "sync-full-leaf.h"
namespace Sync {
FullState::FullState ()
// m_lastUpdated is initialized to "not_a_date_time" in normal lib mode and to "0" time in NS-3 mode
{
}
FullState::~FullState ()
{
}
ndn::time::system_clock::Duration
FullState::getTimeFromLastUpdate () const
{
return ndn::time::system_clock::now() - m_lastUpdated;
}
DigestConstPtr
FullState::getDigest ()
{
if (!m_digest)
{
m_digest = make_shared<Digest> ();
if (m_leaves.get<ordered> ().size () > 0)
{
for (LeafConstPtr leaf : m_leaves.get<ordered> ())
{
FullLeafConstPtr fullLeaf = dynamic_pointer_cast<const FullLeaf> (leaf);
BOOST_ASSERT (fullLeaf != 0);
*m_digest << fullLeaf->getDigest ();
}
m_digest->finalize ();
}
else
{
std::istringstream is ("00"); //zero state
is >> *m_digest;
}
}
return m_digest;
}
// from State
tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
FullState::update (NameInfoConstPtr info, const SeqNo &seq)
{
m_lastUpdated = ndn::time::system_clock::now();
m_digest.reset ();
LeafContainer::iterator item = m_leaves.find (info);
if (item == m_leaves.end ())
{
m_leaves.insert (make_shared<FullLeaf> (info, seq));
return make_tuple (true, false, SeqNo ());
}
else
{
if ((*item)->getSeq () == seq || seq < (*item)->getSeq ())
{
return make_tuple (false, false, SeqNo ());
}
SeqNo old = (*item)->getSeq ();
m_leaves.modify (item, [&seq](LeafPtr data){ data->setSeq(seq); });
return make_tuple (false, true, old);
}
}
bool
FullState::remove (NameInfoConstPtr info)
{
m_lastUpdated = ndn::time::system_clock::now();
m_digest.reset ();
LeafContainer::iterator item = m_leaves.find (info);
if (item != m_leaves.end ())
{
m_leaves.erase (item);
return true;
}
else
return false;
}
} // Sync
-79
View File
@@ -1,79 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_FULL_STATE_H
#define SYNC_FULL_STATE_H
#include <ndn-cxx/util/time.hpp>
#include "sync-state.h"
namespace Sync {
class FullState;
typedef shared_ptr<FullState> FullStatePtr;
typedef shared_ptr<FullState> FullStateConstPtr;
/**
* \ingroup sync
* @brief Cumulative SYNC state
*/
class FullState : public State
{
public:
/**
* @brief Default constructor
*/
FullState ();
virtual ~FullState ();
/**
* @brief Get time period since last state update
*
* This value can be used to randomize reconciliation waiting time in SyncApp
*/
ndn::time::system_clock::Duration
getTimeFromLastUpdate () const;
/**
* @brief Obtain a read-only copy of the digest
*
* If m_digest is 0, then it is automatically created. On every update and removal, m_digest is reset to 0
*/
DigestConstPtr
getDigest ();
// from State
virtual tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
update (NameInfoConstPtr info, const SeqNo &seq);
virtual bool
remove (NameInfoConstPtr info);
private:
ndn::time::system_clock::TimePoint m_lastUpdated; ///< @brief Time when state was updated last time
DigestPtr m_digest;
};
} // Sync
#endif // SYNC_STATE_H
-99
View File
@@ -1,99 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_INTEREST_CONTAINER_H
#define SYNC_INTEREST_CONTAINER_H
#include <ndn-cxx/util/time.hpp>
#include "sync-digest.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/tag.hpp>
// #include <boost/multi_index/ordered_index.hpp>
// #include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index/ordered_index.hpp>
// #include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
namespace mi = boost::multi_index;
namespace Sync {
struct Interest
{
Interest (DigestConstPtr digest, const std::string &name, bool unknown=false)
: m_digest (digest)
, m_name (name)
, m_time (ndn::time::system_clock::now())
, m_unknown (unknown)
{
}
DigestConstPtr m_digest;
std::string m_name;
ndn::time::system_clock::TimePoint m_time;
bool m_unknown;
};
/// @cond include_hidden
struct named { };
struct hashed;
struct timed;
/// @endcond
/**
* \ingroup sync
* @brief Container for interests (application PIT)
*/
struct InterestContainer : public mi::multi_index_container<
Interest,
mi::indexed_by<
mi::hashed_unique<
mi::tag<named>,
BOOST_MULTI_INDEX_MEMBER(Interest, std::string, m_name)
>
,
mi::hashed_non_unique<
mi::tag<hashed>,
BOOST_MULTI_INDEX_MEMBER(Interest, DigestConstPtr, m_digest),
DigestPtrHash,
DigestPtrEqual
>
,
mi::ordered_non_unique<
mi::tag<timed>,
BOOST_MULTI_INDEX_MEMBER(Interest, ndn::time::system_clock::TimePoint, m_time)
>
>
>
{
};
} // Sync
#endif // SYNC_INTEREST_CONTAINER_H
-126
View File
@@ -1,126 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-interest-table.h"
#include "sync-logging.h"
using namespace std;
INIT_LOGGER("SyncInterestTable");
namespace Sync
{
SyncInterestTable::SyncInterestTable(boost::asio::io_service& io, ndn::time::system_clock::Duration lifetime)
: m_entryLifetime(lifetime)
, m_scheduler(io)
{
m_scheduler.scheduleEvent(ndn::time::seconds(4),
ndn::bind(&SyncInterestTable::expireInterests, this));
}
SyncInterestTable::~SyncInterestTable()
{
}
Interest
SyncInterestTable::pop()
{
if (m_table.size() == 0)
BOOST_THROW_EXCEPTION(Error::InterestTableIsEmpty());
Interest ret = *m_table.begin();
m_table.erase(m_table.begin());
return ret;
}
bool
SyncInterestTable::insert(DigestConstPtr digest, const string &name, bool unknownState/*=false*/)
{
bool existent = false;
InterestContainer::index<named>::type::iterator it = m_table.get<named>().find(name);
if (it != m_table.end())
{
existent = true;
m_table.erase(it);
}
m_table.insert(Interest(digest, name, unknownState));
return existent;
}
uint32_t
SyncInterestTable::size() const
{
return m_table.size();
}
bool
SyncInterestTable::remove(const string &name)
{
InterestContainer::index<named>::type::iterator item = m_table.get<named>().find(name);
if (item != m_table.get<named>().end())
{
m_table.get<named>().erase(name);
return true;
}
return false;
}
bool
SyncInterestTable::remove(DigestConstPtr digest)
{
InterestContainer::index<hashed>::type::iterator item = m_table.get<hashed>().find(digest);
if (item != m_table.get<hashed>().end())
{
m_table.get<hashed>().erase(digest); // erase all records associated with the digest
return true;
}
return false;
}
void SyncInterestTable::expireInterests()
{
uint32_t count = 0;
ndn::time::system_clock::TimePoint expireTime = ndn::time::system_clock::now() - m_entryLifetime;
while (m_table.size() > 0)
{
InterestContainer::index<timed>::type::iterator item = m_table.get<timed>().begin();
if (item->m_time <= expireTime)
{
m_table.get<timed>().erase(item);
count ++;
}
else
break;
}
m_scheduler.scheduleEvent(ndn::time::seconds(4),
ndn::bind(&SyncInterestTable::expireInterests, this));
}
}
-96
View File
@@ -1,96 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_INTEREST_TABLE_H
#define SYNC_INTEREST_TABLE_H
#include <ndn-cxx/util/scheduler.hpp>
#include <string>
#include <vector>
#include "sync-digest.h"
#include "sync-interest-container.h"
namespace Sync {
/**
* \ingroup sync
* @brief A table to keep unanswered Sync Interest
* all access operation to the table should grab the
* mutex first
*/
class SyncInterestTable
{
public:
SyncInterestTable (boost::asio::io_service& io, ndn::time::system_clock::Duration lifetime);
~SyncInterestTable ();
/**
* @brief Insert an interest, if interest already exists, update the
* timestamp
*/
bool
insert (DigestConstPtr interest, const std::string &name, bool unknownState=false);
/**
* @brief Remove interest by digest (e.g., when it was satisfied)
*/
bool
remove (DigestConstPtr interest);
/**
* @brief Remove interest by name (e.g., when it was satisfied)
*/
bool
remove (const std::string &name);
/**
* @brief pop a non-expired Interest from PIT
*/
Interest
pop ();
uint32_t
size () const;
private:
/**
* @brief periodically called to expire Interest
*/
void
expireInterests ();
private:
ndn::time::system_clock::Duration m_entryLifetime;
InterestContainer m_table;
ndn::Scheduler m_scheduler;
};
namespace Error {
struct InterestTableIsEmpty : virtual boost::exception, virtual std::exception { };
}
} // Sync
#endif // SYNC_INTEREST_TABLE_H
-43
View File
@@ -1,43 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-leaf.h"
namespace Sync {
Leaf::Leaf (NameInfoConstPtr info, const SeqNo &seq)
: m_info (info)
, m_seq (seq)
{
}
Leaf::~Leaf ()
{
}
void
Leaf::setSeq (const SeqNo &seq)
{
m_seq = std::max (m_seq, seq);
}
} // Sync
-84
View File
@@ -1,84 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_LEAF_H
#define SYNC_LEAF_H
#include "sync-seq-no.h"
#include "sync-name-info.h"
namespace Sync {
/**
* \ingroup sync
* @brief Sync tree leaf
*/
class Leaf
{
public:
/**
* @brief Constructor
* @param info Smart pointer to leaf's name
* @param seq Initial sequence number of the pointer
*/
Leaf (NameInfoConstPtr info, const SeqNo &seq);
virtual ~Leaf ();
/**
* @brief Get name of the leaf
*/
NameInfoConstPtr
getInfo () const { return m_info; }
/**
* @brief Get sequence number of the leaf
*/
const SeqNo&
getSeq () const { return m_seq; }
/**
* @brief Update sequence number of the leaf
* @param seq Sequence number
*
* Sequence number is updated to the largest value among this->m_seq and seq
*/
virtual void
setSeq (const SeqNo &seq);
private:
NameInfoConstPtr m_info;
SeqNo m_seq;
};
typedef shared_ptr<Leaf> LeafPtr;
typedef shared_ptr<const Leaf> LeafConstPtr;
inline std::ostream &
operator << (std::ostream &os, const Leaf &leaf)
{
os << *leaf.getInfo () << "(" << leaf.getSeq () << ")";
return os;
}
} // Sync
#endif // SYNC_LEAF_H
-61
View File
@@ -1,61 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-logging.h"
#ifdef HAVE_LOG4CXX
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/consoleappender.h>
#include <log4cxx/patternlayout.h>
#include <log4cxx/level.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/defaultconfigurator.h>
#include <log4cxx/helpers/exception.h>
using namespace log4cxx;
using namespace log4cxx::helpers;
#include <unistd.h>
void
INIT_LOGGERS ()
{
static bool configured = false;
if (configured) return;
if (access ("log4cxx.properties", R_OK)==0)
PropertyConfigurator::configureAndWatch ("log4cxx.properties");
else
{
PatternLayoutPtr layout (new PatternLayout ("%d{HH:mm:ss} %p %c{1} - %m%n"));
ConsoleAppenderPtr appender (new ConsoleAppender (layout));
BasicConfigurator::configure( appender );
Logger::getRootLogger()->setLevel (log4cxx::Level::getInfo ());
}
configured = true;
}
#endif
-74
View File
@@ -1,74 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_LOG_H
#define SYNC_LOG_H
#ifdef HAVE_LOG4CXX
#include <log4cxx/logger.h>
#define INIT_LOGGER(name) \
static log4cxx::LoggerPtr staticModuleLogger = log4cxx::Logger::getLogger (name)
#define _LOG_DEBUG(x) \
LOG4CXX_DEBUG(staticModuleLogger, x);
#define _LOG_TRACE(x) \
LOG4CXX_TRACE(staticModuleLogger, x);
#define _LOG_FUNCTION(x) \
LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "(" << x << ")");
#define _LOG_FUNCTION_NOARGS \
LOG4CXX_TRACE(staticModuleLogger, __FUNCTION__ << "()");
#define _LOG_ERROR(x) \
LOG4CXX_ERROR(staticModuleLogger, x);
void
INIT_LOGGERS ();
#else
#define INIT_LOGGER(name)
#define _LOG_FUNCTION(x)
#define _LOG_FUNCTION_NOARGS
#define _LOG_TRACE(x)
#define INIT_LOGGERS(x)
#define _LOG_ERROR(x)
#ifdef _DEBUG
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
#define _LOG_DEBUG(x) \
std::clog << boost::get_system_time () << " " << boost::this_thread::get_id () << " " << x << endl;
#else
#define _LOG_DEBUG(x)
#endif
#endif // HAVE_LOG4CXX
#endif // SYNC_LOG_H
-84
View File
@@ -1,84 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_LOGIC_EVENT_CONTAINER_H
#define SYNC_LOGIC_EVENT_CONTAINER_H
#include "sync-event.h"
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/multi_index_container.hpp>
// #include <boost/multi_index/tag.hpp>
#include <boost/multi_index/ordered_index.hpp>
// #include <boost/multi_index/composite_key.hpp>
// #include <boost/multi_index/hashed_index.hpp>
// #include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index/member.hpp>
// #include <boost/multi_index/mem_fun.hpp>
namespace mi = boost::multi_index;
namespace Sync
{
struct LogicEvent
{
LogicEvent (const boost::system_time &_time, Event _event, uint32_t _label)
: time (_time)
, event (_event)
, lbl (_label)
{ }
boost::system_time time;
Event event;
uint32_t lbl;
};
/// @cond include_hidden
struct byLabel { } ;
/// @endcond
/**
* \ingroup sync
* @brief ???
*/
struct EventsContainer : public mi::multi_index_container<
LogicEvent,
mi::indexed_by<
mi::ordered_non_unique<
mi::member<LogicEvent, boost::system_time, &LogicEvent::time>
>,
mi::ordered_non_unique<
mi::tag<byLabel>,
mi::member<LogicEvent, uint32_t, &LogicEvent::lbl>
>
>
>
{
};
} // Sync
#endif // SYNC_LOGIC_EVENT_CONTAINER_H
-750
View File
@@ -1,750 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Yingdi Yu <yingdi@cs.ucla.edu>
*/
#include "sync-logic.h"
#include "sync-diff-leaf.h"
#include "sync-full-leaf.h"
#include "sync-logging.h"
#include "sync-state.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
#include <vector>
using namespace std;
using ndn::Data;
using ndn::EventId;
using ndn::KeyChain;
using ndn::Face;
using ndn::Name;
using ndn::OnDataValidated;
using ndn::OnDataValidationFailed;
using ndn::Validator;
INIT_LOGGER ("SyncLogic");
#ifdef _DEBUG
#define _LOG_DEBUG_ID(v) _LOG_DEBUG(m_instanceId << " " << v)
#else
#define _LOG_DEBUG_ID(v) _LOG_DEBUG(v)
#endif
#define GET_RANDOM(var) var ()
#define TIME_SECONDS_WITH_JITTER(sec) \
(ndn::time::seconds(sec) + ndn::time::milliseconds(GET_RANDOM (m_reexpressionJitter)))
#define TIME_MILLISECONDS_WITH_JITTER(ms) \
(ndn::time::seconds(ms) + ndn::time::milliseconds(GET_RANDOM (m_reexpressionJitter)))
namespace Sync {
using ndn::shared_ptr;
int SyncLogic::m_instanceCounter = 0;
const int SyncLogic::m_syncResponseFreshness = 1000; // MUST BE dividable by 1000!!!
const int SyncLogic::m_syncInterestReexpress = 4; // seconds
SyncLogic::SyncLogic (const Name& syncPrefix,
shared_ptr<Validator> validator,
shared_ptr<Face> face,
LogicUpdateCallback onUpdate,
LogicRemoveCallback onRemove)
: m_state (new FullState)
, m_syncInterestTable (face->getIoService(), ndn::time::seconds(m_syncInterestReexpress))
, m_syncPrefix (syncPrefix)
, m_onUpdate (onUpdate)
, m_onRemove (onRemove)
, m_perBranch (false)
, m_validator(validator)
, m_keyChain(new KeyChain())
, m_face(face)
, m_scheduler(face->getIoService())
, m_randomGenerator (static_cast<unsigned int> (std::time (0)))
, m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
, m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
, m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
{
m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
bind(&SyncLogic::onSyncInterest,
this, _1, _2),
bind(&SyncLogic::onSyncRegisterSucceed,
this, _1),
bind(&SyncLogic::onSyncRegisterFailed,
this, _1, _2));
m_reexpressingInterestId = m_scheduler.scheduleEvent (ndn::time::seconds (0),
bind (&SyncLogic::sendSyncInterest, this));
m_instanceId = string("Instance " + boost::lexical_cast<string>(m_instanceCounter++) + " ");
}
SyncLogic::SyncLogic (const Name& syncPrefix,
shared_ptr<Validator> validator,
shared_ptr<Face> face,
LogicPerBranchCallback onUpdateBranch)
: m_state (new FullState)
, m_syncInterestTable (face->getIoService(), ndn::time::seconds (m_syncInterestReexpress))
, m_syncPrefix (syncPrefix)
, m_onUpdateBranch (onUpdateBranch)
, m_perBranch(true)
, m_validator(validator)
, m_keyChain(new KeyChain())
, m_face(face)
, m_scheduler(face->getIoService())
, m_randomGenerator (static_cast<unsigned int> (std::time (0)))
, m_rangeUniformRandom (m_randomGenerator, boost::uniform_int<> (200,1000))
, m_reexpressionJitter (m_randomGenerator, boost::uniform_int<> (100,500))
, m_recoveryRetransmissionInterval (m_defaultRecoveryRetransmitInterval)
{
m_syncRegisteredPrefixId = m_face->setInterestFilter (m_syncPrefix,
bind(&SyncLogic::onSyncInterest,
this, _1, _2),
bind(&SyncLogic::onSyncRegisterSucceed,
this, _1),
bind(&SyncLogic::onSyncRegisterFailed,
this, _1, _2));
m_reexpressingInterestId = m_scheduler.scheduleEvent (ndn::time::seconds (0),
bind (&SyncLogic::sendSyncInterest, this));
}
SyncLogic::~SyncLogic ()
{
m_face->unsetInterestFilter(m_syncRegisteredPrefixId);
m_scheduler.cancelEvent (m_reexpressingInterestId);
m_scheduler.cancelEvent (m_delayedInterestProcessingId);
}
/**
* Two types of intersts
*
* Normal name: .../<hash>
* Recovery name: .../recovery/<hash>
*/
tuple<DigestConstPtr, std::string>
SyncLogic::convertNameToDigestAndType (const Name &name)
{
BOOST_ASSERT (m_syncPrefix.isPrefixOf(name));
int nameLengthDiff = name.size() - m_syncPrefix.size();
BOOST_ASSERT (nameLengthDiff > 0);
BOOST_ASSERT (nameLengthDiff < 3);
string hash = name.get(-1).toUri();
string interestType;
if(nameLengthDiff == 1)
interestType = "normal";
else
interestType = name.get(-2).toUri();
_LOG_DEBUG_ID (hash << ", " << interestType);
DigestPtr digest = make_shared<Digest> ();
istringstream is (hash);
is >> *digest;
return make_tuple(digest, interestType);
}
void
SyncLogic::onSyncInterest (const Name& prefix, const ndn::Interest& interest)
{
Name name = interest.getName();
_LOG_DEBUG_ID("respondSyncInterest: " << name);
try
{
_LOG_DEBUG_ID ("<< I " << name);
DigestConstPtr digest;
string type;
tie (digest, type) = convertNameToDigestAndType (name);
if (type == "normal") // kind of ineffective...
{
processSyncInterest (name, digest);
}
else if (type == "recovery")
{
processSyncRecoveryInterest (name, digest);
}
}
catch (Error::DigestCalculationError &e)
{
_LOG_DEBUG_ID ("Something fishy happened...");
// log error. ignoring it for now, later we should log it
return ;
}
}
void
SyncLogic::onSyncRegisterSucceed(const Name& prefix)
{
_LOG_DEBUG_ID("Sync prefix registration succeeded! " << prefix);
}
void
SyncLogic::onSyncRegisterFailed(const Name& prefix, const string& msg)
{
_LOG_DEBUG_ID("Sync prefix registration failed! " << msg);
}
void
SyncLogic::onSyncData(const ndn::Interest& interest, Data& data)
{
OnDataValidated onValidated = bind(&SyncLogic::onSyncDataValidated, this, _1);
OnDataValidationFailed onValidationFailed = bind(&SyncLogic::onSyncDataValidationFailed, this, _1);
m_validator->validate(data, onValidated, onValidationFailed);
}
void
SyncLogic::onSyncTimeout(const ndn::Interest& interest)
{
// It is OK. Others will handle the time out situation.
}
void
SyncLogic::onSyncDataValidationFailed(const shared_ptr<const Data>& data)
{
_LOG_DEBUG_ID("Sync data cannot be verified!");
}
void
SyncLogic::onSyncDataValidated(const shared_ptr<const Data>& data)
{
Name name = data->getName();
const char* wireData = (const char*)data->getContent().value();
size_t len = data->getContent().value_size();
try
{
_LOG_DEBUG_ID ("<< D " << name);
DigestConstPtr digest;
string type;
tie (digest, type) = convertNameToDigestAndType (name);
if (type == "normal")
{
processSyncData (name, digest, wireData, len);
}
else
{
// timer is always restarted when we schedule recovery
m_scheduler.cancelEvent (m_reexpressingRecoveryInterestId);
processSyncData (name, digest, wireData, len);
}
}
catch (Error::DigestCalculationError &e)
{
_LOG_DEBUG_ID ("Something fishy happened...");
// log error. ignoring it for now, later we should log it
return;
}
}
void
SyncLogic::processSyncInterest (const Name &name, DigestConstPtr digest,
bool timedProcessing/*=false*/)
{
_LOG_DEBUG_ID("processSyncInterest");
DigestConstPtr rootDigest;
{
rootDigest = m_state->getDigest();
}
// Special case when state is not empty and we have received request with zero-root digest
if (digest->isZero () && !rootDigest->isZero ())
{
SyncStateMsg ssm;
{
ssm << (*m_state);
}
sendSyncData (name, digest, ssm);
return;
}
if (*rootDigest == *digest)
{
_LOG_DEBUG_ID ("processSyncInterest (): Same state. Adding to PIT");
m_syncInterestTable.insert (digest, name.toUri(), false);
return;
}
DiffStateContainer::iterator stateInDiffLog = m_log.find (digest);
if (stateInDiffLog != m_log.end ())
{
DiffStateConstPtr stateDiff = (*stateInDiffLog)->diff ();
sendSyncData (name, digest, stateDiff);
return;
}
if (!timedProcessing)
{
bool exists = m_syncInterestTable.insert (digest, name.toUri(), true);
if (exists) // somebody else replied, so restart random-game timer
{
_LOG_DEBUG_ID("Unknown digest, but somebody may have already replied, " <<
"so restart our timer");
m_scheduler.cancelEvent (m_delayedInterestProcessingId);
}
uint32_t waitDelay = GET_RANDOM (m_rangeUniformRandom);
_LOG_DEBUG_ID("Digest is not in the log. Schedule processing after small delay: " <<
ndn::time::milliseconds (waitDelay));
m_delayedInterestProcessingId =
m_scheduler.scheduleEvent(ndn::time::milliseconds (waitDelay),
bind (&SyncLogic::processSyncInterest, this, name, digest, true));
}
else
{
_LOG_DEBUG_ID(" (timed processing)");
m_recoveryRetransmissionInterval = m_defaultRecoveryRetransmitInterval;
sendSyncRecoveryInterests (digest);
}
}
void
SyncLogic::processSyncData (const Name &name, DigestConstPtr digest,
const char *wireData, size_t len)
{
DiffStatePtr diffLog = make_shared<DiffState> ();
bool ownInterestSatisfied = false;
try
{
m_syncInterestTable.remove (name.toUri()); // Remove satisfied interest from PIT
ownInterestSatisfied = (name == m_outstandingInterestName);
DiffState diff;
SyncStateMsg msg;
if (!msg.ParseFromArray(wireData, len) || !msg.IsInitialized())
{
//Throw
BOOST_THROW_EXCEPTION (Error::SyncStateMsgDecodingFailure () );
}
msg >> diff;
vector<MissingDataInfo> v;
BOOST_FOREACH (LeafConstPtr leaf, diff.getLeaves().get<ordered>())
{
DiffLeafConstPtr diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
BOOST_ASSERT (diffLeaf != 0);
NameInfoConstPtr info = diffLeaf->getInfo();
if (diffLeaf->getOperation() == UPDATE)
{
SeqNo seq = diffLeaf->getSeq();
bool inserted = false;
bool updated = false;
SeqNo oldSeq;
{
tie (inserted, updated, oldSeq) = m_state->update (info, seq);
}
if (inserted || updated)
{
diffLog->update (info, seq);
if (!oldSeq.isValid())
{
oldSeq = SeqNo(seq.getSession(), 0);
}
else
{
++oldSeq;
}
// there is no need for application to process update on forwarder node
if (info->toString() != forwarderPrefix)
{
MissingDataInfo mdi = {info->toString(), oldSeq, seq};
{
ostringstream interestName;
interestName << mdi.prefix <<
"/" << mdi.high.getSession() <<
"/" << mdi.high.getSeq();
_LOG_DEBUG_ID("+++++++++++++++ " + interestName.str());
}
if (m_perBranch)
{
ostringstream interestName;
interestName << mdi.prefix <<
"/" << mdi.high.getSession() <<
"/" << mdi.high.getSeq();
m_onUpdateBranch(interestName.str());
}
else
{
v.push_back(mdi);
}
}
}
}
else if (diffLeaf->getOperation() == REMOVE)
{
if (m_state->remove (info))
{
diffLog->remove (info);
if (!m_perBranch)
{
m_onRemove (info->toString ());
}
}
}
else
{
}
}
if (!v.empty())
{
if (!m_perBranch)
{
m_onUpdate(v);
}
}
insertToDiffLog (diffLog);
}
catch (Error::SyncStateMsgDecodingFailure &e)
{
_LOG_DEBUG_ID ("Something really fishy happened during state decoding " <<
diagnostic_information (e));
diffLog.reset ();
// don't do anything
}
if ((diffLog != 0 && diffLog->getLeaves ().size () > 0) ||
ownInterestSatisfied)
{
_LOG_DEBUG_ID(" +++++++++++++++ state changed!!!");
// Do it only if everything went fine and state changed
// this is kind of wrong
// satisfyPendingSyncInterests (diffLog); // if there are interests in PIT,
// // there is a point to satisfy them using new state
// if state has changed, then it is safe to express a new interest
ndn::time::system_clock::Duration after =
ndn::time::milliseconds(GET_RANDOM (m_reexpressionJitter));
// cout << "------------ reexpress interest after: " << after << endl;
EventId eventId = m_scheduler.scheduleEvent (after,
bind (&SyncLogic::sendSyncInterest, this));
m_scheduler.cancelEvent (m_reexpressingInterestId);
m_reexpressingInterestId = eventId;
}
}
void
SyncLogic::processSyncRecoveryInterest (const Name &name, DigestConstPtr digest)
{
_LOG_DEBUG_ID("processSyncRecoveryInterest");
DiffStateContainer::iterator stateInDiffLog = m_log.find (digest);
if (stateInDiffLog == m_log.end ())
{
_LOG_DEBUG_ID ("Could not find " << *digest << " in digest log");
return;
}
SyncStateMsg ssm;
{
ssm << (*m_state);
}
sendSyncData (name, digest, ssm);
}
void
SyncLogic::satisfyPendingSyncInterests (DiffStateConstPtr diffLog)
{
DiffStatePtr fullStateLog = make_shared<DiffState> ();
{
BOOST_FOREACH (LeafConstPtr leaf, m_state->getLeaves ()/*.get<timed> ()*/)
{
fullStateLog->update (leaf->getInfo (), leaf->getSeq ());
/// @todo Impose limit on how many state info should be send out
}
}
try
{
uint32_t counter = 0;
while (m_syncInterestTable.size () > 0)
{
Sync::Interest interest = m_syncInterestTable.pop ();
if (!interest.m_unknown)
{
_LOG_DEBUG_ID (">> D " << interest.m_name);
sendSyncData (interest.m_name, interest.m_digest, diffLog);
}
else
{
_LOG_DEBUG_ID (">> D (unknown)" << interest.m_name);
sendSyncData (interest.m_name, interest.m_digest, fullStateLog);
}
counter ++;
}
_LOG_DEBUG_ID ("Satisfied " << counter << " pending interests");
}
catch (Error::InterestTableIsEmpty &e)
{
// ok. not really an error
}
}
void
SyncLogic::insertToDiffLog (DiffStatePtr diffLog)
{
diffLog->setDigest (m_state->getDigest());
if (m_log.size () > 0)
{
m_log.get<sequenced> ().front ()->setNext (diffLog);
}
m_log.erase (m_state->getDigest()); // remove diff state with the same digest.
// next pointers are still valid
/// @todo Optimization
m_log.get<sequenced> ().push_front (diffLog);
}
void
SyncLogic::addLocalNames (const Name &prefix, uint64_t session, uint64_t seq)
{
DiffStatePtr diff;
{
//cout << "Add local names" <<endl;
NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix.toUri());
_LOG_DEBUG_ID ("addLocalNames (): old state " << *m_state->getDigest ());
SeqNo seqN (session, seq);
m_state->update(info, seqN);
_LOG_DEBUG_ID ("addLocalNames (): new state " << *m_state->getDigest ());
diff = make_shared<DiffState>();
diff->update(info, seqN);
insertToDiffLog (diff);
}
// _LOG_DEBUG_ID ("PIT size: " << m_syncInterestTable.size ());
satisfyPendingSyncInterests (diff);
}
void
SyncLogic::remove(const Name &prefix)
{
DiffStatePtr diff;
{
NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix.toUri());
m_state->remove(info);
// increment the sequence number for the forwarder node
NameInfoConstPtr forwarderInfo = StdNameInfo::FindOrCreate(forwarderPrefix);
LeafContainer::iterator item = m_state->getLeaves ().find (forwarderInfo);
SeqNo seqNo (0);
if (item != m_state->getLeaves ().end ())
{
seqNo = (*item)->getSeq ();
++seqNo;
}
m_state->update (forwarderInfo, seqNo);
diff = make_shared<DiffState>();
diff->remove(info);
diff->update(forwarderInfo, seqNo);
insertToDiffLog (diff);
}
satisfyPendingSyncInterests (diff);
}
void
SyncLogic::sendSyncInterest ()
{
_LOG_DEBUG_ID("sendSyncInterest");
{
m_outstandingInterestName = m_syncPrefix;
ostringstream os;
os << *m_state->getDigest();
m_outstandingInterestName.append(os.str());
_LOG_DEBUG_ID (">> I " << m_outstandingInterestName);
}
_LOG_DEBUG_ID("sendSyncInterest: " << m_outstandingInterestName);
EventId eventId =
m_scheduler.scheduleEvent(ndn::time::seconds(m_syncInterestReexpress) +
ndn::time::milliseconds(GET_RANDOM(m_reexpressionJitter)),
bind (&SyncLogic::sendSyncInterest, this));
m_scheduler.cancelEvent (m_reexpressingInterestId);
m_reexpressingInterestId = eventId;
ndn::Interest interest(m_outstandingInterestName);
interest.setMustBeFresh(true);
m_face->expressInterest(interest,
bind(&SyncLogic::onSyncData, this, _1, _2),
bind(&SyncLogic::onSyncTimeout, this, _1));
}
void
SyncLogic::sendSyncRecoveryInterests (DigestConstPtr digest)
{
ostringstream os;
os << *digest;
Name interestName = m_syncPrefix;
interestName.append("recovery").append(os.str());
ndn::time::system_clock::Duration nextRetransmission =
ndn::time::milliseconds(m_recoveryRetransmissionInterval + GET_RANDOM (m_reexpressionJitter));
m_recoveryRetransmissionInterval <<= 1;
m_scheduler.cancelEvent (m_reexpressingRecoveryInterestId);
if (m_recoveryRetransmissionInterval < 100*1000) // <100 seconds
m_reexpressingRecoveryInterestId =
m_scheduler.scheduleEvent (nextRetransmission,
bind (&SyncLogic::sendSyncRecoveryInterests, this, digest));
ndn::Interest interest(interestName);
interest.setMustBeFresh(true);
m_face->expressInterest(interest,
bind(&SyncLogic::onSyncData, this, _1, _2),
bind(&SyncLogic::onSyncTimeout, this, _1));
}
void
SyncLogic::sendSyncData (const Name &name, DigestConstPtr digest, StateConstPtr state)
{
SyncStateMsg msg;
msg << (*state);
sendSyncData(name, digest, msg);
}
// pass in state msg instead of state, so that there is no need to lock the state until
// this function returns
void
SyncLogic::sendSyncData (const Name &name, DigestConstPtr digest, SyncStateMsg &ssm)
{
_LOG_DEBUG_ID (">> D " << name);
int size = ssm.ByteSize();
char *wireData = new char[size];
ssm.SerializeToArray(wireData, size);
//Data syncData(name);
ndn::shared_ptr<ndn::Data> syncData = ndn::make_shared<ndn::Data>();
syncData->setName(name);
syncData->setContent(reinterpret_cast<const uint8_t*>(wireData), size);
syncData->setFreshnessPeriod(ndn::time::seconds(m_syncResponseFreshness));
m_keyChain->sign(*syncData);
m_face->put(*syncData);
delete []wireData;
// checking if our own interest got satisfied
bool satisfiedOwnInterest = false;
{
satisfiedOwnInterest = (m_outstandingInterestName == name);
}
if (satisfiedOwnInterest)
{
_LOG_DEBUG_ID ("Satisfied our own Interest. Re-expressing (hopefully with a new digest)");
ndn::time::system_clock::Duration after =
ndn::time::milliseconds(GET_RANDOM(m_reexpressionJitter));
// cout << "------------ reexpress interest after: " << after << endl;
EventId eventId = m_scheduler.scheduleEvent (after,
bind (&SyncLogic::sendSyncInterest, this));
m_scheduler.cancelEvent (m_reexpressingInterestId);
m_reexpressingInterestId = eventId;
}
}
string
SyncLogic::getRootDigest()
{
ostringstream os;
os << *m_state->getDigest();
return os.str();
}
size_t
SyncLogic::getNumberOfBranches () const
{
return m_state->getLeaves ().size ();
}
void
SyncLogic::printState () const
{
BOOST_FOREACH (const shared_ptr<Sync::Leaf> leaf, m_state->getLeaves ())
{
std::cout << *leaf << std::endl;
}
}
std::map<std::string, bool>
SyncLogic::getBranchPrefixes() const
{
std::map<std::string, bool> m;
BOOST_FOREACH (const shared_ptr<Sync::Leaf> leaf, m_state->getLeaves ())
{
std::string prefix = leaf->getInfo()->toString();
// do not return forwarder prefix
if (prefix != forwarderPrefix)
{
m.insert(pair<std::string, bool>(prefix, false));
}
}
return m;
}
}
-223
View File
@@ -1,223 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Yingdi Yu <yingdi@cs.ucla.edu>
*/
#ifndef SYNC_LOGIC_H
#define SYNC_LOGIC_H
#include <boost/random.hpp>
#include <memory>
#include <map>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/validator.hpp>
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/util/scheduler.hpp>
#include "sync-interest-table.h"
#include "sync-diff-state.h"
#include "sync-full-state.h"
#include "sync-std-name-info.h"
#include "sync-diff-state-container.h"
#ifdef _DEBUG
#ifdef HAVE_LOG4CXX
#include <log4cxx/logger.h>
#endif
#endif
namespace Sync {
struct MissingDataInfo {
std::string prefix;
SeqNo low;
SeqNo high;
};
/**
* \ingroup sync
* @brief A wrapper for SyncApp, which handles ccnx related things (process
* interests and data)
*/
class SyncLogic
{
public:
typedef function< void (const std::vector<MissingDataInfo> & ) > LogicUpdateCallback;
typedef function< void (const std::string &/*prefix*/ ) > LogicRemoveCallback;
typedef function< void (const std::string &)> LogicPerBranchCallback;
/**
* @brief Constructor
* @param syncPrefix the name prefix to use for the Sync Interest
* @param onUpdate function that will be called when new state is detected
* @param onRemove function that will be called when state is removed
* @param ccnxHandle ccnx handle
* the app data when new remote names are learned
*/
SyncLogic (const ndn::Name& syncPrefix,
ndn::shared_ptr<ndn::Validator> validator,
ndn::shared_ptr<ndn::Face> face,
LogicUpdateCallback onUpdate,
LogicRemoveCallback onRemove);
SyncLogic (const ndn::Name& syncPrefix,
ndn::shared_ptr<ndn::Validator> validator,
ndn::shared_ptr<ndn::Face> face,
LogicPerBranchCallback onUpdateBranch);
~SyncLogic ();
/**
* a wrapper for the same func in SyncApp
*/
void addLocalNames (const ndn::Name &prefix, uint64_t session, uint64_t seq);
/**
* @brief remove a participant's subtree from the sync tree
* @param prefix the name prefix for the participant
*/
void remove (const ndn::Name &prefix);
std::string
getRootDigest();
#ifdef _DEBUG
ndn::Scheduler &
getScheduler () { return m_scheduler; }
#endif
void
printState () const;
std::map<std::string, bool>
getBranchPrefixes() const;
private:
void
delayedChecksLoop ();
void
onSyncInterest (const ndn::Name& prefix, const ndn::Interest& interest);
void
onSyncRegisterSucceed(const ndn::Name& prefix);
void
onSyncRegisterFailed(const ndn::Name& prefix, const std::string& msg);
void
onSyncData(const ndn::Interest& interest, ndn::Data& data);
void
onSyncTimeout(const ndn::Interest& interest);
void
onSyncDataValidationFailed(const ndn::shared_ptr<const ndn::Data>& data);
void
onSyncDataValidated(const ndn::shared_ptr<const ndn::Data>& data);
void
processSyncInterest (const ndn::Name &name,
DigestConstPtr digest, bool timedProcessing=false);
void
processSyncData (const ndn::Name &name,
DigestConstPtr digest, const char *wireData, size_t len);
void
processSyncRecoveryInterest (const ndn::Name &name,
DigestConstPtr digest);
void
insertToDiffLog (DiffStatePtr diff);
void
satisfyPendingSyncInterests (DiffStateConstPtr diff);
tuple<DigestConstPtr, std::string>
convertNameToDigestAndType (const ndn::Name &name);
void
sendSyncInterest ();
void
sendSyncRecoveryInterests (DigestConstPtr digest);
void
sendSyncData (const ndn::Name &name,
DigestConstPtr digest, StateConstPtr state);
void
sendSyncData (const ndn::Name &name,
DigestConstPtr digest, SyncStateMsg &msg);
size_t
getNumberOfBranches () const;
private:
FullStatePtr m_state;
DiffStateContainer m_log;
ndn::Name m_outstandingInterestName;
SyncInterestTable m_syncInterestTable;
ndn::Name m_syncPrefix;
LogicUpdateCallback m_onUpdate;
LogicRemoveCallback m_onRemove;
LogicPerBranchCallback m_onUpdateBranch;
bool m_perBranch;
std::shared_ptr<ndn::Validator> m_validator;
std::shared_ptr<ndn::KeyChain> m_keyChain;
std::shared_ptr<ndn::Face> m_face;
const ndn::RegisteredPrefixId* m_syncRegisteredPrefixId;
ndn::Scheduler m_scheduler;
boost::mt19937 m_randomGenerator;
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > m_rangeUniformRandom;
boost::variate_generator<boost::mt19937&, boost::uniform_int<> > m_reexpressionJitter;
static const int m_unknownDigestStoreTime = 10; // seconds
static const int m_syncResponseFreshness; // MUST BE dividable by 1000!!!
static const int m_syncInterestReexpress; // seconds
static const int m_defaultRecoveryRetransmitInterval = 200; // milliseconds
uint32_t m_recoveryRetransmissionInterval; // milliseconds
ndn::EventId m_delayedInterestProcessingId;
ndn::EventId m_reexpressingInterestId;
ndn::EventId m_reexpressingRecoveryInterestId;
std::string m_instanceId;
static int m_instanceCounter;
};
} // Sync
#endif // SYNC_APP_WRAPPER_H
-32
View File
@@ -1,32 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-name-info.h"
// #include <boost/lexical_cast.hpp>
namespace Sync {
NameInfo::NameMap NameInfo::m_names;
size_t NameInfo::m_ids = 0;
} // Sync
-102
View File
@@ -1,102 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_NAME_INFO_H
#define SYNC_NAME_INFO_H
#include "sync-common.h"
#include <map>
#include <string>
#include "sync-digest.h"
namespace Sync {
/**
* @ingroup sync
* @brief Templated class for the leaf name
*/
class NameInfo
{
private:
typedef weak_ptr<const NameInfo> const_weak_ptr;
public:
virtual ~NameInfo () { };
/**
* @brief Get ID of the record (should be locally-unique, but not really necessary---this is be used for hashing purposes)
*/
size_t
getHashId () const { return m_id; }
/**
* @brief Check if two names are equal
* @param info name to check with
*/
virtual bool
operator == (const NameInfo &info) const = 0;
/**
* @brief Check if two names are in order
* @param info name to check with
*/
virtual bool
operator < (const NameInfo &info) const = 0;
/**
* @brief Calculates digest of the name
*/
const Digest &
getDigest () const { return m_digest; }
/**
* @brief Convert prefix to string
* @returns string representation of prefix
*/
virtual std::string
toString () const = 0;
protected:
// actual stuff
size_t m_id; ///< @brief Identifies NameInfo throughout the library (for hash container, doesn't need to be strictly unique)
Digest m_digest;
// static stuff
typedef std::map<std::string, const_weak_ptr> NameMap;
static size_t m_ids;
static NameMap m_names;
};
typedef shared_ptr<NameInfo> NameInfoPtr;
typedef shared_ptr<const NameInfo> NameInfoConstPtr;
inline std::ostream &
operator << (std::ostream &os, const NameInfo &info)
{
os << info.toString ();
return os;
}
} // Sync
#endif // SYNC_NAME_INFO_H
-36
View File
@@ -1,36 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-seq-no.h"
namespace Sync {
DigestConstPtr
SeqNo::getDigest () const
{
DigestPtr digest = make_shared<Digest> ();
*digest << m_session << m_seq;
digest->finalize ();
return digest;
}
} // Sync
-198
View File
@@ -1,198 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
* Yingdi Yu <yingdi@cs.ucla.edu>
*/
#ifndef SYNC_SEQ_NO_H
#define SYNC_SEQ_NO_H
#include <boost/cstdint.hpp>
#include "sync-digest.h"
namespace Sync {
/**
* @ingroup sync
* @brief Sequence number abstraction
*/
class SeqNo
{
public:
/**
* @brief Default constructor. Creates an zero sequence number with zero session ID (basically is an invalid object)
*/
SeqNo ()
: m_valid (false)
, m_session (0)
, m_seq (0)
{
}
/**
* @brief Copy constructor
* @param seq sequence number object to copy from
*/
SeqNo (const SeqNo &seq)
{
*this = seq;
}
/**
* @brief Assignment operator
* @param seq sequence number object to copy from
*/
SeqNo &
operator = (const SeqNo &seq)
{
m_valid = seq.m_valid;
m_session = seq.m_session;
m_seq = seq.m_seq;
return *this;
}
/**
* @brief Constructor with just sequence number. Session assumed to be zero
* @param seq Sequence number
*/
SeqNo (uint64_t seq)
: m_valid (true)
, m_session (0)
, m_seq (seq)
{ }
/**
* @brief Constructor with session and sequence id
* @param session Session ID
* @param seq Sequence number
*/
SeqNo (uint64_t session, uint64_t seq)
: m_valid (true)
, m_session (session)
, m_seq (seq)
{ }
/**
* @brief Get sequence number digest
*
* Digest will be calculated every time it is requested
*/
DigestConstPtr
getDigest () const;
/**
* @brief Compare if one sequence number is lower
* @param seq Another sequence number to compare with
*
* tuple (session1, seq1) is less than (session2, seq2) in two cases:
* 1. session1 < session2
* 2. session1 == session2 and seq1 < seq2
*/
bool
operator < (const SeqNo &seq) const
{
return m_session < seq.m_session || (m_session == seq.m_session && m_seq < seq.m_seq);
}
/**
* @brief Compare if two sequence numbers are equal
* @param seq Another sequence number to compare with
*/
bool
operator == (const SeqNo &seq) const
{
return m_session == seq.m_session && m_seq == seq.m_seq;
}
bool
operator <= (const SeqNo &seq) const
{
return m_session == seq.m_session && m_seq <= seq.m_seq;
}
SeqNo &
operator ++ ()
{
if (m_valid) {
m_seq ++;
}
else {
m_valid = true;
}
return *this;
}
bool
isValid () const
{
return m_valid;
}
/**
* @brief Get session id
*/
uint64_t getSession () const
{ return m_session; }
/**
* @brief Get sequence number
*/
uint64_t getSeq () const
{ return m_seq; }
/**
* @brief Set sequence number
*/
void
setSeq(uint64_t seq)
{ m_seq = seq; }
private:
bool m_valid;
/**
* @brief Session ID (e.g., after crash, application will choose new session ID.
*
* Note that session IDs for the same name should always increase. So, the good choice
* for the session ID is client's timestamp
*/
uint64_t m_session;
/**
* @brief Sequence number
*
* Sequence number for a session always starts with 0 and goes to max value.
*
* For now, wrapping sequence number after max to zero is not supported
*/
uint64_t m_seq;
};
inline std::ostream &
operator << (std::ostream &os, const SeqNo &seqno)
{
os << "<session>" << seqno.getSession () << "</session><seqno>" << seqno.getSeq () << "</seqno>";
return os;
}
} // Sync
#endif // SYNC_SEQ_NO_H
-176
View File
@@ -1,176 +0,0 @@
/* -*- Mode: C32++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Yingdi Yu <yingdi@cs.ucla.edu>
*/
#include "sync-socket.h"
#include "sync-logging.h"
#include <boost/lexical_cast.hpp>
#include <boost/thread.hpp>
using namespace std;
using ndn::Data;
using ndn::Face;
using ndn::KeyChain;
using ndn::Name;
using ndn::OnDataValidated;
using ndn::OnDataValidationFailed;
using ndn::Validator;
INIT_LOGGER ("SyncSocket");
namespace Sync {
using ndn::shared_ptr;
using ndn::make_shared;
SyncSocket::SyncSocket (const Name &syncPrefix,
shared_ptr<Validator> validator,
shared_ptr<Face> face,
NewDataCallback dataCallback,
RemoveCallback rmCallback )
: m_newDataCallback(dataCallback)
, m_validator(validator)
, m_keyChain(new KeyChain())
, m_face(face)
, m_syncLogic (syncPrefix,
validator,
face,
bind(&SyncSocket::passCallback, this, _1),
rmCallback)
{
}
SyncSocket::~SyncSocket()
{
}
bool
SyncSocket::publishData(const Name &prefix, uint64_t session,
const char *buf, size_t len,
int freshness,uint64_t seq)
{
shared_ptr<Data> data = make_shared<Data>();
data->setContent(reinterpret_cast<const uint8_t*>(buf), len);
data->setFreshnessPeriod(ndn::time::seconds(freshness));
m_face->getIoService().post(bind(&SyncSocket::publishDataInternal, this,
data, prefix, session,seq));
return true;
}
void
SyncSocket::publishDataInternal(shared_ptr<Data> data,
const Name &prefix, uint64_t session, uint64_t seq)
{
uint64_t sequence = seq;
Name dataName = prefix;
dataName.append(boost::lexical_cast<string>(session))
.append(boost::lexical_cast<string>(sequence));
data->setName(dataName);
m_keyChain->sign(*data);
m_face->put(*data);
SeqNo s(session, sequence + 1);
m_sequenceLog[prefix] = s;
m_syncLogic.addLocalNames (prefix, session, sequence);
}
void
SyncSocket::fetchData(const Name &prefix, const SeqNo &seq,
const OnDataValidated& onValidated, int retry)
{
Name interestName = prefix;
interestName.append(boost::lexical_cast<string>(seq.getSession()))
.append(boost::lexical_cast<string>(seq.getSeq()));
const OnDataValidationFailed& onValidationFailed =
bind(&SyncSocket::onDataValidationFailed, this, _1);
ndn::Interest interest(interestName);
interest.setMustBeFresh(true);
m_face->expressInterest(interest,
bind(&SyncSocket::onData, this, _1, _2,
onValidated, onValidationFailed),
bind(&SyncSocket::onDataTimeout, this, _1, retry,
onValidated, onValidationFailed));
}
void
SyncSocket::onData(const ndn::Interest& interest, Data& data,
const OnDataValidated& onValidated,
const OnDataValidationFailed& onValidationFailed)
{
m_validator->validate(data, onValidated, onValidationFailed);
}
void
SyncSocket::onDataTimeout(const ndn::Interest& interest,
int retry,
const OnDataValidated& onValidated,
const OnDataValidationFailed& onValidationFailed)
{
if(retry > 0)
{
m_face->expressInterest(interest,
bind(&SyncSocket::onData,
this,
_1,
_2,
onValidated,
onValidationFailed),
bind(&SyncSocket::onDataTimeout,
this,
_1,
retry - 1,
onValidated,
onValidationFailed));
}
else
_LOG_DEBUG("interest eventually time out!");
}
void
SyncSocket::onDataValidationFailed(const shared_ptr<const Data>& data)
{
_LOG_DEBUG("data cannot be verified!");
}
uint64_t
SyncSocket::getNextSeq (const Name &prefix, uint64_t session)
{
SequenceLog::iterator i = m_sequenceLog.find (prefix);
if (i != m_sequenceLog.end ())
{
SeqNo s = i->second;
if (s.getSession() == session)
return s.getSeq();
}
return 0;
}
}//Sync
-134
View File
@@ -1,134 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Yingdi Yu <yingdi@cs.ucla.edu>
*/
#ifndef _SYNC_SOCKET_H
#define _SYNC_SOCKET_H
#include "sync-common.h"
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/security/validator.hpp>
#include <ndn-cxx/security/key-chain.hpp>
#include "sync-logic.h"
#include "sync-seq-no.h"
#include <utility>
#include <map>
#include <vector>
#include <sstream>
namespace Sync {
/**
* \ingroup sync
* @brief A simple interface to interact with client code
*/
class SyncSocket
{
public:
typedef ndn::function<void(const std::vector<MissingDataInfo> &, SyncSocket *)> NewDataCallback;
typedef ndn::function<void(const std::string &/*prefix*/)> RemoveCallback;
/**
* @brief the constructor for SyncAppSocket; the parameter syncPrefix
* should be passed to the constructor of m_syncAppWrapper; the other
* parameter should be passed to the constructor of m_fetcher; furthermore,
* the fetch function of m_fetcher should be a second paramter passed to
* the constructor of m_syncAppWrapper, so that m_syncAppWrapper can tell
* m_fetcher to fetch the actual app data after it learns the names
*
* @param syncPrefix the name prefix for Sync Interest
* @param dataCallback the callback to process data
*/
SyncSocket (const ndn::Name &syncPrefix,
ndn::shared_ptr<ndn::Validator> validator,
ndn::shared_ptr<ndn::Face> face,
NewDataCallback dataCallback,
RemoveCallback rmCallback);
~SyncSocket ();
bool
publishData(const ndn::Name &prefix, uint64_t session, const char *buf, size_t len,
int freshness,uint64_t seq);
void
remove (const ndn::Name &prefix)
{ m_syncLogic.remove(prefix); }
void
fetchData(const ndn::Name &prefix, const SeqNo &seq,
const ndn::OnDataValidated& onValidated, int retry = 0);
std::string
getRootDigest()
{ return m_syncLogic.getRootDigest(); }
uint64_t
getNextSeq (const ndn::Name &prefix, uint64_t session);
SyncLogic &
getLogic ()
{ return m_syncLogic; }
// make this a static function so we don't have to create socket instance without
// knowing the local prefix. it's a wrong place for this function anyway
static std::string
GetLocalPrefix ();
private:
void
publishDataInternal(ndn::shared_ptr<ndn::Data> data,
const ndn::Name &prefix, uint64_t session,uint64_t seq);
void
passCallback(const std::vector<MissingDataInfo> &v)
{
m_newDataCallback(v, this);
}
void
onData(const ndn::Interest& interest, ndn::Data& data,
const ndn::OnDataValidated& onValidated,
const ndn::OnDataValidationFailed& onValidationFailed);
void
onDataTimeout(const ndn::Interest& interest,
int retry,
const ndn::OnDataValidated& onValidated,
const ndn::OnDataValidationFailed& onValidationFailed);
void
onDataValidationFailed(const ndn::shared_ptr<const ndn::Data>& data);
private:
typedef std::map<ndn::Name, SeqNo> SequenceLog;
NewDataCallback m_newDataCallback;
SequenceLog m_sequenceLog;
ndn::shared_ptr<ndn::Validator> m_validator;
ndn::shared_ptr<ndn::KeyChain> m_keyChain;
ndn::shared_ptr<ndn::Face> m_face;
SyncLogic m_syncLogic;
};
} // Sync
#endif // SYNC_SOCKET_H
-101
View File
@@ -1,101 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_STATE_LEAF_CONTAINER
#define SYNC_STATE_LEAF_CONTAINER
#include "sync-leaf.h"
#include "sync-name-info.h"
#include <boost/multi_index_container.hpp>
// #include <boost/multi_index/tag.hpp>
#include <boost/multi_index/ordered_index.hpp>
// #include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/hashed_index.hpp>
// #include <boost/multi_index/random_access_index.hpp>
// #include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
namespace mi = boost::multi_index;
namespace Sync {
struct NameInfoHash : public std::unary_function<NameInfo, std::size_t>
{
std::size_t
operator() (NameInfoConstPtr prefix) const
{
return prefix->getHashId ();
}
};
struct NameInfoEqual : public std::unary_function<NameInfo, std::size_t>
{
bool
operator() (NameInfoConstPtr prefix1, NameInfoConstPtr prefix2) const
{
return *prefix1 == *prefix2;
}
};
struct NameInfoCompare : public std::unary_function<NameInfo, std::size_t>
{
bool
operator() (NameInfoConstPtr prefix1, NameInfoConstPtr prefix2) const
{
return *prefix1 < *prefix2;
}
};
/// @cond include_hidden
struct hashed { };
struct ordered { };
/// @endcond
/**
* \ingroup sync
* @brief Container for SYNC leaves
*/
struct LeafContainer : public mi::multi_index_container<
LeafPtr,
mi::indexed_by<
// For fast access to elements using NameInfo
mi::hashed_unique<
mi::tag<hashed>,
mi::const_mem_fun<Leaf, NameInfoConstPtr, &Leaf::getInfo>,
NameInfoHash,
NameInfoEqual
>,
mi::ordered_unique<
mi::tag<ordered>,
mi::const_mem_fun<Leaf, NameInfoConstPtr, &Leaf::getInfo>,
NameInfoCompare
>
>
>
{
};
} // Sync
#endif // SYNC_STATE_LEAF_CONTAINER
-169
View File
@@ -1,169 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-state.h"
#include "sync-diff-leaf.h"
#include "sync-std-name-info.h"
#include <boost/assert.hpp>
#include <boost/foreach.hpp>
#include <boost/throw_exception.hpp>
#include <boost/lexical_cast.hpp>
typedef boost::error_info<struct tag_errmsg, std::string> info_str;
using namespace Sync::Error;
using boost::lexical_cast;
namespace Sync {
/*
std::ostream &
operator << (std::ostream &os, const State &state)
{
os << "<state>"; DEBUG_ENDL;
BOOST_FOREACH (shared_ptr<const Leaf> leaf, state.getLeaves ().get<ordered> ())
{
shared_ptr<const DiffLeaf> diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
if (diffLeaf != 0)
{
os << "<item action=\"" << diffLeaf->getOperation () << "\">"; DEBUG_ENDL;
}
else
{
os << "<item>"; DEBUG_ENDL;
}
os << "<name>" << *leaf->getInfo () << "</name>"; DEBUG_ENDL;
if (diffLeaf == 0 || (diffLeaf != 0 && diffLeaf->getOperation () == UPDATE))
{
os << "<seq>" << leaf->getSeq () << "</seq>"; DEBUG_ENDL;
}
os << "</item>"; DEBUG_ENDL;
}
os << "</state>";
}
*/
SyncStateMsg &
operator << (SyncStateMsg &ossm, const State &state)
{
BOOST_FOREACH (shared_ptr<const Leaf> leaf, state.getLeaves ().get<ordered> ())
{
SyncState *oss = ossm.add_ss();
shared_ptr<const DiffLeaf> diffLeaf = dynamic_pointer_cast<const DiffLeaf> (leaf);
if (diffLeaf != 0 && diffLeaf->getOperation() != UPDATE)
{
oss->set_type(SyncState::DELETE);
}
else
{
oss->set_type(SyncState::UPDATE);
}
std::ostringstream os;
os << *leaf->getInfo();
oss->set_name(os.str());
if (diffLeaf == 0 || (diffLeaf != 0 && diffLeaf->getOperation () == UPDATE))
{
SyncState::SeqNo *seqNo = oss->mutable_seqno();
seqNo->set_session(leaf->getSeq().getSession());
seqNo->set_seq(leaf->getSeq().getSeq());
}
}
return ossm;
}
/*
std::istream &
operator >> (std::istream &in, State &state)
{
TiXmlDocument doc;
in >> doc;
if (doc.RootElement() == 0)
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("Empty XML"));
for (TiXmlElement *iterator = doc.RootElement()->FirstChildElement ("item");
iterator != 0;
iterator = iterator->NextSiblingElement("item"))
{
TiXmlElement *name = iterator->FirstChildElement ("name");
if (name == 0 || name->GetText() == 0)
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("<name> element is missing"));
NameInfoConstPtr info = StdNameInfo::FindOrCreate (name->GetText());
if (iterator->Attribute("action") == 0 || strcmp(iterator->Attribute("action"), "update") == 0)
{
TiXmlElement *seq = iterator->FirstChildElement ("seq");
if (seq == 0)
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("<seq> element is missing"));
TiXmlElement *session = seq->FirstChildElement ("session");
TiXmlElement *seqno = seq->FirstChildElement ("seqno");
if (session == 0 || session->GetText() == 0)
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("<session> element is missing"));
if (seqno == 0 || seqno->GetText() == 0)
BOOST_THROW_EXCEPTION (SyncXmlDecodingFailure () << info_str ("<seqno> element is missing"));
state.update (info, SeqNo (
lexical_cast<uint32_t> (session->GetText()),
lexical_cast<uint32_t> (seqno->GetText())
));
}
else
{
state.remove (info);
}
}
return in;
}
*/
SyncStateMsg &
operator >> (SyncStateMsg &issm, State &state)
{
int n = issm.ss_size();
for (int i = 0; i < n; i++)
{
const SyncState &ss = issm.ss(i);
NameInfoConstPtr info = StdNameInfo::FindOrCreate (ss.name());
if (ss.type() == SyncState::UPDATE)
{
uint64_t session = lexical_cast<uint64_t>(ss.seqno().session());
uint64_t seq = lexical_cast<uint64_t>(ss.seqno().seq());
SeqNo seqNo(session, seq);
state.update(info, seqNo);
}
else
{
state.remove(info);
}
}
return issm;
}
}
-116
View File
@@ -1,116 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_STATE_H
#define SYNC_STATE_H
#include "sync-state-leaf-container.h"
#include <boost/exception/all.hpp>
#include "sync-state.pb.h"
/**
* \defgroup sync SYNC protocol
*
* Implementation of SYNC protocol
*/
namespace Sync {
/**
* \ingroup sync
* @brief this prefix will be used for the dummy node which increases its sequence number whenever
* a remove operation happens; this is to prevent the reversion of root digest when we prune
* a branch, i.e. help the root digest to be forward only
* No corresponding data msg would be published and no attempt would be made to retrieve the
* data msg
*/
const std::string forwarderPrefix = "/d0n0t18ak/t0ps8cr8t";
class State;
typedef shared_ptr<State> StatePtr;
typedef shared_ptr<State> StateConstPtr;
/**
* \ingroup sync
* @brief Container for state leaves and definition of the abstract interface to work with State objects
*/
class State
{
public:
virtual ~State () { };
/**
* @brief Add or update leaf to the state tree
*
* @param info name of the leaf
* @param seq sequence number of the leaf
*/
virtual tuple<bool/*inserted*/, bool/*updated*/, SeqNo/*oldSeqNo*/>
update (NameInfoConstPtr info, const SeqNo &seq) = 0;
/**
* @brief Remove leaf from the state tree
* @param info name of the leaf
*/
virtual bool
remove (NameInfoConstPtr info) = 0;
/**
* @brief Get state leaves
*/
const LeafContainer &
getLeaves () const
{ return m_leaves; }
protected:
LeafContainer m_leaves;
};
/**
* @brief Formats a protobuf SyncStateMsg msg
* @param oss output SyncStateMsg msg
* @param state state
* @returns output SyncStateMsg msg
*/
SyncStateMsg &
operator << (SyncStateMsg &ossm, const State &state);
/**
* @brief Parse a protobuf SyncStateMsg msg
* @param iss input SyncStateMsg msg
* @param state state
* @returns SyncStateMsg msg
*/
SyncStateMsg &
operator >> (SyncStateMsg &issm, State &state);
namespace Error {
/**
* @brief Will be thrown when data cannot be properly decoded to SyncStateMsg
*/
struct SyncStateMsgDecodingFailure : virtual boost::exception, virtual std::exception { };
}
} // Sync
#endif // SYNC_STATE_H
-24
View File
@@ -1,24 +0,0 @@
package Sync;
message SyncState
{
required string name = 1;
enum ActionType
{
UPDATE = 0;
DELETE = 1;
OTHER = 2;
}
required ActionType type = 2;
message SeqNo
{
required uint64 seq = 1;
required uint64 session = 2;
}
optional SeqNo seqno = 3;
}
message SyncStateMsg
{
repeated SyncState ss = 1;
}
-89
View File
@@ -1,89 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#include "sync-std-name-info.h"
namespace Sync {
NameInfoConstPtr
StdNameInfo::FindOrCreate (const std::string &key)
{
// std::cout << "FindOrCreate: " << m_names.size () << "\n";
NameInfoConstPtr ret;
NameMap::iterator item = m_names.find (key);
if (item != m_names.end ())
{
ret = item->second.lock ();
BOOST_ASSERT (ret != 0);
}
else
{
ret = NameInfoPtr (new StdNameInfo (key));
weak_ptr<const NameInfo> value (ret);
std::pair<NameMap::iterator,bool> inserted =
m_names.insert (make_pair (key, value));
BOOST_ASSERT (inserted.second); // previous call has to insert value
item = inserted.first;
}
return ret;
}
StdNameInfo::StdNameInfo (const std::string &name)
: m_name (name)
{
m_id = m_ids ++; // set ID for a newly inserted element
m_digest << name;
m_digest.finalize ();
// std::cout << "StdNameInfo: " << name << " = " << m_id << "\n";
}
StdNameInfo::~StdNameInfo ()
{
// cout << "Destructor for " << m_name << "\n";
m_names.erase (toString ());
}
std::string
StdNameInfo::toString () const
{
return m_name;
}
bool
StdNameInfo::operator == (const NameInfo &info) const
{
return m_name == dynamic_cast<const StdNameInfo&> (info).m_name;
}
bool
StdNameInfo::operator < (const NameInfo &info) const
{
return m_name < dynamic_cast<const StdNameInfo&> (info).m_name;
}
} // Sync
-74
View File
@@ -1,74 +0,0 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 University of California, Los Angeles
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
* Chaoyi Bian <bcy@pku.edu.cn>
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
#ifndef SYNC_STD_NAME_INFO_H
#define SYNC_STD_NAME_INFO_H
#include "sync-name-info.h"
#include <string>
namespace Sync {
class StdNameInfo : public NameInfo
{
public:
/**
* @brief Lookup existing or create new NameInfo object
* @param name routable prefix
*/
static NameInfoConstPtr
FindOrCreate (const std::string &name);
/**
* @brief Destructor which will clean up m_names structure
*/
virtual ~StdNameInfo ();
// from NameInfo
virtual bool
operator == (const NameInfo &info) const;
virtual bool
operator < (const NameInfo &info) const;
virtual std::string
toString () const;
private:
// implementing a singleton pattern.
/**
* @brief Disabled default constructor. NameInfo object should be created through FindOrCreate static call.
*/
/**
* @brief Disabled default
*/
StdNameInfo () {}
StdNameInfo& operator = (const StdNameInfo &info) { (void)info; return *this; }
StdNameInfo (const std::string &name);
std::string m_name;
};
} // Sync
#endif // SYNC_CCNX_NAME_INFO_H
+59 -84
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2016, The University of Memphis,
* Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -29,9 +29,7 @@
namespace nlsr {
INIT_LOGGER("AdjacencyList");
using namespace std;
INIT_LOGGER(AdjacencyList);
AdjacencyList::AdjacencyList()
{
@@ -61,20 +59,6 @@ AdjacencyList::addAdjacents(AdjacencyList& adl)
}
}
bool
AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s)
{
std::list<Adjacent>::iterator it = find(adjName);
if (it == m_adjList.end()) {
return false;
}
else {
it->setStatus(s);
return true;
}
}
Adjacent
AdjacencyList::getAdjacent(const ndn::Name& adjName)
{
@@ -86,49 +70,24 @@ AdjacencyList::getAdjacent(const ndn::Name& adjName)
return adj;
}
static bool
compareAdjacent(const Adjacent& adjacent1, const Adjacent& adjacent2)
{
return adjacent1.getName() < adjacent2.getName();
}
bool
AdjacencyList::operator==(AdjacencyList& adl)
AdjacencyList::operator==(const AdjacencyList& adl) const
{
if (getSize() != adl.getSize()) {
auto theirList = adl.getAdjList();
if (m_adjList.size() != theirList.size()) {
return false;
}
m_adjList.sort(compareAdjacent);
adl.getAdjList().sort(compareAdjacent);
uint32_t equalAdjCount = 0;
std::list<Adjacent>& adjList2 = adl.getAdjList();
std::list<Adjacent>::iterator it1;
std::list<Adjacent>::iterator it2;
for (it1 = m_adjList.begin(), it2 = adjList2.begin();
it1 != m_adjList.end(); it1++, it2++) {
if (!((*it1) == (*it2))) {
break;
}
equalAdjCount++;
}
return equalAdjCount == getSize();
}
int32_t
AdjacencyList::updateAdjacentLinkCost(const ndn::Name& adjName, double lc)
{
std::list<Adjacent>::iterator it = find(adjName);
if (it == m_adjList.end()) {
return -1;
}
(*it).setLinkCost(lc);
return 0;
std::set<Adjacent> ourSet(m_adjList.cbegin(), m_adjList.cend());
std::set<Adjacent> theirSet(theirList.cbegin(), theirList.cend());
return ourSet == theirSet;
}
bool
AdjacencyList::isNeighbor(const ndn::Name& adjName)
AdjacencyList::isNeighbor(const ndn::Name& adjName) const
{
std::list<Adjacent>::iterator it = find(adjName);
std::list<Adjacent>::const_iterator it = find(adjName);
if (it == m_adjList.end())
{
return false;
@@ -157,9 +116,9 @@ AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor,
}
int32_t
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor) const
{
std::list<Adjacent>::iterator it = find(neighbor);
std::list<Adjacent>::const_iterator it = find(neighbor);
if (it == m_adjList.end()) {
return -1;
}
@@ -167,9 +126,9 @@ AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
}
Adjacent::Status
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor)
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
{
std::list<Adjacent>::iterator it = find(neighbor);
std::list<Adjacent>::const_iterator it = find(neighbor);
if (it == m_adjList.end()) {
return Adjacent::STATUS_UNKNOWN;
@@ -194,6 +153,12 @@ AdjacencyList::getAdjList()
return m_adjList;
}
const std::list<Adjacent>&
AdjacencyList::getAdjList() const
{
return m_adjList;
}
bool
AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
{
@@ -218,10 +183,10 @@ AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
}
int32_t
AdjacencyList::getNumOfActiveNeighbor()
AdjacencyList::getNumOfActiveNeighbor() const
{
int32_t actNbrCount = 0;
for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
for (std::list<Adjacent>::const_iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
actNbrCount++;
@@ -235,45 +200,55 @@ AdjacencyList::find(const ndn::Name& adjName)
{
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
m_adjList.end(),
ndn::bind(&Adjacent::compare,
_1, ndn::cref(adjName)));
std::bind(&Adjacent::compare,
_1, std::cref(adjName)));
return it;
}
Adjacent *
AdjacencyList::findAdjacent(const ndn::Name& adjName)
std::list<Adjacent>::const_iterator
AdjacencyList::find(const ndn::Name& adjName) const
{
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
m_adjList.end(),
ndn::bind(&Adjacent::compare,
_1, ndn::cref(adjName)));
if (it != m_adjList.end()) {
return &(*it);
}
return 0;
std::list<Adjacent>::const_iterator it = std::find_if(m_adjList.cbegin(),
m_adjList.cend(),
std::bind(&Adjacent::compare,
_1, std::cref(adjName)));
return it;
}
Adjacent *
AdjacencyList::iterator
AdjacencyList::findAdjacent(const ndn::Name& adjName)
{
return std::find_if(m_adjList.begin(),
m_adjList.end(),
std::bind(&Adjacent::compare,
_1, std::cref(adjName)));
}
AdjacencyList::iterator
AdjacencyList::findAdjacent(uint64_t faceId)
{
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
m_adjList.end(),
ndn::bind(&Adjacent::compareFaceId,
_1, faceId));
if (it != m_adjList.end()) {
return &(*it);
}
return std::find_if(m_adjList.begin(),
m_adjList.end(),
std::bind(&Adjacent::compareFaceId,
_1, faceId));
}
return 0;
AdjacencyList::iterator
AdjacencyList::findAdjacent(const ndn::FaceUri& faceUri)
{
return std::find_if(m_adjList.begin(),
m_adjList.end(),
std::bind(&Adjacent::compareFaceUri,
_1, faceUri));
}
uint64_t
AdjacencyList::getFaceId(const std::string& faceUri)
AdjacencyList::getFaceId(const ndn::FaceUri& faceUri)
{
std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
m_adjList.end(),
ndn::bind(&Adjacent::compareFaceUri,
std::bind(&Adjacent::compareFaceUri,
_1, faceUri));
if (it != m_adjList.end()) {
return it->getFaceId();
@@ -285,11 +260,11 @@ AdjacencyList::getFaceId(const std::string& faceUri)
void
AdjacencyList::writeLog()
{
_LOG_DEBUG("-------Adjacency List--------");
NLSR_LOG_DEBUG("-------Adjacency List--------");
for (std::list<Adjacent>::iterator it = m_adjList.begin();
it != m_adjList.end(); it++) {
(*it).writeLog();
}
}
} //namespace nlsr
} // namespace nlsr
Loaded 100 of 286 files, more files were not shown because too many files have changed in this diff. Show more