An electronic device comprising circuitry configured to: establish a TCP connection with another electronic device (11, 22); generate a secret key shared between the electronic device and the other electronic device; output a first response request command, which is transmitted to the other electronic device, the first response request command generated based on the secret key and a first random number; receive a first response message based on the first response request command, the first response message transmitted from the other electronic device and including first authentication data based on the secret key and the first random number; output a second response request command, which is transmitted to the other electronic device if the first response message is received after a predetermined time has elapsed after transmitting the first response request command and fewer than a predetermined maximum number of response request commands have already been transmitted to the other electronic device, the second response request command generated based on the secret key and a second random number; count a time elapsed from transmitting the second response request command; receive a second response message based on the second response request command, the second response message transmitted from the other electronic device and including second authentication data generated at the other electronic device based on the secret key and the second random number; compare the second authentication data included in the second response message with expected authentication information generated by the electronic device based on the secret key and the second random number; and determine that authentication of the other electronic device has failed when the comparison result indicates that the second authentication data and the expected authentication data do not match or when a time elapsed from transmitting the second response request command to receiving the second response message is larger than the predetermined time. establish a TCP connection with another electronic device (11, 22); generate a secret key shared between the electronic device and the other electronic device; output a first response request command, which is transmitted to the other electronic device, the first response request command generated based on the secret key and a first random number; receive a first response message based on the first response request command, the first response message transmitted from the other electronic device and including first authentication data based on the secret key and the first random number; output a second response request command, which is transmitted to the other electronic device if the first response message is received after a predetermined time has elapsed after transmitting the first response request command and fewer than a predetermined maximum number of response request commands have already been transmitted to the other electronic device, the second response request command generated based on the secret key and a second random number; count a time elapsed from transmitting the second response request command; receive a second response message based on the second response request command, the second response message transmitted from the other electronic device and including second authentication data generated at the other electronic device based on the secret key and the second random number; compare the second authentication data included in the second response message with expected authentication information generated by the electronic device based on the secret key and the second random number; and determine that authentication of the other electronic device has failed when the comparison result indicates that the second authentication data and the expected authentication data do not match or when a time elapsed from transmitting the second response request command to receiving the second response message is larger than the predetermined time.