Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "user_log.h"
12 : #include "rs_ping_inner.h"
13 :
14 3 : uint32_t RsPingGetTripTime(struct RsPingTimestamp *timestamp)
15 : {
16 3 : uint64_t localInterval = ((timestamp->tvSec4 - timestamp->tvSec1) * RS_PING_SEC_TO_USEC + timestamp->tvUsec4) -
17 3 : timestamp->tvUsec1;
18 3 : uint64_t remoteInterval = ((timestamp->tvSec3 - timestamp->tvSec2) * RS_PING_SEC_TO_USEC + timestamp->tvUsec3) -
19 3 : timestamp->tvUsec2;
20 :
21 3 : hccp_dbg("t1:{%llu, %llu} t4:{%llu, %llu} t4-t1:%llu, t2:{%llu, %llu} t3:{%llu, %llu} t3-t2:%llu, rtt:%u",
22 : timestamp->tvSec1, timestamp->tvUsec1, timestamp->tvSec4, timestamp->tvUsec4, localInterval, timestamp->tvSec2,
23 : timestamp->tvUsec2, timestamp->tvSec3, timestamp->tvUsec3, remoteInterval,
24 : (uint32_t)(localInterval - remoteInterval));
25 :
26 3 : return (uint32_t)(localInterval - remoteInterval);
27 : }
|