int dcmi_set_traceroute (int card_id, int device_id, struct traceroute param_info, struct node_info *ret_info[], unsigned int ret_info_size)
Description
Configures traceroute parameters to detect the network nodes where the packets pass through.
Parameter Description
Parameter
Input/Output
Type
Description
card_id
Input
int
Device ID. The supported IDs can be obtained by calling dcmi_get_card_list.
device_id
Input
int
Chip ID, which can be obtained by calling dcmi_get_device_id_in_card. Value range:
NPU: [0, device_id_max – 1]
NOTE:
The value of device_id_max is 1. When device_id is 0, the NPU chip is used. When device_id is 1, the MCU chip is used.
param_info
Input
struct traceroute
Input parameters of traceroute.
struct tracerout_result {
int max_ttl; // Maximum number of hops for probe packets. The values are as follows: –1, 1–255.
If this parameter is set to –1, the default value 30 is used.
int tos; // This parameter can be used to set ToS priority in IPv4. The value ranges from –1 to 63. Or set traffic control value in IPv6. The value ranges from –1 to 255. A larger value indicates a higher priority. If this parameter is set to –1, the default value 0 is used.
int waittime; // Set the maximum waiting time for a detection response. The values are as follows: –1, 1–60 (unit: s). If this parameter is set to –1, the default value 3s is used.
int sport; // Set the source port number. The value ranges from –1 to 65535. If this parameter is set to –1, a random value greater than 30000 is used by default.
int dport; // Set the destination port number. The value ranges from –1 to 65535. If this parameter is set to –1, a random value greater than 30000 is used by default.
char dest_ip[48]; // IP address of the target host
bool ipv6_flag; // Whether to use the IPv6 protocol. Value 0 indicates no, and value 1 indicates yes.
bool reset_flag; // End all background traceroute processes on the device. When an exception occurs during the traceroute test, set this parameter to 1 to end the processes on the device.
};
NOTE:
If the port number is set to 0, the system uses a random value greater than 30000.
ret_info[]
Output
struct node_info *
Returned information of traceroute
struct tracerout_result {
int mask; // Mask, indicating whether the subsequent data is valid. For example, 0xFF indicates that the eight fields after the mask are valid.
char ip[48]; // IP address of the routing node
int snt; // Number of sent ICMP request packets
double loss; // Packet loss rate of the corresponding node
double last; // Response time of the latest packet (ms)
double avg; // Average response time of all packets (ms)
double best; // Fastest packet response time (ms)
double wrst; // Slowest packet response time (ms)
double stdev; // Standard deviation. A larger value indicates a less stable node.
char reserve[64]; // Additional extended information
};
NOTE:
The returned information is stored in a structure array, with each node's information stored in a separate structure.
ret_info_size
Input
unsigned int
Size of the structure for the node information.
Return Value
Type
Description
int
Results:
Success: The value 0 is returned.
Failure: For details about the return codes, see Return Codes.
Exception Handling
To prevent the traceroute command from being suspended due to ICMP packet loss, you are advised to run the two commands for IPv4 addresses at an interval of 3 seconds.
If the command is forcibly interrupted on the host or the return value is -8020, set param_info.reset_flag to 1 and call the dcmi_set_traceroute API to end the process on the device.
After the traceroute command execution finishes, set param_info.reset_flag to 1 and call the dcmi_set_traceroute API to end the process on the device. This prevents the NPU performance from being affected by continuous process running.
If param_info.reset_flag is set to 1, other parameters do not take effect.
Restrictions
Table 1 Support in different deployment scenarios
Product Model
root User in PM (Bare Metal) Scenarios
Running User Group (Non-root User) in PM (Bare Metal) Scenarios
root User in PM + Unprivileged Container Scenarios
Atlas 900 A2 PoD cluster basic unit
Y
N
N
Atlas 800T A2 training server
Y
N
N
Atlas 800I A2 inference server
Y
N
N
Atlas 200T A2 Box16 heterogeneous subrack
Y
N
N
A200I A2 Box heterogeneous component
Y
N
N
A300I A2 inference card
N
N
N
Atlas 300T A2 training card
Y
N
N
Note: Y indicates that the function is supported, N indicates that the function is not supported, and NA indicates that the function is not involved and planned currently.
Example
...
int ret = 0;
int card_id = 0;
int device_id = 0;
struct traceroute param_info = {0};
struct node_info ret_info[10] = {0};
size_t ret_info_size = sizeof(ret_info);
param_info.sport = 40000;
param_info.waittime = 5;
strncpy_s(param_info.dest_ip, sizeof(param_info.dest_ip), "x.x.x.x", strlen("x.x.x.x"));
ret = dcmi_set_traceroute_get_info(card_id, device_id, param_info, &ret_info, ret_info_size);
if (ret != 0){
//todo: Record logs.
return ret;
}
...