blob: fe3bc37555e76fc59693c86c763f72acf078a490 [file] [log] [blame]
Prashanth Kattie31542b2022-02-21 05:08:10 -06001*** Settings ***
Prashanth Kattie31542b2022-02-21 05:08:10 -06002Documentation Network security utility file.
3
4Resource ../lib/resource.robot
5Resource ../lib/bmc_redfish_resource.robot
6
George Keishing8f5ec912022-04-05 11:24:48 -05007*** Keywords ***
8
Prashanth Kattie31542b2022-02-21 05:08:10 -06009Send Network Packets And Get Packet Loss
Prashanth Katti1da88262022-02-21 05:09:45 -060010 [Documentation] Send TCP, UDP or ICMP packets to any network device and return packet loss.
Prashanth Kattie31542b2022-02-21 05:08:10 -060011 [Arguments] ${host} ${num}=${count} ${packet_type}=${ICMP_PACKETS}
12 ... ${port}=80 ${icmp_type}=${ICMP_ECHO_REQUEST}
13
14 # Description of argument(s):
15 # host The host name or IP address of the target system.
16 # packet_type The type of packets to be sent ("tcp, "udp", "icmp").
17 # port Network port.
18 # icmp_type Type of ICMP packets (e.g. 8, 13, 17, etc.).
19 # num Number of packets to be sent.
20
21 # This keyword expects host, port, type and number of packets to be sent
22 # and rate at which packets to be sent, should be given in command line.
23 # By default it sends 4 ICMP echo request packets at 1 packets/second.
24
25 ${cmd_suffix}= Set Variable If '${packet_type}' == 'icmp'
26 ... --icmp-type ${icmp_type}
27 ... -p ${port}
28 ${cmd_buf}= Set Variable --delay ${delay} ${host} -c ${num} --${packet_type} ${cmd_suffix}
29
30 ${nping_result}= Nping ${cmd_buf}
31 [Return] ${nping_result['percent_lost']}
32
33
34Send Network Packets With Flags And Verify Stability
35 [Documentation] Send TCP with flags to the target.
36 [Arguments] ${host} ${num}=${count} ${port}=${REDFISH_INTERFACE}
37 ... ${flags}=${SYN_PACKETS}
38 [Teardown] Verify Interface Stability ${port}
39
40 # Description of argument(s):
41 # host The host name or IP address of the target system.
42 # packet_type The type of packets to be sent ("tcp, "udp", "icmp").
43 # port Network port.
44 # flags Type of flag to be set (e.g. SYN, ACK, RST, FIN, ALL).
45 # num Number of packets to be sent.
46
47 # This keyword expects host, port, type and number of packets to be sent
48 # and rate at which packets to be sent, should be given in command line.
49 # By default it sends 4 ICMP echo request packets at 1 packets/second.
50
51 ${cmd_suffix}= Catenate -p ${port} --flags ${flags}
52 ${cmd_buf}= Set Variable --delay ${delay} ${host} -c ${num} --${packet_type} ${cmd_suffix}
53
54 ${nping_result}= Nping ${cmd_buf}
55 Log To Console Packets lost: ${nping_result['percent_lost']}