Fact-checked by Grok 2 weeks ago

Daytime Protocol

The Daytime Protocol is a simple network service within the that provides the current date and time as a human-readable ASCII character string to querying clients, primarily for testing, measurement, and debugging purposes in computer networks. Defined in May 1983 by in 867, it operates over both and on port 13 and remains an today. In its TCP implementation, a listens on port 13 and, upon accepting a client , immediately transmits the daytime followed by a normal close, without requiring or processing any input from the client. The UDP variant functions similarly in a connectionless manner: the responds to any incoming on port 13 with the daytime , ignoring the contents of the request entirely. This design ensures minimal overhead and simplicity, making it suitable for basic time queries in early network environments. The protocol specifies that the output must consist solely of printable ASCII characters, spaces, returns, and line feeds, with no other control characters permitted. Recommended formats include a verbose style such as "Weekday, Month Day, Year Time-Zone" (e.g., "Tuesday, February 22, 1982 17:37:43-PST") or a more concise SMTP-like format "dd mmm yy hh:mm:ss zzz" (e.g., "02 FEB 82 07:59:01 PST"), though implementations may vary as long as they adhere to the ASCII constraints. Unlike machine-readable time protocols such as the (RFC 868), the Daytime Protocol is explicitly intended for human consumption and basic synchronization in resource-constrained systems. Although largely superseded by more advanced protocols like (NTP) for precise , the Daytime Protocol continues to see limited use, including by small computers and in educational programming contexts, with official support provided by institutions such as the National Institute of Standards and Technology (NIST) through their Internet Time Service servers.

Overview

Definition and Purpose

The Daytime Protocol is a service within the that provides the current local date and time of the as an ASCII character string. Defined in RFC 867, it operates by having the transmit this immediately upon receiving a from a client, without processing any input from the client. The primary purpose of the Daytime Protocol is to serve as a lightweight tool for testing, measurement, and debugging network connectivity and basic time services, avoiding the need for complex synchronization mechanisms. This simplicity makes it particularly suitable for verifying network reachability and responsiveness in environments where minimal overhead is essential. Originally specified for hosts in the Internet community, the protocol was designed to support early network operations that prioritized efficiency and ease of implementation over advanced features. Its straightforward response mechanism ensures quick diagnostics without requiring ongoing communication or authentication.

Historical Development

The Daytime Protocol originated in the early 1980s amid the ARPANET's transition to the TCP/IP protocol suite, which was formally adopted on , 1983, marking a pivotal shift toward standardized . As part of this foundational effort, the protocol was developed to enable simple retrieval of the current date and time from remote hosts, supporting network diagnostics and synchronization in nascent internet environments. Authored by of the University of Southern California's Information Sciences Institute (ISI), it was published as RFC 867 in May 1983. Under the guidance of the Internet Assigned Numbers Authority (IANA), directed by Postel, the Daytime Protocol received port number 13 for both TCP and UDP transports, positioning it among the earliest assigned services in the TCP/IP ecosystem. The specification outlined a straightforward service for ARPA Internet hosts, emphasizing interoperability without complex negotiation. RFC 867 was designated an Internet Standard (STD 25), reflecting its role in establishing basic diagnostic tools for the emerging network. Since its inception, the core specification of the Daytime Protocol has undergone no major revisions, with only minor editorial errata noted over the decades. A related effort, the defined in RFC 868—also authored by Postel and released in May 1983—provided binary time representations but operated as a distinct service. The protocol persists in modern operating systems through legacy support, such as optional daemon configurations in environments and port listings in Windows networking services, ensuring for historical testing scenarios.

Protocol Specification

Operation and Message Exchange

The Daytime Protocol operates as a simple, one-way query-response mechanism between a client and a , designed primarily for retrieving the current date and time without any interactive negotiation. The client initiates the by establishing a to the on the designated , after which the immediately generates and transmits a response containing the current date and time as a character . Notably, the does not wait for or any input from the client, ensuring that the interaction remains unidirectional and efficient for basic time retrieval purposes. This protocol is inherently stateless, meaning each client request triggers a single, independent response from the with no maintenance of session , ongoing , or requirement for acknowledgments. Upon receiving the , the server formulates the response based solely on its local clock and sends it without analyzing or responding to any client data that might arrive concurrently. Once the response is delivered, the server terminates the connection, allowing the client to disconnect and parse the received as needed. This minimizes overhead and supports rapid, queries suitable for testing and measurement in network environments. Error handling in the Daytime Protocol is handled implicitly through the underlying mechanisms, such as connection timeouts or failures, rather than through any protocol-defined error messages or codes. For instance, if a cannot be established due to issues or unavailability, the client detects this at the transport level without receiving a protocol-specific indication. The absence of explicit error protocols at the underscores the protocol's simplicity, prioritizing reliability on lower-layer error detection over custom recovery procedures. A typical interaction flow illustrates this operational simplicity: the client first establishes a to the server; the server then promptly sends the date and time in response; and finally, the client receives the data and closes the . This , often completed in milliseconds, exemplifies the protocol's efficiency for non-critical time tasks, where the response is an ASCII-encoded representing the server's notion of the current moment.

Data Format and Encoding

The Daytime Protocol specifies that the server transmits the current local date and time as a human-readable ASCII string in response to a client request. This string is limited to ASCII printing characters, spaces, , and line feeds, ensuring compatibility with basic text processing. No fixed syntax is mandated by the , allowing flexibility in representation while prioritizing readability. Common conventions include a day-of-week followed by the date, time in 24-hour format, and a timezone indicator, such as "Wed, 13 Nov 2025 12:00:00 GMT". Two popular formats recommended in the are: a verbose style like "Weekday, Month Day, Year Time-Zone" (e.g., "Tuesday, February 22, 1982 17:37:43-PST"), and an SMTP-inspired compact form like "dd mmm yy hh:mm:ss zzz" (e.g., "02 FEB 82 07:59:01 PST"). The response consists of a single line, typically terminated by a and line feed (CRLF) sequence for connections to denote the end of the message. For transmissions, the ASCII string forms the entire without additional delimiters, as the protocol relies on the layer's message boundaries. Servers may append minor variations, such as additional timezone details or implementation-specific notes, but the core content remains focused solely on the date and time. This plain-text encoding promotes simplicity and interoperability across diverse systems.

Port and Transport Options

The Daytime Protocol operates on and port 13, which has been officially assigned by the (IANA) for the Daytime service. This port assignment traces back to the early IANA registries in the , reflecting the protocol's origins in the initial standardization efforts of internet services. The protocol supports both and transports on port 13. TCP provides a connection-oriented service with reliable, ordered delivery of data, making it suitable for environments requiring guaranteed transmission. In contrast, UDP offers a connectionless, mechanism without acknowledgments or retransmissions. The choice between and depends on the application's needs: ensures reliable delivery, which is advantageous for diagnostic and testing scenarios where message integrity is critical, while enables low-overhead, lightweight queries for simple time retrievals. Responses from servers are formatted as human-readable ASCII text strings representing the current date and time.

Implementations

Server-Side Implementations

In Unix-like operating systems, server-side implementations of the Daytime Protocol often leverage super-servers such as inetd or xinetd to manage the service efficiently. These daemons listen on TCP or UDP port 13 and spawn a lightweight process or invoke an internal handler only upon receiving a connection, minimizing resource usage for low-demand protocols like daytime. For instance, xinetd configurations typically include a dedicated file, such as /etc/xinetd.d/daytime-stream, defining the service with parameters like socket_type = stream, protocol = tcp, port = 13, and server = /usr/sbin/in.daytime or an equivalent binary, enabling the service by setting disable = no and restarting the daemon. Standalone server implementations are straightforward due to the protocol's simplicity, commonly written in low-level languages like C using the Berkeley sockets API to bind to port 13, accept connections, retrieve the local time via system calls such as gettimeofday(), format it as an ASCII string (e.g., "Wed Nov 13 12:00:00 2025 PST"), send the response terminated by <CR><LF>, and close the connection. Such servers ignore any incoming data from clients and terminate the session promptly, often after a brief timeout. In Python, a basic equivalent uses the socket module to create a TCP listener, fetch the time with time.strftime(), and transmit it over the accepted connection before shutdown. The following pseudocode illustrates a minimal TCP-based standalone server in C:
#include <sys/socket.h>  
#include <sys/time.h>  
#include <netinet/in.h>  
#include <unistd.h>  
#include <time.h>  
#include <string.h>  

int main() {  
    int sockfd = socket(AF_INET, SOCK_STREAM, 0);  // Create TCP socket  
    struct sockaddr_in servaddr = {0};  
    servaddr.sin_family = AF_INET;  
    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);  
    servaddr.sin_port = htons(13);  // Port 13  
    bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));  // Bind to port  
    listen(sockfd, 5);  // Listen for connections  

    while (1) {  
        int connfd = accept(sockfd, NULL, NULL);  // Accept client connection  
        struct timeval tv;  
        gettimeofday(&tv, NULL);  // Get current time  
        struct tm *tm = localtime(&tv.tv_sec);  
        char buf[100];  
        strftime(buf, sizeof(buf) - 3, "%a %b %d %H:%M:%S %Y %Z", tm);  // Format as ASCII with timezone  
        strcat(buf, "\r\n");  // Append required line terminators  
        write(connfd, buf, strlen(buf));  // Send response  
        close(connfd);  // Close connection  
    }  
    close(sockfd);  
    return 0;  
}  
This approach emphasizes iterative handling for single-threaded operation, though concurrent variants using fork() or threads can support multiple clients. Platform-specific integrations vary: in BSD-derived systems like , the daytime service is traditionally managed via with entries in /etc/[inetd](/page/Inetd).conf specifying the handler as internal or a dedicated . Modern environments, particularly those using , replace or augment with socket activation units, where a .socket (e.g., daytime.socket) defines ListenStream=13 and Accept=yes, paired with a .service (e.g., [email protected]) that executes the binary with StandardInput=socket to handle activated connections on demand. This method ensures the process starts only when needed, enhancing security and efficiency. On Windows, there is no built-in Daytime Protocol server, but custom implementations can be developed using the in languages like C++ or C#, or via third-party libraries such as Rebex Time, which provide / socket handling to bind to port 13, format per , and respond accordingly.

Client-Side Implementations

Client-side implementations of the Daytime Protocol enable applications to query remote servers for the current date and time by establishing a connection to port 13 using or . As specified in , the protocol is designed for simplicity, where the client initiates contact and receives an ASCII string representing the time at the server, such as the coded UTC format from NIST "56789 25-11-17 10:30:00 00 0 0 500 UTC(NIST) *" followed by a and line feed, without needing to send any specific request data after connection. This response format uses printable ASCII characters, spaces, and standard line terminators, making it straightforward to parse or display directly, though coded formats like NIST's require extraction of components (e.g., date as YR-MO-DA, time as HH:MM:SS in UTC). For TCP connections, the client opens a to the server's or on port 13, and the server sends the time string immediately upon accepting the , after which the connection typically closes. No data transmission from the client is required or processed by the server. In UDP mode, the client sends a to port 13—often empty or with arbitrary , as it is ignored—and awaits a response containing the time string. Due to UDP's connectionless and unreliable nature, clients should implement timeouts to handle potential , typically setting a receive timeout of a few seconds using options. A basic client in can be implemented using the built-in socket module, which handles the low-level networking details compliant with the . The following example connects to a public Daytime server operated by NIST and decodes the received ASCII response:
python
import [socket](/page/Socket)  

# Create [TCP](/page/TCP) [socket](/page/Socket)  
sock = [socket](/page/Socket).socket([socket](/page/Socket).AF_INET, [socket](/page/Socket).SOCK_STREAM)  
sock.settimeout(5)  # Optional timeout for [connection](/page/Connection)  
try:  
    sock.connect(('time.nist.gov', [13](/page/13)))  
    data = sock.recv(1024)  
    print(data.decode('ascii').rstrip())  
finally:  
    sock.close()  
This approach ensures reliable delivery over and includes error handling via try-finally for proper closure. For , the Python example modifies the socket type and includes an explicit send operation:
python
import socket  

# Create UDP [socket](/page/Socket)  
sock = [socket](/page/Socket).socket([socket](/page/Socket).AF_INET, [socket](/page/Socket).SOCK_DGRAM)  
sock.settimeout(5)  # Timeout for unreliable [UDP](/page/UDP)  
try:  
    sock.sendto(b'', ('time.nist.gov', 13))  # Empty [datagram](/page/Datagram) triggers response  
    data, _ = sock.recvfrom(1024)  
    print(data.decode('ascii').rstrip())  
finally:  
    sock.close()  
In C, clients leverage the Berkeley sockets API, using functions like socket(), getaddrinfo() for address resolution, connect() for TCP, or sendto()/recvfrom() for UDP, followed by recv() to read the response. A TCP example initializes the socket with AF_INET and SOCK_STREAM, resolves the hostname, connects, receives up to a buffer size (e.g., 1024 bytes), and prints the null-terminated string after trimming whitespace. UDP variants use SOCK_DGRAM and include setsockopt() to configure receive timeouts, such as 5000 milliseconds via SO_RCVTIMEO. These implementations follow POSIX standards and are portable across Unix-like systems. For ad-hoc testing without custom code, command-line utilities provide quick client access to servers. can connect via to port , displaying the time string upon connection, as in telnet time.nist.gov 13, which automatically receives and shows the response before closing. (nc) supports both protocols: nc time.nist.gov 13 for or nc -u time.nist.gov 13 for , where the latter sends an empty packet implicitly and prints the reply. These tools are widely available on Unix systems and useful for network diagnostics, with netcat's verbosity options aiding in troubleshooting connection issues.

Applications and Limitations

Primary Use Cases

The Daytime Protocol, operating on port , serves primarily as a lightweight tool for network diagnostics, enabling administrators to verify connectivity by establishing a simple or connection to a remote and receiving an immediate response containing the current date and time. This functionality makes it particularly useful in scenarios, such as confirming availability in early environments where more complex protocols were unavailable. In and systems lacking support for advanced time protocols like NTP, the Daytime Protocol provides a straightforward method for retrieving approximate current time from a network source, suitable for devices such as older MS-DOS-based machines or resource-constrained hardware. For instance, it has been employed in basic applications where minimal overhead is essential, allowing quick time acquisition without the need for ongoing mechanisms. Additionally, the facilitates clock by enabling users to cross-check local system time against a network-provided , offering a rudimentary validation without requiring high . A key historical example includes its integration into early diagnostic tools, where a successful query confirms both network reachability and server responsiveness.

Limitations and Modern Relevance

The Daytime Protocol lacks any form of , making it vulnerable to spoofing attacks where malicious actors can impersonate servers and provide falsified time data. This insecurity renders it unsuitable for time-sensitive applications, such as financial transactions or secure logging, where accurate and verifiable timestamps are essential. Furthermore, the protocol provides time information only to the nearest second, without support for sub-second precision, limiting its utility in environments requiring high-resolution synchronization. It also does not account for time zones in a standardized client-adjustable manner or handle leap seconds, potentially leading to discrepancies in global time representation. When implemented over , the protocol inherits the transport's unreliability, including risks of or delays in lossy networks, which can further degrade accuracy. In contemporary networking, the Daytime Protocol has been largely superseded by the Network Time Protocol (NTP) as defined in RFC 5905, which offers enhanced precision, authentication mechanisms, and robustness for . It persists primarily for legacy compatibility and simple diagnostic testing, with the National Institute of Standards and Technology (NIST) Internet Time Service (ITS) continuing to support it on port 13 for small systems and hardware lacking NTP capabilities as of November 2025. Public Daytime servers prompting reliance on alternatives such as HTTP-based time endpoints that provide current timestamps via APIs.

References

  1. [1]
    RFC 867: Daytime Protocol
    The Daytime Protocol sends the current date and time as a character string. It uses TCP or UDP on port 13, and is a debugging tool.
  2. [2]
    RFC 867 - Daytime Protocol - IETF Datatracker
    Aug 30, 2025 · A daytime service simply sends a the current date and time as a character string without regard to the input.
  3. [3]
    NIST Internet Time Service (ITS)
    Here are the server names, locations, and IP addresses and current status. ... Daytime Protocol (RFC-867). This protocol is widely used by small computers ...<|control11|><|separator|>
  4. [4]
    A Brief History of the Internet & Related Networks
    Both public domain and commercial implementations of the roughly 100 protocols of TCP/IP protocol suite became available in the 1980's. During the early 1990's, ...
  5. [5]
  6. [6]
    RFC 867 - Daytime Protocol - IETF Datatracker
    RFC 867 defines a standard for the ARPA Internet where hosts send the current date and time as a character string, using TCP or UDP.
  7. [7]
    History for rfc867 - IETF Datatracker
    Daytime Protocol RFC 867 also known as STD 25 · Status · Email expansions · History. Document history. Date, By, Action. 2025-08-30.
  8. [8]
    Service overview and network port requirements - Windows Server
    Jan 15, 2025 · This article discusses the required network ports, protocols, and services that are used by Microsoft client and server operating systems, server-based ...Missing: revisions | Show results with:revisions
  9. [9]
    Outline - Computer Science (CS) - Virginia Tech
    Simple Daytime Server 1/2. •Source code in daytimetcpsrv.c. •Create a TCP Socket. ➢Identical to client code. •Bind server well-known port to socket. ➢Fill an ...
  10. [10]
    systemd for Administrators, Part XI
    Sep 26, 2011 · In this story I hope to explain how to convert inetd services into systemd units. Let's start with a bit of background.Missing: side | Show results with:side
  11. [11]
    systemd.socket - Freedesktop.org
    Note that the daemon software configured for socket activation with socket units needs to be able to accept sockets from systemd, either via systemd's native ...Missing: daytime | Show results with:daytime
  12. [12]
    What is Port 13? - CBT Nuggets
    Jun 2, 2025 · It's officially designated for the Daytime Protocol, a simple service that returns the current date and time when queried.
  13. [13]
    Daytime protocol - Gokberk Yaltirakli
    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.
  14. [14]
    None
    ### Summary of Daytime Protocol (RFC 867)
  15. [15]
    World Time API: Simple JSON/plain-text API to obtain the current ...
    WorldTimeAPI is a simple web service which returns the current local time for a given timezone as either plain-text or JSON. Additional information is also ...FAQ page of WorldTimeAPI · Examples · Schema · Timezones