Search in sources :

Example 1 with TmfPacketStreamBuilder

use of org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder in project tracecompass by tracecompass.

the class StreamListAnalysisTest method executeAnalysisTest.

/**
 * Method that execute the analysis and verify the results.
 *
 * @throws TmfAnalysisException
 *             Thrown when an analysis error occurs during the setup or
 *             execution. Fails the test.
 * @throws TmfTraceException
 *             Thrown when the trace cannot be initialized. Fails the test.
 */
@Test
public void executeAnalysisTest() throws TmfAnalysisException, TmfTraceException {
    PcapTestTrace trace = PcapTestTrace.MOSTLY_TCP;
    assumeTrue(trace.exists());
    String path = trace.getPath().toString();
    PcapTrace pcapTrace = new PcapTrace();
    StreamListAnalysis analysis = new StreamListAnalysis();
    pcapTrace.initTrace(null, path, null);
    analysis.setId(StreamListAnalysis.ID);
    analysis.setTrace(pcapTrace);
    analysis.schedule();
    analysis.waitForCompletion();
    // Verify that builders are not empty.
    TmfPacketStreamBuilder builder = analysis.getBuilder(TmfPcapProtocol.ETHERNET_II);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(1, builder.getNbStreams());
    builder = analysis.getBuilder(TmfPcapProtocol.IPV4);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(3, builder.getNbStreams());
    builder = analysis.getBuilder(TmfPcapProtocol.TCP);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(2, builder.getNbStreams());
    builder = analysis.getBuilder(TmfPcapProtocol.UDP);
    if (builder == null) {
        fail("The PacketStreamBuilder is null!");
        return;
    }
    assertEquals(1, builder.getNbStreams());
    analysis.dispose();
    pcapTrace.dispose();
}
Also used : PcapTrace(org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace) TmfPacketStreamBuilder(org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) PcapTestTrace(org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace) Test(org.junit.Test)

Example 2 with TmfPacketStreamBuilder

use of org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder in project tracecompass by tracecompass.

the class StreamListView method updateUI.

private void updateUI() {
    final Display display = Display.getDefault();
    if (display == null || display.isDisposed()) {
        return;
    }
    display.asyncExec(() -> {
        if (display.isDisposed()) {
            return;
        }
        ITmfTrace trace = fCurrentTrace;
        if (trace == null) {
            return;
        }
        StreamListAnalysis analysis = TmfTraceUtils.getAnalysisModuleOfClass(trace, StreamListAnalysis.class, StreamListAnalysis.ID);
        if (analysis == null) {
            return;
        }
        Map<TmfPcapProtocol, Table> tables = fTableMap;
        if (tables == null) {
            return;
        }
        for (Entry<TmfPcapProtocol, Table> protocolEntry : tables.entrySet()) {
            TmfPcapProtocol protocol = protocolEntry.getKey();
            TmfPacketStreamBuilder builder = analysis.getBuilder(protocol);
            Table table = protocolEntry.getValue();
            if (builder != null && !(table.isDisposed())) {
                for (TmfPacketStream stream : builder.getStreams()) {
                    TableItem item;
                    if (stream.getID() < table.getItemCount()) {
                        item = table.getItem(stream.getID());
                    } else {
                        item = new TableItem(table, SWT.NONE);
                    }
                    item.setText(0, String.valueOf(stream.getID()));
                    item.setText(1, stream.getFirstEndpoint().toString());
                    item.setText(2, stream.getSecondEndpoint().toString());
                    item.setText(3, String.valueOf(stream.getNbPackets()));
                    item.setText(4, String.valueOf(stream.getNbBytes()));
                    item.setText(5, String.valueOf(stream.getNbPacketsAtoB()));
                    item.setText(6, String.valueOf(stream.getNbBytesAtoB()));
                    item.setText(7, String.valueOf(stream.getNbPacketsBtoA()));
                    item.setText(8, String.valueOf(stream.getNbBytesBtoA()));
                    item.setText(9, stream.getStartTime().toString());
                    item.setText(10, stream.getStopTime().toString());
                    // $NON-NLS-1$
                    item.setText(11, String.format("%.3f", stream.getDuration()));
                    // $NON-NLS-1$
                    item.setText(12, String.format("%.3f", stream.getBPSAtoB()));
                    // $NON-NLS-1$
                    item.setText(13, String.format("%.3f", stream.getBPSBtoA()));
                    item.setData(KEY_STREAM, stream);
                }
            }
        }
    });
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) Table(org.eclipse.swt.widgets.Table) TmfPcapProtocol(org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol) TmfPacketStreamBuilder(org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder) TmfPacketStream(org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStream) TableItem(org.eclipse.swt.widgets.TableItem) StreamListAnalysis(org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis) Display(org.eclipse.swt.widgets.Display)

Aggregations

StreamListAnalysis (org.eclipse.tracecompass.internal.tmf.pcap.core.analysis.StreamListAnalysis)2 TmfPacketStreamBuilder (org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStreamBuilder)2 Display (org.eclipse.swt.widgets.Display)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1 TmfPacketStream (org.eclipse.tracecompass.internal.tmf.pcap.core.event.TmfPacketStream)1 TmfPcapProtocol (org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol)1 PcapTrace (org.eclipse.tracecompass.internal.tmf.pcap.core.trace.PcapTrace)1 PcapTestTrace (org.eclipse.tracecompass.pcap.core.tests.shared.PcapTestTrace)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 Test (org.junit.Test)1