forked from RevenantX/LiteNetLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLiteNetLib.Utils.NtpPacket.html
More file actions
758 lines (705 loc) · 31.9 KB
/
LiteNetLib.Utils.NtpPacket.html
File metadata and controls
758 lines (705 loc) · 31.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Class NtpPacket
</title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Class NtpPacket
">
<meta name="generator" content="docfx 2.53.1.0">
<link rel="shortcut icon" href="../favicon.ico">
<link rel="stylesheet" href="../styles/docfx.vendor.css">
<link rel="stylesheet" href="../styles/docfx.css">
<link rel="stylesheet" href="../styles/main.css">
<meta property="docfx:navrel" content="../toc.html">
<meta property="docfx:tocrel" content="toc.html">
</head>
<body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../logo.svg" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search" id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</div>
</div>
</header>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="LiteNetLib.Utils.NtpPacket">
<h1 id="LiteNetLib_Utils_NtpPacket" data-uid="LiteNetLib.Utils.NtpPacket" class="text-break">Class NtpPacket
</h1>
<div class="markdown level0 summary"><p>Represents RFC4330 SNTP packet used for communication to and from a network time server.</p>
</div>
<div class="markdown level0 conceptual"></div>
<div class="inheritance">
<h5>Inheritance</h5>
<div class="level0"><span class="xref">System.Object</span></div>
<div class="level1"><span class="xref">NtpPacket</span></div>
</div>
<h6><strong>Namespace</strong>: <a class="xref" href="LiteNetLib.Utils.html">LiteNetLib.Utils</a></h6>
<h6><strong>Assembly</strong>: LiteNetLib.dll</h6>
<h5 id="LiteNetLib_Utils_NtpPacket_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public class NtpPacket</code></pre>
</div>
<h5 id="LiteNetLib_Utils_NtpPacket_remarks"><strong>Remarks</strong></h5>
<div class="markdown level0 remarks"><p>
Most applications should just use the <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_CorrectionOffset">CorrectionOffset</a> property.
</p>
<p>
The same data structure represents both request and reply packets.
Request and reply differ in which properties are set and to what values.
</p>
<p>
The only real property is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_Bytes">Bytes</a>.
All other properties read from and write to the underlying byte array
with the exception of <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_DestinationTimestamp">DestinationTimestamp</a>,
which is not part of the packet on network and it is instead set locally after receiving the packet.
</p>
<p>
Copied from <a href="https://guerrillantp.machinezoo.com/">GuerrillaNtp project</a>
with permission from Robert Vazan (@robertvazan) under MIT license, see <a href="https://github.com/RevenantX/LiteNetLib/pull/236">https://github.com/RevenantX/LiteNetLib/pull/236</a>
</p>
</div>
<h3 id="constructors">Constructors
</h3>
<a id="LiteNetLib_Utils_NtpPacket__ctor_" data-uid="LiteNetLib.Utils.NtpPacket.#ctor*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket__ctor" data-uid="LiteNetLib.Utils.NtpPacket.#ctor">NtpPacket()</h4>
<div class="markdown level1 summary"><p>Initializes default request packet.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public NtpPacket()</code></pre>
</div>
<h5 id="LiteNetLib_Utils_NtpPacket__ctor_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Properties <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_Mode">Mode</a> and <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_VersionNumber">VersionNumber</a>
are set appropriately for request packet. Property <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_TransmitTimestamp">TransmitTimestamp</a>
is set to <span class="xref">System.DateTime.UtcNow</span>.</p>
</div>
<h3 id="properties">Properties
</h3>
<a id="LiteNetLib_Utils_NtpPacket_Bytes_" data-uid="LiteNetLib.Utils.NtpPacket.Bytes*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_Bytes" data-uid="LiteNetLib.Utils.NtpPacket.Bytes">Bytes</h4>
<div class="markdown level1 summary"><p>Gets RFC4330-encoded SNTP packet.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public byte[] Bytes { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Byte</span>[]</td>
<td><p>Byte array containing RFC4330-encoded SNTP packet. It is at least 48 bytes long.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_Bytes_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This is the only real property. All other properties except
<a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_DestinationTimestamp">DestinationTimestamp</a> read from or write to this byte array.</p>
</div>
<a id="LiteNetLib_Utils_NtpPacket_CorrectionOffset_" data-uid="LiteNetLib.Utils.NtpPacket.CorrectionOffset*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_CorrectionOffset" data-uid="LiteNetLib.Utils.NtpPacket.CorrectionOffset">CorrectionOffset</h4>
<div class="markdown level1 summary"><p>Gets the offset that should be added to local time to synchronize it with server time.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public TimeSpan CorrectionOffset { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.TimeSpan</span></td>
<td><p>Time difference between server and client. It should be added to local time to get server time.
It is calculated from timestamps in the packet as <code>0.5 * ((t1 - t0) - (t3 - t2))</code>
where t0 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_OriginTimestamp">OriginTimestamp</a>,
t1 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_ReceiveTimestamp">ReceiveTimestamp</a>,
t2 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_TransmitTimestamp">TransmitTimestamp</a>,
and t3 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_DestinationTimestamp">DestinationTimestamp</a>.
This property throws an exception in request packets.</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_DestinationTimestamp_" data-uid="LiteNetLib.Utils.NtpPacket.DestinationTimestamp*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_DestinationTimestamp" data-uid="LiteNetLib.Utils.NtpPacket.DestinationTimestamp">DestinationTimestamp</h4>
<div class="markdown level1 summary"><p>Gets or sets the time of reception of response SNTP packet on the client.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public DateTime? DestinationTimestamp { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Nullable</span><<span class="xref">System.DateTime</span>></td>
<td><p>Time of reception of response SNTP packet on the client. It is <code>null</code> in request packets.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_DestinationTimestamp_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This property is not part of the protocol and has to be set when reply packet is received.</p>
</div>
<h5 id="LiteNetLib_Utils_NtpPacket_DestinationTimestamp_seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_CorrectionOffset">CorrectionOffset</a></div>
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_RoundTripTime">RoundTripTime</a></div>
</div>
<a id="LiteNetLib_Utils_NtpPacket_LeapIndicator_" data-uid="LiteNetLib.Utils.NtpPacket.LeapIndicator*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_LeapIndicator" data-uid="LiteNetLib.Utils.NtpPacket.LeapIndicator">LeapIndicator</h4>
<div class="markdown level1 summary"><p>Gets the leap second indicator.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public NtpLeapIndicator LeapIndicator { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="LiteNetLib.Utils.NtpLeapIndicator.html">NtpLeapIndicator</a></td>
<td><p>Leap second warning, if any. Special value
<a class="xref" href="LiteNetLib.Utils.NtpLeapIndicator.html#LiteNetLib_Utils_NtpLeapIndicator_AlarmCondition">AlarmCondition</a> indicates unsynchronized server clock.
Default is <a class="xref" href="LiteNetLib.Utils.NtpLeapIndicator.html#LiteNetLib_Utils_NtpLeapIndicator_NoWarning">NoWarning</a>.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_LeapIndicator_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>Only servers fill in this property. Clients can consult this property for possible leap second warning.</p>
</div>
<a id="LiteNetLib_Utils_NtpPacket_Mode_" data-uid="LiteNetLib.Utils.NtpPacket.Mode*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_Mode" data-uid="LiteNetLib.Utils.NtpPacket.Mode">Mode</h4>
<div class="markdown level1 summary"><p>Gets or sets SNTP packet mode, i.e. whether this is client or server packet.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public NtpMode Mode { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="LiteNetLib.Utils.NtpMode.html">NtpMode</a></td>
<td><p>SNTP packet mode. Default is <a class="xref" href="LiteNetLib.Utils.NtpMode.html#LiteNetLib_Utils_NtpMode_Client">Client</a> in newly created packets.
Server reply should have this property set to <a class="xref" href="LiteNetLib.Utils.NtpMode.html#LiteNetLib_Utils_NtpMode_Server">Server</a>.</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_OriginTimestamp_" data-uid="LiteNetLib.Utils.NtpPacket.OriginTimestamp*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_OriginTimestamp" data-uid="LiteNetLib.Utils.NtpPacket.OriginTimestamp">OriginTimestamp</h4>
<div class="markdown level1 summary"><p>Gets or sets the time when the client sent its request.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public DateTime? OriginTimestamp { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Nullable</span><<span class="xref">System.DateTime</span>></td>
<td><p>This property is <code>null</code> in request packets.
In reply packets, it is the time when the client sent its request.
Servers copy this value from <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_TransmitTimestamp">TransmitTimestamp</a>
that they find in received request packet.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_OriginTimestamp_seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_CorrectionOffset">CorrectionOffset</a></div>
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_RoundTripTime">RoundTripTime</a></div>
</div>
<a id="LiteNetLib_Utils_NtpPacket_Poll_" data-uid="LiteNetLib.Utils.NtpPacket.Poll*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_Poll" data-uid="LiteNetLib.Utils.NtpPacket.Poll">Poll</h4>
<div class="markdown level1 summary"><p>Gets server's preferred polling interval.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public int Poll { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><p>Polling interval in log2 seconds, e.g. 4 stands for 16s and 17 means 131,072s.</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_Precision_" data-uid="LiteNetLib.Utils.NtpPacket.Precision*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_Precision" data-uid="LiteNetLib.Utils.NtpPacket.Precision">Precision</h4>
<div class="markdown level1 summary"><p>Gets the precision of server clock.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public int Precision { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><p>Clock precision in log2 seconds, e.g. -20 for microsecond precision.</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_ReceiveTimestamp_" data-uid="LiteNetLib.Utils.NtpPacket.ReceiveTimestamp*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_ReceiveTimestamp" data-uid="LiteNetLib.Utils.NtpPacket.ReceiveTimestamp">ReceiveTimestamp</h4>
<div class="markdown level1 summary"><p>Gets or sets the time when the request was received by the server.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public DateTime? ReceiveTimestamp { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Nullable</span><<span class="xref">System.DateTime</span>></td>
<td><p>This property is <code>null</code> in request packets.
In reply packets, it is the time when the server received client request.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_ReceiveTimestamp_seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_CorrectionOffset">CorrectionOffset</a></div>
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_RoundTripTime">RoundTripTime</a></div>
</div>
<a id="LiteNetLib_Utils_NtpPacket_ReferenceId_" data-uid="LiteNetLib.Utils.NtpPacket.ReferenceId*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_ReferenceId" data-uid="LiteNetLib.Utils.NtpPacket.ReferenceId">ReferenceId</h4>
<div class="markdown level1 summary"><p>Gets the ID of the time source used by the server or Kiss-o'-Death code sent by the server.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public uint ReferenceId { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.UInt32</span></td>
<td><p>
ID of server's time source or Kiss-o'-Death code.
Purpose of this property depends on value of <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_Stratum">Stratum</a> property.
</p>
<p>
Stratum 1 servers write here one of several special values that describe the kind of hardware clock they use.
</p>
<p>
Stratum 2 and lower servers set this property to IPv4 address of their upstream server.
If upstream server has IPv6 address, the address is hashed, because it doesn't fit in this property.
</p>
<p>
When server sets <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_Stratum">Stratum</a> to special value 0,
this property contains so called kiss code that instructs the client to stop querying the server.
</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_ReferenceTimestamp_" data-uid="LiteNetLib.Utils.NtpPacket.ReferenceTimestamp*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_ReferenceTimestamp" data-uid="LiteNetLib.Utils.NtpPacket.ReferenceTimestamp">ReferenceTimestamp</h4>
<div class="markdown level1 summary"><p>Gets or sets the time when the server clock was last set or corrected.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public DateTime? ReferenceTimestamp { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Nullable</span><<span class="xref">System.DateTime</span>></td>
<td><p>Time when the server clock was last set or corrected or <code>null</code> when not specified.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_ReferenceTimestamp_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This Property is usually set only by servers. It usually lags server's current time by several minutes,
so don't use this property for time synchronization.</p>
</div>
<a id="LiteNetLib_Utils_NtpPacket_RootDelay_" data-uid="LiteNetLib.Utils.NtpPacket.RootDelay*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_RootDelay" data-uid="LiteNetLib.Utils.NtpPacket.RootDelay">RootDelay</h4>
<div class="markdown level1 summary"><p>Gets the total round-trip delay from the server to the reference clock.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public TimeSpan RootDelay { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.TimeSpan</span></td>
<td><p>Round-trip delay to the reference clock. Normally a positive value smaller than one second.</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_RootDispersion_" data-uid="LiteNetLib.Utils.NtpPacket.RootDispersion*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_RootDispersion" data-uid="LiteNetLib.Utils.NtpPacket.RootDispersion">RootDispersion</h4>
<div class="markdown level1 summary"><p>Gets the estimated error in time reported by the server.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public TimeSpan RootDispersion { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.TimeSpan</span></td>
<td><p>Estimated error in time reported by the server. Normally a positive value smaller than one second.</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_RoundTripTime_" data-uid="LiteNetLib.Utils.NtpPacket.RoundTripTime*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_RoundTripTime" data-uid="LiteNetLib.Utils.NtpPacket.RoundTripTime">RoundTripTime</h4>
<div class="markdown level1 summary"><p>Gets the round-trip time to the server.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public TimeSpan RoundTripTime { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.TimeSpan</span></td>
<td><p>Time the request spent traveling to the server plus the time the reply spent traveling back.
This is calculated from timestamps in the packet as <code>(t1 - t0) + (t3 - t2)</code>
where t0 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_OriginTimestamp">OriginTimestamp</a>,
t1 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_ReceiveTimestamp">ReceiveTimestamp</a>,
t2 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_TransmitTimestamp">TransmitTimestamp</a>,
and t3 is <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_DestinationTimestamp">DestinationTimestamp</a>.
This property throws an exception in request packets.</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_Stratum_" data-uid="LiteNetLib.Utils.NtpPacket.Stratum*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_Stratum" data-uid="LiteNetLib.Utils.NtpPacket.Stratum">Stratum</h4>
<div class="markdown level1 summary"><p>Gets server's distance from the reference clock.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public int Stratum { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><p>
Distance from the reference clock. This property is set only in server reply packets.
Servers connected directly to reference clock hardware set this property to 1.
Statum number is incremented by 1 on every hop down the NTP server hierarchy.
</p>
<p>
Special value 0 indicates that this packet is a Kiss-o'-Death message
with kiss code stored in <a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_ReferenceId">ReferenceId</a>.
</p>
</td>
</tr>
</tbody>
</table>
<a id="LiteNetLib_Utils_NtpPacket_TransmitTimestamp_" data-uid="LiteNetLib.Utils.NtpPacket.TransmitTimestamp*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_TransmitTimestamp" data-uid="LiteNetLib.Utils.NtpPacket.TransmitTimestamp">TransmitTimestamp</h4>
<div class="markdown level1 summary"><p>Gets or sets the time when the packet was sent.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public DateTime? TransmitTimestamp { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Nullable</span><<span class="xref">System.DateTime</span>></td>
<td><p>Time when the packet was sent. It should never be <code>null</code>.
Default value is <span class="xref">System.DateTime.UtcNow</span>.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_TransmitTimestamp_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This property must be set by both clients and servers.</p>
</div>
<h5 id="LiteNetLib_Utils_NtpPacket_TransmitTimestamp_seealso">See Also</h5>
<div class="seealso">
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_CorrectionOffset">CorrectionOffset</a></div>
<div><a class="xref" href="LiteNetLib.Utils.NtpPacket.html#LiteNetLib_Utils_NtpPacket_RoundTripTime">RoundTripTime</a></div>
</div>
<a id="LiteNetLib_Utils_NtpPacket_VersionNumber_" data-uid="LiteNetLib.Utils.NtpPacket.VersionNumber*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_VersionNumber" data-uid="LiteNetLib.Utils.NtpPacket.VersionNumber">VersionNumber</h4>
<div class="markdown level1 summary"><p>Gets or sets protocol version number.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public int VersionNumber { get; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td><p>SNTP protocol version. Default is 4, which is the latest version at the time of this writing.</p>
</td>
</tr>
</tbody>
</table>
<h5 id="LiteNetLib_Utils_NtpPacket_VersionNumber_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>In request packets, clients should leave this property at default value 4.
Servers usually reply with the same protocol version.</p>
</div>
<h3 id="methods">Methods
</h3>
<a id="LiteNetLib_Utils_NtpPacket_FromServerResponse_" data-uid="LiteNetLib.Utils.NtpPacket.FromServerResponse*"></a>
<h4 id="LiteNetLib_Utils_NtpPacket_FromServerResponse_System_Byte___System_DateTime_" data-uid="LiteNetLib.Utils.NtpPacket.FromServerResponse(System.Byte[],System.DateTime)">FromServerResponse(Byte[], DateTime)</h4>
<div class="markdown level1 summary"><p>Initializes packet from data received from a server.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static NtpPacket FromServerResponse(byte[] bytes, DateTime destinationTimestamp)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Byte</span>[]</td>
<td><span class="parametername">bytes</span></td>
<td><p>Data received from the server.</p>
</td>
</tr>
<tr>
<td><span class="xref">System.DateTime</span></td>
<td><span class="parametername">destinationTimestamp</span></td>
<td><p>Utc time of reception of response SNTP packet on the client.</p>
</td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="LiteNetLib.Utils.NtpPacket.html">NtpPacket</a></td>
<td></td>
</tr>
</tbody>
</table>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
<span>Generated by <strong>DocFX</strong></span>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="../styles/docfx.vendor.js"></script>
<script type="text/javascript" src="../styles/docfx.js"></script>
<script type="text/javascript" src="../styles/main.js"></script>
</body>
</html>