EthernetTransmitter

class mtf.network_port.bus_transmitter.EthernetTransmitter

This class implements functionality to transmit Ethernet payloads.

transmitter = <mtf.libs.mtf_pybinder.mtf_ethernet_transmitter object>
lock = <unlocked _thread.lock object>
classmethod transmit_frame(channel_name: str, payload: List)

Transmits the given payload over the given Ethernet channel.

Args:

channel_name (str): The name of the Ethernet channel to transmit the payload over. payload (FramePayload): The Ethernet packet to transmit.

Returns:

bool: True on success; False otherwise.

classmethod transmit_frame_queue(channel_name: str, timestamped_queue: List[tuple[int, List[int]]])

Transmits queue of packets with respect to the delays between successive message.

Args:

channel_name (str): The name of the Ethernet channel to transmit the frame over. timestamped_queue (List[tuple[int, List[int]]]): Each tuple contains:

  • First element: The delay between the previous message and the current message in nanoseconds.

  • Second element: The payload to be sent.

Examples:

transmit_frame_queue
from mtf.mtf_base import MtfBase

# Here the delta time between the first message and the second one is 4seconds 
# and the delta time between the second frame and the third one is 1second.
MtfBase.bus_manager.bus_transmitter(BusType.ETHERNET).transmit_frame_queue("ethernet_channel_name", [(0,[1,2,3]), (4000000000,[3,2,1]), ,(1000000000,payload)])

Note:

Warning

This method is deprecated. Please use configure_frame_queue and start_frame_queue instead.

classmethod configure_frame_queue(channel_name: str, timestamped_queue: List[tuple[int, List[int]]])

Configures a packet queue on the given Ethernet channel.

Args:

channel_name (str): The name of the Ethernet channel to be configured. timestamped_queue (list[tuple(int,list[int])]): Each tuple contains:

  • First element: The delay between the previous message and the current message in nanoseconds.

  • Second element: The payload to be sent.

Returns:

bool: True if the queue transmission is configured; False otherwise.

Examples:

configure_frame_queue
from mtf.mtf_base import MtfBase

MtfBase.bus_manager.bus_transmitter(BusType.ETHERNET).configure_frame_queue("ethernet_channel_name", [(0,[1,2,3]), (2,[1,2,3]) .....])
classmethod start_frame_queue(channel_name: str)

Starts transmitting the packet queue on the given Ethernet channel.

Args:

channel_name (str): The channel name to start the transmission over.

Returns:

bool: True on success; False otherwise.

Note:

Important

The packet queue to be transmitted must have been configured in advance.

classmethod send_ethernet_packet(channel_name: str, packet: Packet)

Transmits the given PCPP packet.

Args:

channel_name (str): The channel name to transmit over. packet (pcpp.Packet): The PCPP packet to transmit.

Returns:

bool: True on success; False otherwise.

Examples:

send_ethernet_packet
from mtf.libs.mtf_pybinder.pcpp import RawPacket, Packet
import numpy as np
from mtf.mtf_base import MtfBase

payload = [
    0x04, 0xEC, 0xD8, 0xCC, 0xA0, 0x92, 0xAC, 0x71, 0x2E, 0x41, 0x6F, 0x03,
    0x08, 0x00, 0x45, 0x00, 0x00, 0x43, 0xF7, 0x56, 0x40, 0x00, 0x6C, 0x11,
    0x58, 0x6B, 0x28, 0x63, 0xDC, 0xA2, 0xAC, 0x10, 0x0D, 0xD2, 0x01, 0xBB,
    0xFF, 0xA1, 0x00, 0x2F, 0xF2, 0x40, 0x4A, 0xA8, 0x26, 0x18, 0xAF, 0xFF,
    0x3D, 0xF4, 0x09, 0xAA, 0x5B, 0x16, 0xD9, 0xE1, 0xC7, 0xF5, 0x09, 0x2A,
    0xE8, 0xA9, 0x93, 0xD5, 0xE9, 0x44, 0x7A, 0xED, 0xC7, 0xDB, 0x37, 0x9E,
    0xEC, 0x97, 0xC3, 0x81, 0xA3, 0x61, 0xA6, 0xEC, 0x04,
]
udp_packet = np.array(payload,dtype=np.uint8)
rp = RawPacket(udp_packet)
my_packet = Packet(rp)
MtfBase.bus_manager.bus_transmitter(BusType.ETHERNET).send_ethernet_packet("ethernet_channel_name", my_packet)