API to get port MAC address

79 views
Skip to first unread message

abhilash vellidandi

unread,
Apr 19, 2018, 12:30:05 AM4/19/18
to TRex Traffic Generator
Hi,

In my testing I am using multiple IP address for a single port, for this I am creating a stream to send GARP messages for each IP periodically. Currently I am manually fetching the MAC Address and updating in the packet details, is there any API we can use to get the MAC adress of the ports without needing to update them manually in case the port that is being used changes.

Below is the snipped from my script:

    garp_base_pkt = Ether(src="ec:9e:cd:19:13:95",dst="ff:ff:ff:ff:ff:ff")/ARP(hwsrc="ec:9e:cd:19:13:95",hwdst="ec:9e:cd:19:13:95")
    port0_range = {'src': {'start': "1.1.1.1", 'end': "1.1.1.17"}, 'vlan': {'start': 2222, 'end': 2222}}
    ip = port0_range['src']
    vlan = port0_range['vlan']
    garpvm = [ STLVmFlowVar(name="ip", min_value=ip['start'], max_value=ip['end'], size=4, step=4, op="inc"),
               STLVmWrFlowVar(fv_name="ip", pkt_offset="ARP.psrc"),
               STLVmWrFlowVar(fv_name="ip", pkt_offset="ARP.pdst"),
             ]
    garp_pkt = STLPktBuilder(garp_base_pkt, vm = garpvm)
    garp = STLStream(packet = garp_pkt, mode = STLTXCont(pps = 1))
    c.add_streams(garp, ports = 0)



Thanks in advance for your support.

Thanks and Regards,
Abhilash

abhilash vellidandi

unread,
Apr 24, 2018, 5:37:35 AM4/24/18
to TRex Traffic Generator

Hi,

Could you please let me know if this is possible?

Thanks and Regards,
Abhilash

Yaroslav Brustinov

unread,
Apr 24, 2018, 6:39:05 AM4/24/18
to abhilash vellidandi, TRex Traffic Generator
Hi,

If you will not use "src" in Ether class, upon sending of stream TRex will put MAC address of interface.

If you insist to put the MAC address yourself, you can query the port:
c.ports[port_id].get_ts_attr()['layer_cfg']['ether']['src']

Thanks,
Yaroslav.

--
You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trex-tgn+unsubscribe@googlegroups.com.
To post to this group, send email to trex...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/trex-tgn/3562a263-b9fd-4e36-ba57-ffae435dc378%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages