Click here to Skip to main content
Licence CPOL
First Posted 13 Mar 2001
Views 176,988
Bookmarked 81 times

SNTP Client in C#

By Valer BOCAN | 27 Aug 2001
Implementation of the Simple Network Time Protocol (RFC 2030) in C#

1
1 vote, 2.8%
2

3
5 votes, 13.9%
4
30 votes, 83.3%
5
4.89/5 - 66 votes
1 removed
μ 4.71, σa 1.05 [?]
  • Download source files - 12 Kb
  • Download demo project - 5 Kb

    Sample Image - ntpclient.jpg

    Introduction

    Though not obvious, time synchronization is sometimes important. The best example is the Kerberos authentication protocol, which requires the resources to be synchronized within minutes or even seconds, but there are other situations as well. The Network Time Protocol (NTP) and its simplified form (SNTP) are widely used to synchronize network resources, due to their simplicity and effectiveness. There are many programs available that synchronize your PC's clock with that of a time server. Dimension 4 is my favorite.

    In case you need time synchronization embedded into your software, here is the C# alternative. It's simple, fast and integrates seamlessly with the .NET platform. There is a Java implementation of a NTP client by Michel Van den Bergh, but I don't have the URL anymore. Maybe Michel reads this and will send me a note.

    There are several time severs on the Internet and the list below contains those operated by NIST. If you need more, use a search engine.

    Name IP Address Location
    time-a.nist.gov 129.6.15.28 NIST, Gaithersburg, Maryland
    time-b.nist.gov 129.6.15.29 NIST, Gaithersburg, Maryland
    time-a.timefreq.bldrdoc.gov 132.163.4.101 NIST, Boulder, Colorado
    time-b.timefreq.bldrdoc.gov 132.163.4.102 NIST, Boulder, Colorado
    time-c.timefreq.bldrdoc.gov 132.163.4.103 NIST, Boulder, Colorado
    utcnist.colorado.edu 128.138.140.44 University of Colorado, Boulder
    time.nist.gov 192.43.244.18 NCAR, Boulder, Colorado
    time-nw.nist.gov 131.107.1.10 Microsoft, Redmond, Washington
    nist1.datum.com 209.0.72.7 Datum, San Jose, California
    nist1.dc.certifiedtime.com 216.200.93.8 Abovnet, Virginia
    nist1.nyc.certifiedtime.com 208.184.49.9 Abovnet, New York City
    nist1.sjc.certifiedtime.com 208.185.146.41 Abovnet, San Jose, California

  • License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    About the Author

    Valer BOCAN

    Architect

    Romania Romania

    Member
    I am a software engineer based in Timișoara, Romania and currently hold the position of software architect for one of the largest companies in the world.
     
    I invented a dialect of the Forth programming language and implemented the first Forth compiler for the .NET platform. I reverse-engineered the communication protocol of some GPS trackers and wrote from scratch a vehicle tracking system that is currently used to track my two cars. I hold a PhD in computer science and I am the author of several papers and a book chapter. In the 90s I wrote several computer viruses in assembly language for my own research and I was the first to devise a technique to deter heuristic virus scanners. In short, a humble man.

    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    GeneralTimeouts Pinmembermalcomm23:55 11 Feb '11  
    GeneralRe: Timeouts PinmemberRomain TAILLANDIER0:42 9 Dec '11  
    AnswerRe: Timeouts PinmemberValer BOCAN0:56 9 Dec '11  
    GeneralRe: Timeouts PinmemberRomain TAILLANDIER1:14 9 Dec '11  
    NewsGreat little helper, has a leak Pinmemberbruceme1017:24 23 Feb '10  
    GeneralLicense PinmemberCaptain Groovy15:00 4 Feb '10  
    GeneralRe: License PinmemberValer BOCAN18:43 4 Feb '10  
    Generalthanx PinmemberMurat DOGANCAY3:55 21 Feb '09  
    Generalhangs if no ip Pinmemberwihe200820:27 18 Jul '08  
    GeneralRe: hangs if no ip Pinmemberwihe200820:31 18 Jul '08  
    GeneralRe: hangs if no ip Pinmemberwihe200821:55 18 Jul '08  
    Generalcommercial use Pinmemberharmjonker7:19 14 Jul '08  
    GeneralRe: commercial use PinmemberValer BOCAN23:47 14 Jul '08  
    QuestionDaylight Time saving PinmemberXadhoomGrglblstr23:47 6 Apr '08  
    AnswerRe: Daylight Time saving [modified] PinmemberGeoff Low (NZ)16:56 5 Jun '08  
    GeneralThe program block PinmemberNanakiFire4:34 2 Apr '08  
    GeneralNTP in Compact Framework PinmemberIowaEric6:56 8 Jun '07  
    GeneralRe: NTP in Compact Framework PinmemberIowaEric16:51 24 Oct '07  
    GeneralRe: NTP in Compact Framework Pinmemberbeimklabautermann6:38 3 Jun '10  
    GeneralNIce article PinmemberVikas Salvi3:21 3 Mar '07  
    AnswerRe: NIce article PinmemberNetDave7:48 25 Apr '07  
    GeneralExecution on Pocket PC Emulator PinmemberRashmi C2:16 13 Dec '06  
    The SNTP C# code works on desktop PC. But while trying it on Pocket PC emulator am unable to receive any packets from the server.
    Found that Active Sync does not support UDP.
    Therefore, installed Virtual Machine Network Driver and VMWare. Yet the code does not work.
    Please help me execute the code on Pocket PC. It is urgent.
     
    rashmi chinchkar

    GeneralGet Server time Pinmembertry.kret18:14 8 Oct '06  
    AnswerRe: Get Server time PinmemberValer BOCAN18:23 8 Oct '06  
    GeneralRe: Get Server time Pinmembertry.kret18:49 8 Oct '06  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Mobile
    Web04 | 2.5.120210.1 | Last Updated 28 Aug 2001
    Article Copyright 2001 by Valer BOCAN
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid