blob: b180ca03dc2430e950bd31aa881d8405a47533b2 [file] [log] [blame]
Yingdi Yuf7ede412014-08-30 20:37:52 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Davide Pesavento5f5101a2022-03-11 20:05:03 -05003 * Copyright (c) 2012-2022 University of California, Los Angeles
Yingdi Yuf7ede412014-08-30 20:37:52 -07004 *
5 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
7 *
8 * ChronoSync is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation, either
10 * version 3 of the License, or (at your option) any later version.
11 *
12 * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author Zhenkai Zhu <http://irl.cs.ucla.edu/~zhenkai/>
20 * @author Chaoyi Bian <bcy@pku.edu.cn>
21 * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
22 * @author Yingdi Yu <yingdi@cs.ucla.edu>
Sonu Mishra4d3a2e02017-01-18 20:27:51 -080023 * @author Sonu Mishra <https://www.linkedin.com/in/mishrasonu>
Yingdi Yuf7ede412014-08-30 20:37:52 -070024 */
25
26#ifndef CHRONOSYNC_LOGIC_HPP
27#define CHRONOSYNC_LOGIC_HPP
28
Ashlesh Gawande687cf922017-05-30 15:04:16 -050029#include "diff-state-container.hpp"
30#include "interest-table.hpp"
31
Ashlesh Gawande9a306fe2019-01-04 11:38:18 -060032#include <ndn-cxx/util/random.hpp>
33
Qiuhan Ding8c095fd2014-11-19 17:38:32 -080034#include <unordered_map>
Yingdi Yuf7ede412014-08-30 20:37:52 -070035
Yingdi Yuf7ede412014-08-30 20:37:52 -070036namespace chronosync {
37
38/**
39 * @brief The missing sequence numbers for a session
40 *
41 * This class is used to notify the clients of Logic
42 * the details of state changes.
43 *
44 * Instances of this class is usually used as elements of some containers
45 * such as std::vector, thus it is copyable.
46 */
Sonu Mishra4d3a2e02017-01-18 20:27:51 -080047class NodeInfo
48{
Qiuhan Ding8c095fd2014-11-19 17:38:32 -080049public:
50 Name userPrefix;
51 Name signingId;
52 Name sessionName;
53 SeqNo seqNo;
54};
55
Yingdi Yuf7ede412014-08-30 20:37:52 -070056class MissingDataInfo
57{
58public:
59 /// @brief session name
60 Name session;
61 /// @brief the lowest one of missing sequence numbers
62 SeqNo low;
63 /// @brief the highest one of missing sequence numbers
64 SeqNo high;
65};
66
67/**
68 * @brief The callback function to handle state updates
69 *
70 * The parameter is a set of MissingDataInfo, of which each corresponds to
71 * a session that has changed its state.
72 */
Davide Pesavento8663ed12022-07-23 03:04:27 -040073using UpdateCallback = std::function<void(const std::vector<MissingDataInfo>&)>;
Yingdi Yuf7ede412014-08-30 20:37:52 -070074
75/**
76 * @brief Logic of ChronoSync
77 */
78class Logic : noncopyable
79{
80public:
Qiuhan Ding8c095fd2014-11-19 17:38:32 -080081 class Error : public std::runtime_error
82 {
83 public:
Davide Pesavento07684bc2021-02-07 20:09:28 -050084 using std::runtime_error::runtime_error;
Qiuhan Ding8c095fd2014-11-19 17:38:32 -080085 };
86
Davide Pesavento8663ed12022-07-23 03:04:27 -040087 static inline const Name EMPTY_NAME;
88 static inline const Name DEFAULT_NAME;
89 static inline const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
90 static constexpr time::steady_clock::duration DEFAULT_RESET_TIMER = 0_ms;
91 static constexpr time::steady_clock::duration DEFAULT_CANCEL_RESET_TIMER = 500_ms;
92 static constexpr time::milliseconds DEFAULT_RESET_INTEREST_LIFETIME = 1_s;
93 static constexpr time::milliseconds DEFAULT_SYNC_INTEREST_LIFETIME = 1_s;
94 static constexpr time::milliseconds DEFAULT_SYNC_REPLY_FRESHNESS = 1_s;
95 static constexpr time::milliseconds DEFAULT_RECOVERY_INTEREST_LIFETIME = 1_s;
Yingdi Yuf7ede412014-08-30 20:37:52 -070096
97 /**
98 * @brief Constructor
99 *
Yingdi Yu9d5679a2015-02-01 00:17:58 -0800100 * @param face The face used to communication, will be shutdown in destructor
Yingdi Yuf7ede412014-08-30 20:37:52 -0700101 * @param syncPrefix The prefix of the sync group
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800102 * @param defaultUserPrefix The prefix of the first user added to this session
Yingdi Yuf7ede412014-08-30 20:37:52 -0700103 * @param onUpdate The callback function to handle state updates
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800104 * @param defaultSigningId The signing Id of the default user
Yingdi Yucd339022014-11-05 17:51:19 -0800105 * @param validator The validator for packet validation
Yingdi Yuf7ede412014-08-30 20:37:52 -0700106 * @param resetTimer The timer to periodically send Reset Interest
Yingdi Yuf7ede412014-08-30 20:37:52 -0700107 * @param cancelResetTimer The timer to exit from Reset state
Ashlesh Gawande097bb442017-05-31 13:38:00 -0500108 * @param resetInterestLifetime The lifetime of Reset Interest
109 * @param syncInterestLifetime The lifetime of sync interest
110 * @param syncReplyFreshness The FreshnessPeriod of sync reply
111 * @param recoveryInterestLifetime The lifetime of recovery interest
Alexander Afanasyevbf5bc6c2018-02-19 11:26:09 -0500112 * @param session Manually defined session ID
Yingdi Yuf7ede412014-08-30 20:37:52 -0700113 */
114 Logic(ndn::Face& face,
115 const Name& syncPrefix,
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800116 const Name& defaultUserPrefix,
Yingdi Yuf7ede412014-08-30 20:37:52 -0700117 const UpdateCallback& onUpdate,
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800118 const Name& defaultSigningId = DEFAULT_NAME,
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500119 std::shared_ptr<Validator> validator = DEFAULT_VALIDATOR,
Davide Pesavento8663ed12022-07-23 03:04:27 -0400120 const time::steady_clock::duration& resetTimer = DEFAULT_RESET_TIMER,
121 const time::steady_clock::duration& cancelResetTimer = DEFAULT_CANCEL_RESET_TIMER,
Yingdi Yuf7ede412014-08-30 20:37:52 -0700122 const time::milliseconds& resetInterestLifetime = DEFAULT_RESET_INTEREST_LIFETIME,
123 const time::milliseconds& syncInterestLifetime = DEFAULT_SYNC_INTEREST_LIFETIME,
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800124 const time::milliseconds& syncReplyFreshness = DEFAULT_SYNC_REPLY_FRESHNESS,
Alexander Afanasyevbf5bc6c2018-02-19 11:26:09 -0500125 const time::milliseconds& recoveryInterestLifetime = DEFAULT_RECOVERY_INTEREST_LIFETIME,
Ashlesh Gawandedb862e02018-03-30 17:15:08 -0500126 const name::Component& session = name::Component());
Yingdi Yuf7ede412014-08-30 20:37:52 -0700127
128 ~Logic();
129
Qiuhan Dingfb8c9e02015-01-30 14:04:55 -0800130 /**
131 * @brief Reset the sync tree (and restart synchronization again)
132 *
133 * @param isOnInterest a flag that tells whether the reset is called by reset interest.
134 */
Yingdi Yuf7ede412014-08-30 20:37:52 -0700135 void
Qiuhan Dingfb8c9e02015-01-30 14:04:55 -0800136 reset(bool isOnInterest = false);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700137
138 /**
139 * @brief Set user prefix
140 *
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800141 * This method will also change the default user and signing Id of that user.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700142 *
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800143 * @param defaultUserPrefix The prefix of user.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700144 */
145 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800146 setDefaultUserPrefix(const Name& defaultUserPrefix);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700147
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800148 /// @brief Get the name of default user.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700149 const Name&
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800150 getDefaultUserPrefix() const
Yingdi Yuf7ede412014-08-30 20:37:52 -0700151 {
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800152 return m_defaultUserPrefix;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700153 }
154
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800155 /**
156 * @brief Add user node into the local session.
157 *
158 * This method also reset after adding
159 *
160 * @param userPrefix prefix of the added node
161 * @param signingId signing Id of the added node
Alexander Afanasyevbf5bc6c2018-02-19 11:26:09 -0500162 * @param session manually defined session ID
Davide Pesaventod7de2d42019-08-01 20:55:50 -0400163 * @param shouldSendReset enable/disable sending the reset interest
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800164 */
165 void
Ashlesh Gawandedb862e02018-03-30 17:15:08 -0500166 addUserNode(const Name& userPrefix, const Name& signingId = DEFAULT_NAME,
Davide Pesaventod7de2d42019-08-01 20:55:50 -0400167 const name::Component& session = name::Component(), bool shouldSendReset = true);
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800168
169 /// @brief remove the node from the local session
170 void
171 removeUserNode(const Name& userPrefix);
172
173 /**
174 * @brief Get the name of the local session.
175 *
176 * This method gets the session name according to prefix, if prefix is not specified,
177 * it returns the session name of default user.
178 *
179 * @param prefix prefix of the node
180 */
181 const Name&
182 getSessionName(Name prefix = EMPTY_NAME);
183
184 /**
185 * @brief Get current seqNo of the local session.
186 *
187 * This method gets the seqNo according to prefix, if prefix is not specified,
188 * it returns the seqNo of default user.
189 *
190 * @param prefix prefix of the node
191 */
Yingdi Yuf7ede412014-08-30 20:37:52 -0700192 const SeqNo&
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800193 getSeqNo(Name prefix = EMPTY_NAME);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700194
195 /**
196 * @brief Update the seqNo of the local session
197 *
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800198 * The method updates the existing seqNo with the supplied seqNo and prefix.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700199 *
200 * @param seq The new seqNo.
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800201 * @param updatePrefix The prefix of node to update.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700202 */
203 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800204 updateSeqNo(const SeqNo& seq, const Name& updatePrefix = EMPTY_NAME);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700205
206 /// @brief Get root digest of current sync tree
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500207 ConstBufferPtr
Yingdi Yuf7ede412014-08-30 20:37:52 -0700208 getRootDigest() const;
209
210 /// @brief Get the name of all sessions
211 std::set<Name>
212 getSessionNames() const;
213
Yingdi Yu906c2ea2014-10-31 11:24:50 -0700214CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Yingdi Yuf7ede412014-08-30 20:37:52 -0700215 void
216 printState(std::ostream& os) const;
217
218 ndn::Scheduler&
219 getScheduler()
220 {
221 return m_scheduler;
222 }
223
224 State&
225 getState()
226 {
227 return m_state;
228 }
229
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -0500230 /// Create a subset @p partialState excluding @p nExcludedStates from @p state
Ashlesh Gawande4a9ecd52018-02-06 14:36:19 -0600231 void
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -0500232 trimState(State& partialState, const State& state, size_t excludedStates);
233
234 Data
235 encodeSyncReply(const Name& nodePrefix, const Name& name, const State& state);
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800236
Yingdi Yuf7ede412014-08-30 20:37:52 -0700237private:
238 /**
239 * @brief Callback to handle Sync Interest
240 *
241 * This method checks whether an incoming interest is a normal one or a reset
242 * and dispatches the incoming interest to corresponding processing methods.
243 *
244 * @param prefix The prefix of the sync group.
245 * @param interest The incoming sync interest.
246 */
247 void
248 onSyncInterest(const Name& prefix, const Interest& interest);
249
250 /**
251 * @brief Callback to handle Sync prefix registration failure
252 *
253 * This method does nothing for now.
254 *
255 * @param prefix The prefix of the sync group.
256 * @param msg The error message.
257 */
258 void
259 onSyncRegisterFailed(const Name& prefix, const std::string& msg);
260
261 /**
262 * @brief Callback to handle Sync Reply
263 *
264 * This method calls validator to validate Sync Reply.
265 * For now, validation is disabled, Logic::onSyncDataValidated is called
266 * directly.
267 *
268 * @param interest The Sync Interest
269 * @param data The reply to the Sync Interest
270 */
271 void
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800272 onSyncData(const Interest& interest, const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700273
274 /**
275 * @brief Callback to handle reply to Reset Interest.
276 *
277 * This method does nothing, since reply to Reset Interest is not useful for now.
278 *
279 * @param interest The Reset Interest
280 * @param data The reply to the Reset Interest
281 */
282 void
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800283 onResetData(const Interest& interest, const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700284
285 /**
Ashlesh Gawandea1ad6042019-10-07 15:56:11 -0500286 * @brief Callback to handle Sync Interest Nack
287 *
288 * This method checks whether the Nack is of type NoRoute
289 * and schedules a sync interest in m_reexpressionJitter
290 *
291 * @param interest The sync interest for which the Nack happened
292 * @param nack The incoming Nack
293 */
294 void
295 onSyncNack(const Interest& interest, const ndn::lp::Nack& nack);
296
297 /**
Yingdi Yuf7ede412014-08-30 20:37:52 -0700298 * @brief Callback to handle Sync Interest timeout.
299 *
300 * This method does nothing, since Logic per se handles timeout explicitly.
301 *
302 * @param interest The Sync Interest
303 */
304 void
305 onSyncTimeout(const Interest& interest);
306
307 /**
308 * @brief Callback to invalid Sync Reply.
309 *
310 * This method does nothing but drops the invalid reply.
311 *
312 * @param data The invalid Sync Reply
313 */
314 void
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500315 onSyncDataValidationFailed(const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700316
317 /**
318 * @brief Callback to valid Sync Reply.
319 *
320 * This method simply passes the valid reply to processSyncData.
321 *
322 * @param data The valid Sync Reply.
323 */
324 void
Ashlesh Gawande1d1092d2018-08-03 14:36:49 -0500325 onSyncDataValidated(const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700326
327 /**
328 * @brief Process normal Sync Interest
329 *
330 * This method extracts the digest from the incoming Sync Interest,
331 * compares it against current local digest, and process the Sync
332 * Interest according to the comparison result. See docs/design.rst
333 * for more details.
334 *
335 * @param interest The incoming interest
336 * @param isTimedProcessing True if the interest needs an immediate reply,
337 * otherwise hold the interest for a while before
338 * making a reply (to avoid unnecessary recovery)
339 */
340 void
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500341 processSyncInterest(const Interest& interest, bool isTimedProcessing = false);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700342
343 /**
344 * @brief Process reset Sync Interest
345 *
346 * This method simply call Logic::reset()
347 *
348 * @param interest The incoming interest.
349 */
350 void
351 processResetInterest(const Interest& interest);
352
353 /**
354 * @brief Process Sync Reply.
355 *
356 * This method extracts state update information from Sync Reply and applies
357 * it to the Sync Tree and re-express Sync Interest.
358 *
Davide Pesavento27416442020-01-23 23:10:24 -0500359 * @param name The data name of the Sync Reply.
360 * @param digest The digest in the data name.
361 * @param syncReply The content of the Sync Reply.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700362 */
363 void
Davide Pesavento27416442020-01-23 23:10:24 -0500364 processSyncData(const Name& name, ConstBufferPtr digest, const Block& syncReply);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700365
366 /**
367 * @brief Insert state diff into log
368 *
Davide Pesavento27416442020-01-23 23:10:24 -0500369 * @param diff The diff.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700370 * @param previousRoot The root digest before state changes.
371 */
372 void
Davide Pesavento27416442020-01-23 23:10:24 -0500373 insertToDiffLog(DiffStatePtr diff, ConstBufferPtr previousRoot);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700374
375 /**
376 * @brief Reply to all pending Sync Interests with a particular commit (or diff)
377 *
378 * @param commit The diff.
379 */
380 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800381 satisfyPendingSyncInterests(const Name& updatedPrefix, ConstDiffStatePtr commit);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700382
383 /// @brief Helper method to send normal Sync Interest
384 void
385 sendSyncInterest();
386
387 /// @brief Helper method to send reset Sync Interest
388 void
389 sendResetInterest();
390
391 /// @brief Helper method to send Sync Reply
392 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800393 sendSyncData(const Name& nodePrefix, const Name& name, const State& state);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700394
395 /**
396 * @brief Unset reset status
397 *
398 * By invoking this method, one can add its own state into the Sync Tree, thus
399 * jumping out of the reset status
400 */
401 void
402 cancelReset();
403
404 void
Davide Pesavento5f5101a2022-03-11 20:05:03 -0500405 printDigest(const ConstBufferPtr& digest) const;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700406
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800407 /**
408 * @brief Helper method to send Recovery Interest
409 *
410 * @param digest The digest to be included in the recovery interest
411 */
412 void
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500413 sendRecoveryInterest(ConstBufferPtr digest);
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800414
415 /**
416 * @brief Process Recovery Interest
417 *
418 * This method extracts the digest from the incoming Recovery Interest.
419 * If it recognizes this incoming digest, then it sends its full state
420 * as reply.
421 *
422 * @param interest The incoming interest
423 */
424 void
425 processRecoveryInterest(const Interest& interest);
426
427 /**
428 * @brief Callback to handle Recovery Reply
429 *
430 * This method calls Logic::onSyncDataValidated directly.
431 *
432 * @param interest The Recovery Interest
433 * @param data The reply to the Recovery Interest
434 */
435 void
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800436 onRecoveryData(const Interest& interest, const Data& data);
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800437
438 /**
439 * @brief Callback to handle Recovery Interest timeout.
440 *
441 * This method does nothing.
442 *
443 * @param interest The Recovery Interest
444 */
445 void
446 onRecoveryTimeout(const Interest& interest);
447
Yingdi Yuf7ede412014-08-30 20:37:52 -0700448private:
Davide Pesavento8663ed12022-07-23 03:04:27 -0400449 using NodeList = std::unordered_map<Name, NodeInfo>;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700450
451 // Communication
452 ndn::Face& m_face;
453 Name m_syncPrefix;
Junxiao Shi8e4e76d2019-02-08 15:25:08 -0700454 ndn::ScopedRegisteredPrefixHandle m_syncRegisteredPrefix;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700455 Name m_syncReset;
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800456 Name m_defaultUserPrefix;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700457
458 // State
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800459 NodeList m_nodeList;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700460 State m_state;
461 DiffStateContainer m_log;
462 InterestTable m_interestTable;
Junxiao Shi8e4e76d2019-02-08 15:25:08 -0700463 Name m_pendingSyncInterestName;
464 ndn::ScopedPendingInterestHandle m_pendingSyncInterest;
465 ndn::ScopedPendingInterestHandle m_pendingResetInterest;
466 std::map<std::string, ndn::ScopedPendingInterestHandle> m_pendingRecoveryInterests;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700467 bool m_isInReset;
468 bool m_needPeriodReset;
469
470 // Callback
471 UpdateCallback m_onUpdate;
472
473 // Event
Davide Pesavento0d837e32019-03-16 22:31:14 -0400474 ndn::Scheduler m_scheduler;
475 ndn::scheduler::ScopedEventId m_delayedInterestProcessingId;
476 ndn::scheduler::ScopedEventId m_reexpressingInterestId;
477 ndn::scheduler::ScopedEventId m_resetInterestId;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700478
479 // Timer
Ashlesh Gawande9a306fe2019-01-04 11:38:18 -0600480 ndn::random::RandomNumberEngine& m_rng;
Ashlesh Gawande4a9ecd52018-02-06 14:36:19 -0600481 std::uniform_int_distribution<> m_rangeUniformRandom;
482 std::uniform_int_distribution<> m_reexpressionJitter;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700483 /// @brief Timer to send next reset 0 for no reset
Davide Pesavento8663ed12022-07-23 03:04:27 -0400484 time::steady_clock::duration m_resetTimer;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700485 /// @brief Timer to cancel reset state
Davide Pesavento8663ed12022-07-23 03:04:27 -0400486 time::steady_clock::duration m_cancelResetTimer;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700487 /// @brief Lifetime of reset interest
488 time::milliseconds m_resetInterestLifetime;
489 /// @brief Lifetime of sync interest
490 time::milliseconds m_syncInterestLifetime;
491 /// @brief FreshnessPeriod of SyncReply
492 time::milliseconds m_syncReplyFreshness;
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800493 /// @brief Lifetime of recovery interest
494 time::milliseconds m_recoveryInterestLifetime;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700495
Yingdi Yucd339022014-11-05 17:51:19 -0800496 // Security
Yingdi Yuf7ede412014-08-30 20:37:52 -0700497 ndn::KeyChain m_keyChain;
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500498 std::shared_ptr<Validator> m_validator;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700499
Davide Pesavento8663ed12022-07-23 03:04:27 -0400500 const int m_instanceId;
501 static inline int s_instanceCounter = 0;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700502};
503
Davide Pesavento07684bc2021-02-07 20:09:28 -0500504#ifdef CHRONOSYNC_WITH_TESTS
Alexander Afanasyev89036292018-02-13 17:19:50 -0500505size_t
506getMaxPacketLimit();
Davide Pesavento07684bc2021-02-07 20:09:28 -0500507#endif // CHRONOSYNC_WITH_TESTS
Yingdi Yuf7ede412014-08-30 20:37:52 -0700508
509} // namespace chronosync
510
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800511#endif // CHRONOSYNC_LOGIC_HPP