Daytime Protocol
The Daytime Protocol is a simple network service within the Internet Protocol Suite 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 Jon Postel in RFC 867, it operates over both TCP and UDP on port 13 and remains an Internet Standard today.[1][2]
In its TCP implementation, a server listens on port 13 and, upon accepting a client connection, immediately transmits the daytime string followed by a normal connection close, without requiring or processing any input from the client. The UDP variant functions similarly in a connectionless manner: the server responds to any incoming datagram on port 13 with the daytime string, ignoring the contents of the request datagram entirely. This design ensures minimal overhead and simplicity, making it suitable for basic time queries in early network environments.[1]
The protocol specifies that the output string must consist solely of printable ASCII characters, spaces, carriage 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 Time Protocol (RFC 868), the Daytime Protocol is explicitly intended for human consumption and basic synchronization in resource-constrained systems.[1]
Although largely superseded by more advanced protocols like Network Time Protocol (NTP) for precise clock synchronization, 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.[3]
Overview
Definition and Purpose
The Daytime Protocol is a service within the Internet Protocol Suite that provides the current local date and time of the server as an ASCII character string.[1] Defined in RFC 867, it operates by having the server transmit this information immediately upon receiving a connection from a client, without processing any input from the client.[1]
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.[1] This simplicity makes it particularly suitable for verifying network reachability and server responsiveness in environments where minimal overhead is essential.[1]
Originally specified for hosts in the ARPA Internet community, the protocol was designed to support early network operations that prioritized efficiency and ease of implementation over advanced features.[1] Its straightforward response mechanism ensures quick diagnostics without requiring ongoing communication or authentication.[1]
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 January 1, 1983, marking a pivotal shift toward standardized internetworking.[4] 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 Jon Postel of the University of Southern California's Information Sciences Institute (ISI), it was published as RFC 867 in May 1983.[1]
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.[5] The specification outlined a straightforward service for ARPA Internet hosts, emphasizing interoperability without complex negotiation.[6] RFC 867 was designated an Internet Standard (STD 25), reflecting its role in establishing basic diagnostic tools for the emerging network.[7]
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 Time Protocol 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 Unix-like environments and port listings in Windows networking services, ensuring compatibility for historical testing scenarios.[8]
Protocol Specification
Operation and Message Exchange
The Daytime Protocol operates as a simple, one-way query-response mechanism between a client and a server, designed primarily for retrieving the current date and time without any interactive negotiation. The client initiates the process by establishing a connection to the server on the designated port, after which the server immediately generates and transmits a response containing the current date and time as a character string. Notably, the server does not wait for or process any input from the client, ensuring that the interaction remains unidirectional and efficient for basic time retrieval purposes.[1]
This protocol is inherently stateless, meaning each client request triggers a single, independent response from the server with no maintenance of session state, ongoing dialogue, or requirement for acknowledgments. Upon receiving the connection, 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 string as needed. This design minimizes overhead and supports rapid, fire-and-forget queries suitable for testing and measurement in network environments.[1]
Error handling in the Daytime Protocol is handled implicitly through the underlying transport layer mechanisms, such as connection timeouts or failures, rather than through any protocol-defined error messages or codes. For instance, if a connection cannot be established due to network issues or server unavailability, the client detects this at the transport level without receiving a protocol-specific indication. The absence of explicit error protocols at the application layer underscores the protocol's simplicity, prioritizing reliability on lower-layer error detection over custom recovery procedures.[1]
A typical interaction flow illustrates this operational simplicity: the client first establishes a connection to the server; the server then promptly sends the date and time string in response; and finally, the client receives the data and closes the connection. This sequence, often completed in milliseconds, exemplifies the protocol's efficiency for non-critical time synchronization tasks, where the response is an ASCII-encoded string representing the server's notion of the current moment.[1]
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.[6] This string is limited to ASCII printing characters, spaces, carriage returns, and line feeds, ensuring compatibility with basic text processing.[6]
No fixed syntax is mandated by the protocol, allowing flexibility in representation while prioritizing readability.[6] Common conventions include a day-of-week abbreviation followed by the date, time in 24-hour format, and a timezone indicator, such as "Wed, 13 Nov 2025 12:00:00 GMT".[6] Two popular formats recommended in the RFC 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").[6] The response consists of a single line, typically terminated by a carriage return and line feed (CRLF) sequence for TCP connections to denote the end of the message.[6]
For UDP transmissions, the ASCII string forms the entire datagram payload without additional delimiters, as the protocol relies on the transport layer's message boundaries.[6] 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.[6] This plain-text encoding promotes simplicity and interoperability across diverse systems.[6]
Port and Transport Options
The Daytime Protocol operates on TCP and UDP port 13, which has been officially assigned by the Internet Assigned Numbers Authority (IANA) for the Daytime service.[5] This port assignment traces back to the early IANA registries in the 1980s, reflecting the protocol's origins in the initial standardization efforts of internet services.[1]
The protocol supports both Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) transports on port 13. TCP provides a connection-oriented service with reliable, ordered delivery of data, making it suitable for environments requiring guaranteed transmission.[1] In contrast, UDP offers a connectionless, best-effort delivery mechanism without acknowledgments or retransmissions.[5]
The choice between TCP and UDP depends on the application's needs: TCP ensures reliable delivery, which is advantageous for diagnostic and testing scenarios where message integrity is critical, while UDP enables low-overhead, lightweight queries for simple time retrievals.[1] Responses from Daytime servers are formatted as human-readable ASCII text strings representing the current date and time.[1]
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.[1] 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;
}
#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.[9]
Platform-specific integrations vary: in BSD-derived systems like FreeBSD, the daytime service is traditionally managed via inetd with entries in /etc/[inetd](/page/Inetd).conf specifying the handler as internal or a dedicated executable. Modern Linux environments, particularly those using systemd, replace or augment inetd with socket activation units, where a .socket file (e.g., daytime.socket) defines ListenStream=13 and Accept=yes, paired with a .service file (e.g., [email protected]) that executes the server binary with StandardInput=socket to handle activated connections on demand.[10] This method ensures the server process starts only when needed, enhancing security and efficiency.[11]
On Windows, there is no built-in Daytime Protocol server, but custom implementations can be developed using the Winsock API in languages like C++ or C#, or via third-party libraries such as Rebex Time, which provide TCP/UDP socket handling to bind to port 13, format local time per RFC 867, and respond accordingly.[12]
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 TCP or UDP. As specified in RFC 867, 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 carriage return and line feed, without needing to send any specific request data after connection.[6] 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).[6][3]
For TCP connections, the client opens a socket to the server's IP address or hostname on port 13, and the server sends the time string immediately upon accepting the connection, 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 datagram to port 13—often empty or with arbitrary content, as it is ignored—and awaits a response datagram containing the time string. Due to UDP's connectionless and unreliable nature, clients should implement timeouts to handle potential packet loss, typically setting a receive timeout of a few seconds using socket options.[6]
A basic TCP client in Python can be implemented using the built-in socket module, which handles the low-level networking details compliant with the protocol. The following code 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()
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 TCP and includes error handling via try-finally for proper socket closure. For UDP, 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()
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.[3]
For ad-hoc testing without custom code, command-line utilities provide quick client access to Daytime servers. Telnet can connect via TCP to port 13, displaying the time string upon connection, as in telnet time.nist.gov 13, which automatically receives and shows the response before closing. Netcat (nc) supports both protocols: nc time.nist.gov 13 for TCP or nc -u time.nist.gov 13 for UDP, 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.[6][3]
Applications and Limitations
Primary Use Cases
The Daytime Protocol, operating on port 13, serves primarily as a lightweight tool for network diagnostics, enabling administrators to verify connectivity by establishing a simple TCP or UDP connection to a remote server and receiving an immediate response containing the current date and time.[1] This functionality makes it particularly useful in troubleshooting scenarios, such as confirming server availability in early Internet environments where more complex protocols were unavailable.[13]
In legacy and embedded systems lacking support for advanced time synchronization 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.[13] For instance, it has been employed in basic embedded applications where minimal overhead is essential, allowing quick time acquisition without the need for ongoing synchronization mechanisms.[1]
Additionally, the protocol facilitates clock verification by enabling users to cross-check local system time against a network-provided timestamp, offering a rudimentary validation without requiring high precision.[6] A key historical example includes its integration into early Internet diagnostic tools, where a successful query confirms both network reachability and server responsiveness.[13]
Limitations and Modern Relevance
The Daytime Protocol lacks any form of authentication, making it vulnerable to spoofing attacks where malicious actors can impersonate servers and provide falsified time data.[14] This insecurity renders it unsuitable for time-sensitive applications, such as financial transactions or secure logging, where accurate and verifiable timestamps are essential.[3]
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.[14] 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.[14] When implemented over UDP, the protocol inherits the transport's unreliability, including risks of packet loss or delays in lossy networks, which can further degrade accuracy.[14]
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 clock synchronization. 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.[3] Public Daytime servers prompting reliance on alternatives such as HTTP-based time endpoints that provide current timestamps via REST APIs.[15]