Daytime protocol


Reading time: about 1 minute

Daytime is an almost extinct protocol that can be used to get the current time from a server. It is defined by RFC867. It can be used over TCP or UDP.

You can consider it a human-readable and extremely simple version of the Network Time Protocol. Even though there is no strict format that the servers are expected to use, you can probably manage to extract a machine-readable time from it with some best-effort parsing and heuristics.

TCP Connections

The server should listen on TCP port 13. When it accepts a new connection, it should send the current time in an UNSPECIFIED format, discard any received data and close the connection.

UDP Connections

The server should listen for UDP datagrams on port 13. When it receives a datagram, it should send a reply containing the current time in an UNSPECIFIED format. Any data it receives in the datagram should be discarded.

Time format

The time format is not specified in the RFC, but it is recommended to be limited to ASCII characters, space, carriage return (\r) and line feed (\n).

Example server in Python

import socket
import time

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("0.0.0.0", 13)) # Bind to port 13
server.listen(5)

while True:
    sock, addr = server.accept()
    daytime = time.strftime("%A, %B %d, %Y, %H:%M:%S\n") # Tuesday, February 22, 1982 17:37:43
    sock.send(daytime.encode("ascii"))
    sock.close()

Citation

If you find this work useful, please cite it as:
@article{yaltirakli,
  title   = "Daytime protocol",
  author  = "Yaltirakli, Gokberk",
  journal = "gkbrk.com",
  year    = "2024",
  url     = "https://www.gkbrk.com/daytime-protocol"
}
Not using BibTeX? Click here for more citation styles.
IEEE Citation
Gokberk Yaltirakli, "Daytime protocol", November, 2024. [Online]. Available: https://www.gkbrk.com/daytime-protocol. [Accessed Nov. 12, 2024].
APA Style
Yaltirakli, G. (2024, November 12). Daytime protocol. https://www.gkbrk.com/daytime-protocol
Bluebook Style
Gokberk Yaltirakli, Daytime protocol, GKBRK.COM (Nov. 12, 2024), https://www.gkbrk.com/daytime-protocol

Comments

© 2024 Gokberk Yaltirakli