summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/examples/stl_ipv6_tools.py
blob: 6a652795dd8a8cb1becb9ed01d352f54feeee6f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/python
import stl_path
from trex_stl_lib.api import *
import sys

'''
Simple script that demonstrates:
1) Automatic discovery of IPv6 nodes
2) Ping first node in the list
'''

c = STLClient(verbose_level = LoggerApi.VERBOSE_REGULAR_SYNC)
c.connect()
c.reset()
c.set_service_mode()

results = c.scan6(ports = [0], timeout = 2, verbose = True)[0]

if not results:
    print('No devices found.')
    sys.exit(0)

# Setting default destination to MAC of first result and ping it

c.set_l2_mode(port = 0, dst_mac = results[0]['mac'])

c.ping_ip(src_port = 0, dst_ip = results[0]['ipv6'])


print('\nDone.\n')