def select_tx_port(tx_port_id_list, rx_port_id):
    """
    Select an IXIA port to send traffic

    Args:
        tx_port_id_list (list): IDs of ports that can send traffic
        rx_port_id (int): ID of the port that should receive traffic

    Returns:
        ID of the port to send traffic (int) or None (if we fail to find it)
    """
    if len(tx_port_id_list) == 0:
        return None

    max_tx_port_id = max(tx_port_id_list)
    if  max_tx_port_id < rx_port_id:
        return max_tx_port_id
    else:
        return min(x for x in tx_port_id_list if x > rx_port_id)