1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.tmf
.pcap
.core
.event
;
15 import org
.eclipse
.linuxtools
.internal
.pcap
.core
.stream
.PacketStream
;
16 import org
.eclipse
.tracecompass
.internal
.tmf
.pcap
.core
.protocol
.TmfPcapProtocol
;
17 import org
.eclipse
.tracecompass
.internal
.tmf
.pcap
.core
.util
.ProtocolConversion
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.ITmfTimestamp
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestamp
;
22 * Class that wraps a Packet Stream.
24 * @author Vincent Perot
26 public class TmfPacketStream
{
28 private final PacketStream fPacketStream
;
34 * The stream to build the TmfPacketStream from.
36 public TmfPacketStream(PacketStream stream
) {
37 fPacketStream
= stream
;
41 * Method that returns the first endpoint of the packet stream.
43 * @return The first endpoint.
45 public String
getFirstEndpoint() {
46 return fPacketStream
.getEndpointPair().getFirstEndpoint().toString();
50 * Method that returns the second endpoint of the packet stream.
52 * @return The second endpoint.
54 public String
getSecondEndpoint() {
55 return fPacketStream
.getEndpointPair().getSecondEndpoint().toString();
59 * Method that returns the ID of the packet stream.
61 * @return The ID of the packet stream.
64 return fPacketStream
.getID();
68 * Method that returns the TmfProtocol of the packet stream.
70 * @return The TmfProtocol of the packet stream.
72 public TmfPcapProtocol
getProtocol() {
73 return ProtocolConversion
.wrap(fPacketStream
.getProtocol());
77 * Get the number of packets going from the first endpoint to the second.
79 * @return The number of packets from A to B.
81 public synchronized long getNbPacketsAtoB() {
82 return fPacketStream
.getNbPacketsAtoB();
86 * Get the number of packets going from the second endpoint to the first.
88 * @return The number of packets from B to A.
90 public synchronized long getNbPacketsBtoA() {
91 return fPacketStream
.getNbPacketsBtoA();
95 * Get the total number of packets in this stream.
97 * @return The total number of packets.
99 public synchronized long getNbPackets() {
100 return fPacketStream
.getNbPackets();
104 * Get the number of bytes going from the first endpoint to the second.
106 * @return The number of bytes from A to B.
108 public synchronized long getNbBytesAtoB() {
109 return fPacketStream
.getNbBytesAtoB();
113 * Get the number of bytes going from the second endpoint to the first.
115 * @return The number of bytes from B to A.
117 public synchronized long getNbBytesBtoA() {
118 return fPacketStream
.getNbBytesBtoA();
122 * Get the total number of bytes in this stream.
124 * @return The total number of bytes.
126 public synchronized long getNbBytes() {
127 return fPacketStream
.getNbBytes();
131 * Get the start time of this stream.
133 * @return The start time.
135 public synchronized ITmfTimestamp
getStartTime() {
136 return new TmfTimestamp(fPacketStream
.getStartTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
140 * Get the stop time of this stream.
142 * @return The stop time.
144 public synchronized ITmfTimestamp
getStopTime() {
145 return new TmfTimestamp(fPacketStream
.getStopTime(), ITmfTimestamp
.NANOSECOND_SCALE
);
149 * Get the duration of this stream, in seconds
151 * @return The duration of this stream.
153 public synchronized double getDuration() {
154 return fPacketStream
.getDuration();
158 * Get the the average byte per second from A to B.
160 * @return the average byte per second from A to B.
162 public synchronized double getBPSAtoB() {
163 return fPacketStream
.getBPSAtoB();
167 * Get the the average byte per second from B to A.
169 * @return the average byte per second from B to A.
171 public synchronized double getBPSBtoA() {
172 return fPacketStream
.getBPSBtoA();