tmf.core: Introduce TmfTimestamp factory methods
[deliverable/tracecompass.git] / pcap / org.eclipse.tracecompass.tmf.pcap.core / src / org / eclipse / tracecompass / internal / tmf / pcap / core / event / TmfPacketStream.java
CommitLineData
b6eb4dce
VP
1/*******************************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
12
2bdf0193 13package org.eclipse.tracecompass.internal.tmf.pcap.core.event;
b6eb4dce 14
71f2817f 15import org.eclipse.tracecompass.internal.pcap.core.stream.PacketStream;
2bdf0193
AM
16import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
17import org.eclipse.tracecompass.internal.tmf.pcap.core.util.ProtocolConversion;
18import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
19import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
b6eb4dce
VP
20
21/**
22 * Class that wraps a Packet Stream.
23 *
24 * @author Vincent Perot
25 */
26public class TmfPacketStream {
27
28 private final PacketStream fPacketStream;
29
30 /**
31 * Class constructor.
32 *
33 * @param stream
34 * The stream to build the TmfPacketStream from.
35 */
36 public TmfPacketStream(PacketStream stream) {
37 fPacketStream = stream;
38 }
39
40 /**
41 * Method that returns the first endpoint of the packet stream.
42 *
43 * @return The first endpoint.
44 */
45 public String getFirstEndpoint() {
46 return fPacketStream.getEndpointPair().getFirstEndpoint().toString();
47 }
48
49 /**
50 * Method that returns the second endpoint of the packet stream.
51 *
52 * @return The second endpoint.
53 */
54 public String getSecondEndpoint() {
55 return fPacketStream.getEndpointPair().getSecondEndpoint().toString();
56 }
57
58 /**
59 * Method that returns the ID of the packet stream.
60 *
61 * @return The ID of the packet stream.
62 */
63 public int getID() {
64 return fPacketStream.getID();
65 }
66
67 /**
68 * Method that returns the TmfProtocol of the packet stream.
69 *
70 * @return The TmfProtocol of the packet stream.
71 */
c88feda9 72 public TmfPcapProtocol getProtocol() {
b6eb4dce
VP
73 return ProtocolConversion.wrap(fPacketStream.getProtocol());
74 }
75
76 /**
77 * Get the number of packets going from the first endpoint to the second.
78 *
79 * @return The number of packets from A to B.
80 */
81 public synchronized long getNbPacketsAtoB() {
82 return fPacketStream.getNbPacketsAtoB();
83 }
84
85 /**
86 * Get the number of packets going from the second endpoint to the first.
87 *
88 * @return The number of packets from B to A.
89 */
90 public synchronized long getNbPacketsBtoA() {
91 return fPacketStream.getNbPacketsBtoA();
92 }
93
94 /**
95 * Get the total number of packets in this stream.
96 *
97 * @return The total number of packets.
98 */
99 public synchronized long getNbPackets() {
100 return fPacketStream.getNbPackets();
101 }
102
103 /**
104 * Get the number of bytes going from the first endpoint to the second.
105 *
106 * @return The number of bytes from A to B.
107 */
108 public synchronized long getNbBytesAtoB() {
109 return fPacketStream.getNbBytesAtoB();
110 }
111
112 /**
113 * Get the number of bytes going from the second endpoint to the first.
114 *
115 * @return The number of bytes from B to A.
116 */
117 public synchronized long getNbBytesBtoA() {
118 return fPacketStream.getNbBytesBtoA();
119 }
120
121 /**
122 * Get the total number of bytes in this stream.
123 *
124 * @return The total number of bytes.
125 */
126 public synchronized long getNbBytes() {
127 return fPacketStream.getNbBytes();
128 }
129
130 /**
131 * Get the start time of this stream.
132 *
133 * @return The start time.
134 */
135 public synchronized ITmfTimestamp getStartTime() {
b2c971ec 136 return TmfTimestamp.fromNanos(fPacketStream.getStartTime());
b6eb4dce
VP
137 }
138
139 /**
140 * Get the stop time of this stream.
141 *
142 * @return The stop time.
143 */
144 public synchronized ITmfTimestamp getStopTime() {
b2c971ec 145 return TmfTimestamp.fromNanos(fPacketStream.getStopTime());
b6eb4dce
VP
146 }
147
148 /**
149 * Get the duration of this stream, in seconds
150 *
151 * @return The duration of this stream.
152 */
153 public synchronized double getDuration() {
154 return fPacketStream.getDuration();
155 }
156
157 /**
158 * Get the the average byte per second from A to B.
159 *
160 * @return the average byte per second from A to B.
161 */
162 public synchronized double getBPSAtoB() {
163 return fPacketStream.getBPSAtoB();
164 }
165
166 /**
167 * Get the the average byte per second from B to A.
168 *
169 * @return the average byte per second from B to A.
170 */
171 public synchronized double getBPSBtoA() {
172 return fPacketStream.getBPSBtoA();
173 }
174
175}
This page took 0.069004 seconds and 5 git commands to generate.