3.5.1 Traffic Monitoring Software 3.5.3 Traffic Snooping
Ethernet Networking Technology Guide  /  3 Network Simulation  /  3.5 Observing Network Traffic  / 

3.5.2 Ethernet Probe

The Ethernet probe provides a way to listen to traffic at a particular endpoint of the link, that is, the probe will receive both incoming and outgoing traffic for a particular device.

A probe is inserted using the insert-ethernet-probe command with appropriate arguments. We will use QSP-x86 as an example machine. Please start the simulation with the firststeps-no-network.simics start script:

simics> load-module eth-links
simics> new-ethernet-switch link0
Created instantiated 'ethernet_switch' component 'link0'
simics> connect link0.device0 board.mb.sb.eth_slot

# insert a probe between the PHY of the eth[0] device above and the link
simics> load-module eth-probe
simics> insert-ethernet-probe device = board.mb.sb.phy
Created probe 'probe0'
simics> probe0.info
Information about probe0 [class eth-probe]
==========================================

Connections:
    Port A : board.mb.sb.phy
    Port B : link0.link

At this point, the probe is ready to use. You can issue a <eth-probe>.pcap-dump or similar command to connect an external network monitoring tool at the probe level. The traffic will be dumped as seen from the board.mb.sb.phy device.

You can also register your own callback to listen to the traffic going-on in the probe, using the ethernet_probe interface provided by the probe object:

typedef enum {
        Eth_Probe_Port_A = 0,
        Eth_Probe_Port_B = 1
} eth_probe_side_t;

typedef void (*ethernet_probe_snoop_t)(lang_void *user_data,
                                       conf_object_t *probe,
                                       eth_probe_side_t to_side,
                                       const frags_t *frame,
                                       eth_frame_crc_status_t crc_status);

SIM_INTERFACE(ethernet_probe) {
        void (*attach_snooper)(conf_object_t *NOTNULL probe,
                               ethernet_probe_snoop_t snoop_fun,
                               lang_void *user_data);
        void (*attach_probe)(conf_object_t *NOTNULL probe,
                             ethernet_probe_snoop_t snoop_fun,
                             lang_void *user_data);
        void (*detach)(conf_object_t *NOTNULL probe);
        void (*send_frame)(conf_object_t *NOTNULL probe,
                           eth_probe_side_t to_side,
                           const frags_t *frame,
                           eth_frame_crc_status_t crc_status);
};

#define ETHERNET_PROBE_INTERFACE "ethernet_probe"

A complete description of this interface is provided in the Simics Reference Manual. What we are interested in at this point is to register a snooper callback that will only listen to traffic:

# a callback that does nothing but print a warning
simics> @def callback(user_data, probe, to_side, packet, crc_status):
            if to_side == Eth_Probe_Port_A:
                print('packet going to device')
            else:
                print('packet going to network')

........
simics> @conf.probe0.iface.ethernet_probe.attach_snooper(callback, None)
simics> c 
packet going to network
packet going to network
[...]

The probe can also drop, modify or inject packets. This is described in the Injecting Network Traffic section below.

3.5.1 Traffic Monitoring Software 3.5.3 Traffic Snooping