blob: e016a9eec308b793f80606f94d05ba086827ae32 [file] [log] [blame]
Yingdi Yuf7ede412014-08-30 20:37:52 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
Davide Pesavento27416442020-01-23 23:10:24 -05003 * Copyright (c) 2012-2020 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 */
Ashlesh Gawande08784d42017-09-06 23:40:21 -050073using UpdateCallback = 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:
84 explicit
85 Error(const std::string& what)
86 : std::runtime_error(what)
87 {
88 }
89 };
90
91public:
Yingdi Yuf7ede412014-08-30 20:37:52 -070092 static const time::steady_clock::Duration DEFAULT_RESET_TIMER;
93 static const time::steady_clock::Duration DEFAULT_CANCEL_RESET_TIMER;
94 static const time::milliseconds DEFAULT_RESET_INTEREST_LIFETIME;
95 static const time::milliseconds DEFAULT_SYNC_INTEREST_LIFETIME;
96 static const time::milliseconds DEFAULT_SYNC_REPLY_FRESHNESS;
Sonu Mishra4d3a2e02017-01-18 20:27:51 -080097 static const time::milliseconds DEFAULT_RECOVERY_INTEREST_LIFETIME;
Yingdi Yuf7ede412014-08-30 20:37:52 -070098
99 /**
100 * @brief Constructor
101 *
Yingdi Yu9d5679a2015-02-01 00:17:58 -0800102 * @param face The face used to communication, will be shutdown in destructor
Yingdi Yuf7ede412014-08-30 20:37:52 -0700103 * @param syncPrefix The prefix of the sync group
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800104 * @param defaultUserPrefix The prefix of the first user added to this session
Yingdi Yuf7ede412014-08-30 20:37:52 -0700105 * @param onUpdate The callback function to handle state updates
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800106 * @param defaultSigningId The signing Id of the default user
Yingdi Yucd339022014-11-05 17:51:19 -0800107 * @param validator The validator for packet validation
Yingdi Yuf7ede412014-08-30 20:37:52 -0700108 * @param resetTimer The timer to periodically send Reset Interest
Yingdi Yuf7ede412014-08-30 20:37:52 -0700109 * @param cancelResetTimer The timer to exit from Reset state
Ashlesh Gawande097bb442017-05-31 13:38:00 -0500110 * @param resetInterestLifetime The lifetime of Reset Interest
111 * @param syncInterestLifetime The lifetime of sync interest
112 * @param syncReplyFreshness The FreshnessPeriod of sync reply
113 * @param recoveryInterestLifetime The lifetime of recovery interest
Alexander Afanasyevbf5bc6c2018-02-19 11:26:09 -0500114 * @param session Manually defined session ID
Yingdi Yuf7ede412014-08-30 20:37:52 -0700115 */
116 Logic(ndn::Face& face,
117 const Name& syncPrefix,
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800118 const Name& defaultUserPrefix,
Yingdi Yuf7ede412014-08-30 20:37:52 -0700119 const UpdateCallback& onUpdate,
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800120 const Name& defaultSigningId = DEFAULT_NAME,
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500121 std::shared_ptr<Validator> validator = DEFAULT_VALIDATOR,
Yingdi Yuf7ede412014-08-30 20:37:52 -0700122 const time::steady_clock::Duration& resetTimer = DEFAULT_RESET_TIMER,
123 const time::steady_clock::Duration& cancelResetTimer = DEFAULT_CANCEL_RESET_TIMER,
124 const time::milliseconds& resetInterestLifetime = DEFAULT_RESET_INTEREST_LIFETIME,
125 const time::milliseconds& syncInterestLifetime = DEFAULT_SYNC_INTEREST_LIFETIME,
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800126 const time::milliseconds& syncReplyFreshness = DEFAULT_SYNC_REPLY_FRESHNESS,
Alexander Afanasyevbf5bc6c2018-02-19 11:26:09 -0500127 const time::milliseconds& recoveryInterestLifetime = DEFAULT_RECOVERY_INTEREST_LIFETIME,
Ashlesh Gawandedb862e02018-03-30 17:15:08 -0500128 const name::Component& session = name::Component());
Yingdi Yuf7ede412014-08-30 20:37:52 -0700129
130 ~Logic();
131
Qiuhan Dingfb8c9e02015-01-30 14:04:55 -0800132 /**
133 * @brief Reset the sync tree (and restart synchronization again)
134 *
135 * @param isOnInterest a flag that tells whether the reset is called by reset interest.
136 */
Yingdi Yuf7ede412014-08-30 20:37:52 -0700137 void
Qiuhan Dingfb8c9e02015-01-30 14:04:55 -0800138 reset(bool isOnInterest = false);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700139
140 /**
141 * @brief Set user prefix
142 *
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800143 * This method will also change the default user and signing Id of that user.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700144 *
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800145 * @param defaultUserPrefix The prefix of user.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700146 */
147 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800148 setDefaultUserPrefix(const Name& defaultUserPrefix);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700149
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800150 /// @brief Get the name of default user.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700151 const Name&
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800152 getDefaultUserPrefix() const
Yingdi Yuf7ede412014-08-30 20:37:52 -0700153 {
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800154 return m_defaultUserPrefix;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700155 }
156
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800157 /**
158 * @brief Add user node into the local session.
159 *
160 * This method also reset after adding
161 *
162 * @param userPrefix prefix of the added node
163 * @param signingId signing Id of the added node
Alexander Afanasyevbf5bc6c2018-02-19 11:26:09 -0500164 * @param session manually defined session ID
Davide Pesaventod7de2d42019-08-01 20:55:50 -0400165 * @param shouldSendReset enable/disable sending the reset interest
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800166 */
167 void
Ashlesh Gawandedb862e02018-03-30 17:15:08 -0500168 addUserNode(const Name& userPrefix, const Name& signingId = DEFAULT_NAME,
Davide Pesaventod7de2d42019-08-01 20:55:50 -0400169 const name::Component& session = name::Component(), bool shouldSendReset = true);
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800170
171 /// @brief remove the node from the local session
172 void
173 removeUserNode(const Name& userPrefix);
174
175 /**
176 * @brief Get the name of the local session.
177 *
178 * This method gets the session name according to prefix, if prefix is not specified,
179 * it returns the session name of default user.
180 *
181 * @param prefix prefix of the node
182 */
183 const Name&
184 getSessionName(Name prefix = EMPTY_NAME);
185
186 /**
187 * @brief Get current seqNo of the local session.
188 *
189 * This method gets the seqNo according to prefix, if prefix is not specified,
190 * it returns the seqNo of default user.
191 *
192 * @param prefix prefix of the node
193 */
Yingdi Yuf7ede412014-08-30 20:37:52 -0700194 const SeqNo&
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800195 getSeqNo(Name prefix = EMPTY_NAME);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700196
197 /**
198 * @brief Update the seqNo of the local session
199 *
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800200 * The method updates the existing seqNo with the supplied seqNo and prefix.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700201 *
202 * @param seq The new seqNo.
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800203 * @param updatePrefix The prefix of node to update.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700204 */
205 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800206 updateSeqNo(const SeqNo& seq, const Name& updatePrefix = EMPTY_NAME);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700207
208 /// @brief Get root digest of current sync tree
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500209 ConstBufferPtr
Yingdi Yuf7ede412014-08-30 20:37:52 -0700210 getRootDigest() const;
211
212 /// @brief Get the name of all sessions
213 std::set<Name>
214 getSessionNames() const;
215
Yingdi Yu906c2ea2014-10-31 11:24:50 -0700216CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Yingdi Yuf7ede412014-08-30 20:37:52 -0700217 void
218 printState(std::ostream& os) const;
219
220 ndn::Scheduler&
221 getScheduler()
222 {
223 return m_scheduler;
224 }
225
226 State&
227 getState()
228 {
229 return m_state;
230 }
231
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -0500232 /// Create a subset @p partialState excluding @p nExcludedStates from @p state
Ashlesh Gawande4a9ecd52018-02-06 14:36:19 -0600233 void
Alexander Afanasyev6ee98ff2018-02-13 19:12:28 -0500234 trimState(State& partialState, const State& state, size_t excludedStates);
235
236 Data
237 encodeSyncReply(const Name& nodePrefix, const Name& name, const State& state);
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800238
Yingdi Yuf7ede412014-08-30 20:37:52 -0700239private:
240 /**
241 * @brief Callback to handle Sync Interest
242 *
243 * This method checks whether an incoming interest is a normal one or a reset
244 * and dispatches the incoming interest to corresponding processing methods.
245 *
246 * @param prefix The prefix of the sync group.
247 * @param interest The incoming sync interest.
248 */
249 void
250 onSyncInterest(const Name& prefix, const Interest& interest);
251
252 /**
253 * @brief Callback to handle Sync prefix registration failure
254 *
255 * This method does nothing for now.
256 *
257 * @param prefix The prefix of the sync group.
258 * @param msg The error message.
259 */
260 void
261 onSyncRegisterFailed(const Name& prefix, const std::string& msg);
262
263 /**
264 * @brief Callback to handle Sync Reply
265 *
266 * This method calls validator to validate Sync Reply.
267 * For now, validation is disabled, Logic::onSyncDataValidated is called
268 * directly.
269 *
270 * @param interest The Sync Interest
271 * @param data The reply to the Sync Interest
272 */
273 void
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800274 onSyncData(const Interest& interest, const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700275
276 /**
277 * @brief Callback to handle reply to Reset Interest.
278 *
279 * This method does nothing, since reply to Reset Interest is not useful for now.
280 *
281 * @param interest The Reset Interest
282 * @param data The reply to the Reset Interest
283 */
284 void
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800285 onResetData(const Interest& interest, const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700286
287 /**
Ashlesh Gawandea1ad6042019-10-07 15:56:11 -0500288 * @brief Callback to handle Sync Interest Nack
289 *
290 * This method checks whether the Nack is of type NoRoute
291 * and schedules a sync interest in m_reexpressionJitter
292 *
293 * @param interest The sync interest for which the Nack happened
294 * @param nack The incoming Nack
295 */
296 void
297 onSyncNack(const Interest& interest, const ndn::lp::Nack& nack);
298
299 /**
Yingdi Yuf7ede412014-08-30 20:37:52 -0700300 * @brief Callback to handle Sync Interest timeout.
301 *
302 * This method does nothing, since Logic per se handles timeout explicitly.
303 *
304 * @param interest The Sync Interest
305 */
306 void
307 onSyncTimeout(const Interest& interest);
308
309 /**
310 * @brief Callback to invalid Sync Reply.
311 *
312 * This method does nothing but drops the invalid reply.
313 *
314 * @param data The invalid Sync Reply
315 */
316 void
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500317 onSyncDataValidationFailed(const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700318
319 /**
320 * @brief Callback to valid Sync Reply.
321 *
322 * This method simply passes the valid reply to processSyncData.
323 *
324 * @param data The valid Sync Reply.
325 */
326 void
Ashlesh Gawande1d1092d2018-08-03 14:36:49 -0500327 onSyncDataValidated(const Data& data);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700328
329 /**
330 * @brief Process normal Sync Interest
331 *
332 * This method extracts the digest from the incoming Sync Interest,
333 * compares it against current local digest, and process the Sync
334 * Interest according to the comparison result. See docs/design.rst
335 * for more details.
336 *
337 * @param interest The incoming interest
338 * @param isTimedProcessing True if the interest needs an immediate reply,
339 * otherwise hold the interest for a while before
340 * making a reply (to avoid unnecessary recovery)
341 */
342 void
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500343 processSyncInterest(const Interest& interest, bool isTimedProcessing = false);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700344
345 /**
346 * @brief Process reset Sync Interest
347 *
348 * This method simply call Logic::reset()
349 *
350 * @param interest The incoming interest.
351 */
352 void
353 processResetInterest(const Interest& interest);
354
355 /**
356 * @brief Process Sync Reply.
357 *
358 * This method extracts state update information from Sync Reply and applies
359 * it to the Sync Tree and re-express Sync Interest.
360 *
Davide Pesavento27416442020-01-23 23:10:24 -0500361 * @param name The data name of the Sync Reply.
362 * @param digest The digest in the data name.
363 * @param syncReply The content of the Sync Reply.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700364 */
365 void
Davide Pesavento27416442020-01-23 23:10:24 -0500366 processSyncData(const Name& name, ConstBufferPtr digest, const Block& syncReply);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700367
368 /**
369 * @brief Insert state diff into log
370 *
Davide Pesavento27416442020-01-23 23:10:24 -0500371 * @param diff The diff.
Yingdi Yuf7ede412014-08-30 20:37:52 -0700372 * @param previousRoot The root digest before state changes.
373 */
374 void
Davide Pesavento27416442020-01-23 23:10:24 -0500375 insertToDiffLog(DiffStatePtr diff, ConstBufferPtr previousRoot);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700376
377 /**
378 * @brief Reply to all pending Sync Interests with a particular commit (or diff)
379 *
380 * @param commit The diff.
381 */
382 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800383 satisfyPendingSyncInterests(const Name& updatedPrefix, ConstDiffStatePtr commit);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700384
385 /// @brief Helper method to send normal Sync Interest
386 void
387 sendSyncInterest();
388
389 /// @brief Helper method to send reset Sync Interest
390 void
391 sendResetInterest();
392
393 /// @brief Helper method to send Sync Reply
394 void
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800395 sendSyncData(const Name& nodePrefix, const Name& name, const State& state);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700396
397 /**
398 * @brief Unset reset status
399 *
400 * By invoking this method, one can add its own state into the Sync Tree, thus
401 * jumping out of the reset status
402 */
403 void
404 cancelReset();
405
406 void
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500407 printDigest(ConstBufferPtr digest);
Yingdi Yuf7ede412014-08-30 20:37:52 -0700408
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800409 /**
410 * @brief Helper method to send Recovery Interest
411 *
412 * @param digest The digest to be included in the recovery interest
413 */
414 void
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500415 sendRecoveryInterest(ConstBufferPtr digest);
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800416
417 /**
418 * @brief Process Recovery Interest
419 *
420 * This method extracts the digest from the incoming Recovery Interest.
421 * If it recognizes this incoming digest, then it sends its full state
422 * as reply.
423 *
424 * @param interest The incoming interest
425 */
426 void
427 processRecoveryInterest(const Interest& interest);
428
429 /**
430 * @brief Callback to handle Recovery Reply
431 *
432 * This method calls Logic::onSyncDataValidated directly.
433 *
434 * @param interest The Recovery Interest
435 * @param data The reply to the Recovery Interest
436 */
437 void
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800438 onRecoveryData(const Interest& interest, const Data& data);
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800439
440 /**
441 * @brief Callback to handle Recovery Interest timeout.
442 *
443 * This method does nothing.
444 *
445 * @param interest The Recovery Interest
446 */
447 void
448 onRecoveryTimeout(const Interest& interest);
449
Yingdi Yucd339022014-11-05 17:51:19 -0800450public:
451 static const ndn::Name DEFAULT_NAME;
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800452 static const ndn::Name EMPTY_NAME;
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500453 static const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
Yingdi Yucd339022014-11-05 17:51:19 -0800454
Yingdi Yuf7ede412014-08-30 20:37:52 -0700455private:
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500456 using NodeList = std::unordered_map<ndn::Name, NodeInfo>;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700457
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500458 static const ConstBufferPtr EMPTY_DIGEST;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700459 static const ndn::name::Component RESET_COMPONENT;
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800460 static const ndn::name::Component RECOVERY_COMPONENT;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700461
462 // Communication
463 ndn::Face& m_face;
464 Name m_syncPrefix;
Junxiao Shi8e4e76d2019-02-08 15:25:08 -0700465 ndn::ScopedRegisteredPrefixHandle m_syncRegisteredPrefix;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700466 Name m_syncReset;
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800467 Name m_defaultUserPrefix;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700468
469 // State
Qiuhan Ding8c095fd2014-11-19 17:38:32 -0800470 NodeList m_nodeList;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700471 State m_state;
472 DiffStateContainer m_log;
473 InterestTable m_interestTable;
Junxiao Shi8e4e76d2019-02-08 15:25:08 -0700474 Name m_pendingSyncInterestName;
475 ndn::ScopedPendingInterestHandle m_pendingSyncInterest;
476 ndn::ScopedPendingInterestHandle m_pendingResetInterest;
477 std::map<std::string, ndn::ScopedPendingInterestHandle> m_pendingRecoveryInterests;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700478 bool m_isInReset;
479 bool m_needPeriodReset;
480
481 // Callback
482 UpdateCallback m_onUpdate;
483
484 // Event
Davide Pesavento0d837e32019-03-16 22:31:14 -0400485 ndn::Scheduler m_scheduler;
486 ndn::scheduler::ScopedEventId m_delayedInterestProcessingId;
487 ndn::scheduler::ScopedEventId m_reexpressingInterestId;
488 ndn::scheduler::ScopedEventId m_resetInterestId;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700489
490 // Timer
Ashlesh Gawande9a306fe2019-01-04 11:38:18 -0600491 ndn::random::RandomNumberEngine& m_rng;
Ashlesh Gawande4a9ecd52018-02-06 14:36:19 -0600492 std::uniform_int_distribution<> m_rangeUniformRandom;
493 std::uniform_int_distribution<> m_reexpressionJitter;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700494 /// @brief Timer to send next reset 0 for no reset
495 time::steady_clock::Duration m_resetTimer;
496 /// @brief Timer to cancel reset state
497 time::steady_clock::Duration m_cancelResetTimer;
498 /// @brief Lifetime of reset interest
499 time::milliseconds m_resetInterestLifetime;
500 /// @brief Lifetime of sync interest
501 time::milliseconds m_syncInterestLifetime;
502 /// @brief FreshnessPeriod of SyncReply
503 time::milliseconds m_syncReplyFreshness;
Sonu Mishra4d3a2e02017-01-18 20:27:51 -0800504 /// @brief Lifetime of recovery interest
505 time::milliseconds m_recoveryInterestLifetime;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700506
Yingdi Yucd339022014-11-05 17:51:19 -0800507 // Security
Yingdi Yuf7ede412014-08-30 20:37:52 -0700508 ndn::KeyChain m_keyChain;
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500509 std::shared_ptr<Validator> m_validator;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700510
Yingdi Yuf7ede412014-08-30 20:37:52 -0700511 int m_instanceId;
Ashlesh Gawande08784d42017-09-06 23:40:21 -0500512 static int s_instanceCounter;
Yingdi Yuf7ede412014-08-30 20:37:52 -0700513};
514
Alexander Afanasyev89036292018-02-13 17:19:50 -0500515#ifdef CHRONOSYNC_HAVE_TESTS
516size_t
517getMaxPacketLimit();
518#endif // CHRONOSYNC_HAVE_TESTS
Yingdi Yuf7ede412014-08-30 20:37:52 -0700519
520} // namespace chronosync
521
Alexander Afanasyeve9eda8a2017-03-09 14:40:03 -0800522#endif // CHRONOSYNC_LOGIC_HPP