A method for determining the distance between a first device and a second device via ultra-wideband communication comprising: transmitting a first beacon message from the first device to the second device, wherein a hardware interrupt for recording its time of transmission as a first time stamp (T 1) is triggered at the first device, and a hardware interrupt for recording its time of receipt as a second time stamp (T 2) is triggered at the second device, transmitting a second beacon message, in response to the first beacon message, from the second device to the first device, wherein a hardware interrupt for recording its time of transmission as a third time stamp (T 3) is triggered at the second device, and a hardware interrupt for recording its time of receipt as a fourth time stamp (T 4) is triggered at the first device, transmitting a third beacon message, in response to the second beacon message, from the first device to the second device, wherein a hardware interrupt for recording its time of transmission as a fifth time stamp (T 5) is triggered at the first device, and a hardware interrupt for recording its time of receipt as a sixth time stamp (T 6) is triggered at the second device, wherein the third beacon message comprises the first time stamp (T 1) and the fourth time stamp (T 4), transmitting a fourth beacon message, after the third beacon message, from the first device to the second device, wherein the fourth beacon message comprises the fifth time stamp (T 5), deriving an estimate of a time of flight between the first device and the second device based on the first to sixth timestamps (T 1 T 2, T 3, T 4, T 5, T 6) at the second device, obtaining the time of flight between the first device and the second device as the time of flight estimate derived for a set of beacon messages when a respective first, second and third beacon message is transmitted between the first device and the second device, or obtaining the time of flight between the first device and the second device as a mean value of the time of flight estimates derived for sets of beacon messages when respective multiple first, second and third beacon messages are transmitted between the first device and the second device, and obtaining a distance between the first device and the second device based on the obtained time of flight between the first device and the second device. transmitting a first beacon message from the first device to the second device, wherein a hardware interrupt for recording its time of transmission as a first time stamp (T 1) is triggered at the first device, and a hardware interrupt for recording its time of receipt as a second time stamp (T 2) is triggered at the second device, transmitting a second beacon message, in response to the first beacon message, from the second device to the first device, wherein a hardware interrupt for recording its time of transmission as a third time stamp (T 3) is triggered at the second device, and a hardware interrupt for recording its time of receipt as a fourth time stamp (T 4) is triggered at the first device, transmitting a third beacon message, in response to the second beacon message, from the first device to the second device, wherein a hardware interrupt for recording its time of transmission as a fifth time stamp (T 5) is triggered at the first device, and a hardware interrupt for recording its time of receipt as a sixth time stamp (T 6) is triggered at the second device, wherein the third beacon message comprises the first time stamp (T 1) and the fourth time stamp (T 4), transmitting a fourth beacon message, after the third beacon message, from the first device to the second device, wherein the fourth beacon message comprises the fifth time stamp (T 5), deriving an estimate of a time of flight between the first device and the second device based on the first to sixth timestamps (T 1 T 2, T 3, T 4, T 5, T 6) at the second device, obtaining the time of flight between the first device and the second device as the time of flight estimate derived for a set of beacon messages when a respective first, second and third beacon message is transmitted between the first device and the second device, or obtaining the time of flight between the first device and the second device as a mean value of the time of flight estimates derived for sets of beacon messages when respective multiple first, second and third beacon messages are transmitted between the first device and the second device, and obtaining a distance between the first device and the second device based on the obtained time of flight between the first device and the second device.