diff options
author | Vincent Lucas <chenzo@jitsi.org> | 2012-06-12 16:16:39 +0000 |
---|---|---|
committer | Vincent Lucas <chenzo@jitsi.org> | 2012-06-12 16:16:39 +0000 |
commit | ba0e82158d7b8cf780941ef2b36a3dd7f4172287 (patch) | |
tree | 1f854a647c51b8fb40e52ecce1ad4652fda2248e /src/net/java | |
parent | b16d2cc46a4397204a4a41cdc1e10b205f540e67 (diff) | |
download | jitsi-ba0e82158d7b8cf780941ef2b36a3dd7f4172287.zip jitsi-ba0e82158d7b8cf780941ef2b36a3dd7f4172287.tar.gz jitsi-ba0e82158d7b8cf780941ef2b36a3dd7f4172287.tar.bz2 |
Corrects RTP adresses logged in pcap file by JingleNodes socket. Updates ice4j library to revision #306: Corrects RTP adresses logged in pcap file. Adds an informational log when the RTP loss rate is > 5% (at most an entry each 5 seconds).
Diffstat (limited to 'src/net/java')
5 files changed, 94 insertions, 23 deletions
diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPInputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPInputStream.java index 31556a2..7b4750f 100644 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPInputStream.java +++ b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPInputStream.java @@ -11,6 +11,7 @@ import java.net.*; import net.java.sip.communicator.service.packetlogging.*; import net.java.sip.communicator.util.*; +import org.ice4j.socket.*; /** * RTPConnectorInputStream implementation for TCP protocol. @@ -86,6 +87,11 @@ public class RTPConnectorTCPInputStream if(socket.getLocalAddress() == null) return; + // Do not log the packet if this one has been processed (and already + // logged) by the ice4j stack. + if(socket instanceof MultiplexingSocket) + return; + PacketLoggingService packetLogging = NeomediaActivator.getPacketLogging(); diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPOutputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPOutputStream.java index 590da6f..c4e2819 100644 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPOutputStream.java +++ b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorTCPOutputStream.java @@ -10,6 +10,7 @@ import java.io.*; import java.net.*; import net.java.sip.communicator.service.packetlogging.*; +import org.ice4j.socket.*; /** * RTPConnectorOutputStream implementation for TCP protocol. @@ -62,6 +63,11 @@ public class RTPConnectorTCPOutputStream */ protected void doLogPacket(RawPacket packet, InetSocketAddress target) { + // Do not log the packet if this one has been processed (and already + // logged) by the ice4j stack. + if(socket instanceof MultiplexingSocket) + return; + PacketLoggingService packetLogging = NeomediaActivator.getPacketLogging(); diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPInputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPInputStream.java index 3ca3888..4cef9e3 100644 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPInputStream.java +++ b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPInputStream.java @@ -10,6 +10,7 @@ import java.io.*; import java.net.*; import net.java.sip.communicator.service.packetlogging.*; +import org.ice4j.socket.*; /** * RTPConnectorInputStream implementation for UDP protocol. @@ -70,6 +71,11 @@ public class RTPConnectorUDPInputStream if(socket.getLocalAddress() == null) return; + // Do not log the packet if this one has been processed (and already + // logged) by the ice4j stack. + if(socket instanceof MultiplexingDatagramSocket) + return; + PacketLoggingService packetLogging = NeomediaActivator.getPacketLogging(); diff --git a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPOutputStream.java b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPOutputStream.java index 6192f3f..de2b00e 100644 --- a/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPOutputStream.java +++ b/src/net/java/sip/communicator/impl/neomedia/RTPConnectorUDPOutputStream.java @@ -10,6 +10,7 @@ import java.io.*; import java.net.*; import net.java.sip.communicator.service.packetlogging.*; +import org.ice4j.socket.*; /** * RTPConnectorOutputStream implementation for UDP protocol. @@ -65,6 +66,11 @@ public class RTPConnectorUDPOutputStream */ protected void doLogPacket(RawPacket packet, InetSocketAddress target) { + // Do not log the packet if this one has been processed (and already + // logged) by the ice4j stack. + if(socket instanceof MultiplexingDatagramSocket) + return; + PacketLoggingService packetLogging = NeomediaActivator.getPacketLogging(); diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesCandidateDatagramSocket.java b/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesCandidateDatagramSocket.java index 54b6ba6..4d88eca 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesCandidateDatagramSocket.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/JingleNodesCandidateDatagramSocket.java @@ -11,6 +11,7 @@ import java.net.*; import org.ice4j.*; import org.ice4j.stack.*; +import org.ice4j.socket.*; /** * Represents an application-purposed (as opposed to an ICE-specific) @@ -32,6 +33,31 @@ public class JingleNodesCandidateDatagramSocket extends DatagramSocket private JingleNodesCandidate jingleNodesCandidate; /** + * The number of RTP packets received for this socket. + */ + private long nbReceivedRtpPackets = 0; + + /** + * The number of RTP packets sent for this socket. + */ + private long nbSentRtpPackets = 0; + + /** + * The number of RTP packets lost (not received) for this socket. + */ + private long nbLostRtpPackets = 0; + + /** + * The last RTP sequence number received for this socket. + */ + private long lastRtpSequenceNumber = -1; + + /** + * The last time an information about packet lost has been logged. + */ + private long lastLostPacketLogTime = 0; + + /** * Initializes a new <tt>JingleNodesdCandidateDatagramSocket</tt> instance * which is to be the <tt>socket</tt> of a specific * <tt>JingleNodesCandidate</tt>. @@ -82,19 +108,15 @@ public class JingleNodesCandidateDatagramSocket extends DatagramSocket //XXX reuse an existing DatagramPacket ? super.send(packet); - // no exception packet is successfully sent, log it - if(StunStack.isPacketLoggerEnabled()) - { - StunStack.getPacketLogger().logPacket( - super.getLocalAddress().getAddress(), - super.getLocalPort(), - packet.getAddress().getAddress(), - packet.getPort(), - packet.getData(), - true); - } + // no exception packet is successfully sent, log it. + ++nbSentRtpPackets; + DelegatingDatagramSocket.logPacketToPcap( + packet, + this.nbSentRtpPackets, + true, + super.getLocalAddress(), + super.getLocalPort()); } - /** * Receives a <tt>DatagramPacket</tt> from this socket. The DatagramSocket @@ -110,17 +132,16 @@ public class JingleNodesCandidateDatagramSocket extends DatagramSocket { super.receive(p); - // no exception packet is successfully received, log it - if(StunStack.isPacketLoggerEnabled()) - { - StunStack.getPacketLogger().logPacket( - p.getAddress().getAddress(), - p.getPort(), - super.getLocalAddress().getAddress(), - super.getLocalPort(), - p.getData(), - false); - } + // no exception packet is successfully received, log it. + ++nbReceivedRtpPackets; + DelegatingDatagramSocket.logPacketToPcap( + p, + this.nbReceivedRtpPackets, + false, + super.getLocalAddress(), + super.getLocalPort()); + // Log RTP losses if > 5%. + updateRtpLosses(p); } /** @@ -178,4 +199,30 @@ public class JingleNodesCandidateDatagramSocket extends DatagramSocket { return jingleNodesCandidate.getTransportAddress(); } + + /** + * Updates and Logs information about RTP losses if there is more then 5% of + * RTP packet lost (at most every 5 seconds). + * + * @param p The last packet received. + */ + public void updateRtpLosses(DatagramPacket p) + { + // If this is not a STUN/TURN packet, then this is a RTP packet. + if(!StunDatagramPacketFilter.isStunPacket(p)) + { + long newSeq = DelegatingDatagramSocket.getRtpSequenceNumber(p); + if(this.lastRtpSequenceNumber != -1) + { + nbLostRtpPackets += DelegatingDatagramSocket + .getNbLost(this.lastRtpSequenceNumber, newSeq); + } + this.lastRtpSequenceNumber = newSeq; + + this.lastLostPacketLogTime = DelegatingDatagramSocket.logRtpLosses( + this.nbLostRtpPackets, + this.nbReceivedRtpPackets, + this.lastLostPacketLogTime); + } + } } |