656 Commits

Author SHA1 Message Date
bgrozev
2586d8b2da
Port NAT harvester properties to new config (#229)
* feat: Port "nat harvester" to the new config.

* ref: Fix ktlint errors.
2021-05-26 18:01:12 +03:00
Ingo Bauersachs
3e0a9f97ef
Use ephemeral port for server socket (#228) 2021-05-03 23:21:29 +02:00
Ingo Bauersachs
f176d021f8
Replace static with random port in tests (#224) 2021-04-09 00:12:10 +02:00
Jonathan Lennox
5a299cd694
Shut down harvester thread pool when it's done. (#223)
* Shut down harvester thread pool when it's done.

* Use ExecutorService to create harvester threads; name thread pool threads to match other ice4j threads.
2021-04-08 15:51:51 -04:00
Ingo Bauersachs
34c2ce50ec
Migrate tests to JUnit 5 and release Maven Central (#221)
* Migrate test to JUnit 5 and prepare POM for Maven Central

* Use random ports for transaction tests

* Apply ktlint format

* Fix flaky tests

* Use jicoco from Maven Central

* Remove semver checks

* Add Kotlin linting check

* Use bnd-maven-plugin for OSGi to avoid confusing Kotlin

* Release to Maven Central

Closes #213
Closes #95

* Fix braces formatting that crept in with a regex
2021-01-04 21:34:02 +01:00
bgrozev
67ffceb81d
Port AWS harvester config. (#216) 2020-10-09 11:01:35 -05:00
bgrozev
3a55627ba0
ref: Port StunMappingHarvester config. (#215) 2020-09-25 11:39:13 -05:00
bgrozev
29ae8061ad
Port more config properties. (#214)
* ref: Port the "disable link-local addresses" property.

* ref: Port the receive buffer size property.

* ref: Port the "disable ipv6" property.

* ref: Port the "dynamic ports" propertty.

* ref: Port the timeout property.

* test: Add tests for the new properties.
2020-09-14 12:43:56 -05:00
bgrozev
f8a506ef70
Use metaconfig, port some properties. (#212)
* Use metaconfig, port some properties.

* ref: Use the typesource config to read system properties.

* fix: Fix a typo.

* Add tests for AgentConfig.
2020-08-24 11:36:22 -05:00
bgrozev
686164ffc4
ref: Rename variables. (#209) 2020-06-10 15:15:11 -05:00
bgrozev
ed63ae8e11
fix: Match the base when finding a local canidate for a remote address (fixes #205). (#208)
* fix: Match the base when finding a local canidate for a remote address (fixes #205).
2020-06-10 14:18:33 -05:00
bgrozev
9a580a9401
Remove unused code, fix typo and formatting (#207)
* Remove unused method.

* Fix typos and formatting.
2020-06-09 16:25:10 -05:00
Jonathan Lennox
8ffa9030f4
Log the real source port of STUN mapping requests. (#206) 2020-06-05 17:57:18 -04:00
Jonathan Lennox
7016902b21
Shut down STUN stack before removing streams from Agent. (#202)
Should fix NPEs being thrown during Agent.free().
2020-04-21 09:59:33 -04:00
Jonathan Lennox
e6e36856c6
Fix format of msgType in exception message. (#201) 2020-04-17 16:11:28 -04:00
Jonathan Lennox
e90c796d6d
Merge duplicate ICE candidate pairs. (#195)
This can happen if a remote candidate is discovered as peer-reflexive and later received over signaling.
2020-04-08 12:48:48 -04:00
Jonathan Lennox
ca3868ac26
Avoid double-nomination of ICE candidate pairs. (#198)
Nomination is blocked once something is nominated rather than waiting until something is selected.
2020-04-07 18:25:16 -04:00
Jonathan Lennox
982e78212b
Some helpers for adding an ICE nomination strategy config option. (#197)
* Add fromString method to NominationStrategy.

* Add getters for NominationStrategy.

This allows Kotlin to model Agent's nominationStrategy as a property.
2020-04-07 16:52:57 -04:00
Jonathan Lennox
35e149848e
Remove local ufrag from log messages. (#196)
Not needed now that we have logger2, which has it in the log context.
2020-04-07 16:33:35 -04:00
bgrozev
36f732ba1c
Initializes the harvesters array to non-null. (#193) 2020-04-03 14:34:06 -05:00
bgrozev
fe30fe8a31
Adds the remote address and ufrag to a log message. (#190)
* Adds the remote address and ufrag to a log message.
2020-02-26 10:28:55 -06:00
Yury Yaroshevich
7989977e1e Added Message-Integrity attribute to Role Conflict message. (#187)
* Added missing attributes to Role Conflict message.

* Updated logs and fixed comments.

* Added unit test of role conflict recovery.

* Fixed long lines.
2019-09-30 13:27:07 -07:00
bbaldino
43a9f282d2
use classes in jitsi-utils (#188)
* use queuestatistics/ratestatistcs from jitsi-utils

* remove packetqueue (exists in jitsi-utils)

* use executorfactory in jitsi-utils

* use customizablethreadfactory on jitsi-utils

* remove asyncqueuehandler (exists in jitsi-utils)
2019-09-25 08:54:06 -07:00
bbaldino
e854e4efaf
use the jitsi-utils logger (#186)
* use new logger in agent

* use new logger in component, componentsocket, icemediastream, mergingdatagramsocket

* use new logger in localcandidate

* use new logger in checklist

* use new logger in defaultnominator

* use new logger in connectivitycheckclient, connectivitycheckserver

* fix typo, allow taking in a parent logger

* use jitsi-utils

* clean up uses of old logger and remove it
2019-09-19 08:11:18 -07:00
damencho
0b052e8f85 Removes extra exception printed on initializing delegating channels. 2019-06-07 19:41:14 +01:00
Дамян Минков
c7c4719c45
Prepares for java 11. (#180)
* Prepares for java 11.

* Removes unused import.
2019-05-09 14:22:52 +01:00
Han Xu
59461c9d13 Clear system property at the end of test.
The current test is passing, but still I think it's better to clear
the system property it sets.
2019-04-24 09:44:02 +01:00
Han Xu
105a49749e Fix Retransmitter creation to take effect of originalWaitInterval config 2019-04-24 09:44:02 +01:00
Peter Sear
0ea60d85b3 Add unit tests for org.ice4j.ice.NetworkUtilsTest
These tests were written using Diffblue Cover.
2019-03-28 09:43:48 -07:00
Yury Yaroshevich
80471b751a Offload I/O from ScheduledExecutorService thread in PaceMaker. (#173)
* Offload I/O from ScheduledExecutorService thread in PaceMaker.
2019-02-13 09:08:44 +00:00
Yury Yaroshevich
5aec41fc02 Offload I/O from ScheduledExecutorService thread in Retransmitter. (#172)
* Offload I/O from ScheduledExecutorService thread in Retransmitter.

* Use single thread executor for timer.

* Use single thread for timer

* Fixed typo
2019-02-12 11:50:59 -08:00
Reker
f9a357ec17 Fix SDP Connection field generation bug (#136)
The signature of sdpFactory#createConnection is (String netType, String addrType, String addr), so IceSdpUtils always generate wrong Connection in SDP
2019-02-12 11:42:23 +00:00
Yury Yaroshevich
0be8f1aae7 Offload I/O from ScheduledExecutorService thread in StunKeepAliveRunner (#170)
* Added periodic runnable to offload I/O from ScheduledExecutorService's thread.

* Added missing class header.

* Do not invoke `getMillisecondsDelayUntilNextRun` from synchronized section.

* Use java.time.Duration to represent time interval.

* Use synchronized block in scheduleNextRun.
2019-02-11 09:37:44 -08:00
bgrozev
e87d331e57
fix: Changes the fixed thread pool in NetAccessManager to an unbounde… (#171)
* fix: Changes the fixed thread pool in NetAccessManager to an unbounded cached thread pool.
2019-02-08 19:08:08 +00:00
Yury Yaroshevich
e3e78dcda3 Fixed socket receive buffer interface misuse (#167)
* Use type with tiny interface (offer/poll/scan/isEmpty) for socket receive buffer.

* Fixed computation of total bytes stored in buffer due to misuse of iterator and addAll methods of list.

* Rename offer back to add and do not return status.

* Fixed formatting.

* Declare variables as final.

* Check if `toMove` is empty, because it can not be null with new SocketReceiveBuffer.

* Fix after rebase.
2019-01-15 14:26:33 +00:00
Yury Yaroshevich
ce42c77b82 Do not limit org.ice4j.ice.harvest.DISABLE_LINK_LOCAL_ADDRESSES to IPv6. (#156)
* Do not limit DISABLE_LINK_LOCAL_ADDRESSES to IPv6.

* Removed part about IPv6 for in comment for DISABLE_LINK_LOCAL_ADDRESSES.
2019-01-11 03:50:44 +00:00
Yury Yaroshevich
4027cf429d Use pool of datagram packets inside MultiplexingXXXSocketSupport (#168)
Use pool of datagram packets inside MultiplexingXXXSocketSupport to reduce clone() overhead.
2019-01-08 11:53:13 -06:00
Yury Yaroshevich
c56fcc3a3f Use ReadWriteLock to split receive and close execution in SafeCloseDatagramSocket. (#166)
* Use ReadWriteLock to split receive and close execution in SafeCloseDatagramSocket.

* Me into authors lists.

* Removed empty try/finally
2018-12-19 10:29:42 -08:00
Yury Yaroshevich
8b43209b8d Use notify instead of notifyAll when only one thread affected by notification. (#165) 2018-12-19 08:31:58 -08:00
Yury Yaroshevich
6beca2903c Invoke releasePacket on dropped items in PacketQueue. (#164)
* Invoke releasePacket on dropped items in PacketQueue.

* Fixed comment.

* Use Object.notify instead of Object.notifyAll in PacketQueue.doAdd

* Fixed formatting.

* Use atomic for numDroppedPackets because it is no longer under synchronized block.

* Copy number of dropped packets to local variable.
2018-12-17 09:16:16 -08:00
Yury Yaroshevich
c325421927 Do not explicitly create threads in PacketQueue (#157)
* Do not explicitly create threads in PacketQueue, but borrow threads for execution from ExecutorService.

* Added method to release created packet in PacketQueue.

* Added constructor overload to override default ExecutorService of PacketQueue.

* Fixed inconsistent formatting.

* Added throttling support to PacketQueue.

* Added performance tests for various configurations of PacketQueue.

* Updated comments.

* Added test for fixed size thread pool to compare it with ForkJoinPool.

* Fixed comments.

* Changed default values of PacketQueue configuration to closer match old implementation.

* Removed unused constants.

* Added tests to reveal introduced bug. Fixed bug.

* Fixed comments in PacketsQueue.

* Do not hard code class name in thread pool name.

* Return 0 when handler is null (should be not be reachable, but anyway).

* Added test to check capacity constraint of PacketQueue.

* Replaced manual capacity check with checking offer return value.

* Made throttler class static.

* Added test to check that PacketQueue thread is release without work.

* Do GC before running performance benchmark.

* Fixed formatting and added timeout.

* Added test to check cooperative multi-tasking behavior when executor is shared between queues and has less threads then executor has.

* Minor code rearrangement.

* Use dedicated syncronization object for sate of AsyncPacketReader.

* Stop PacketQueue when benchmark is finished.

* Added constant for number of benchmark iterations.

* Minor code style enhancements.

* Added myself to the list of authors.

* Added test to check that million of PacketQueue can share single thread without eating CPU when idle.

* Extracted AsyncQueueHandler class.

* Fixed imports.

* Minor fixes.

* Minimize diff by undoing unnecessary changes.

* Minimized diff.

* Reduce diff.

* Added constructor argument null checks.

* Removed throttling and simplified AsyncQueueHandler.

* Reviewed usage of syncronized blocks.

* Moved variable closer to usage.

* Fixed according to code review.

* Added extra constructor.

* Removed cancel from onYield because it's unnecessary after removing throttling.

* Rearranged onYield and handleQueueItemsUntilEmpty, introduced rescheduleReader

* Updated copyright.
2018-12-12 08:37:28 -08:00
Yury Yaroshevich
17b9bd9c17 Fixed socket remove condition in MergingDatagramSocket. (#159) 2018-12-10 10:30:17 -08:00
Yury Yaroshevich
ee4e8c9452 Eliminate "Stun4J Message Processor" by replacing it with thread pool. (#155)
* Use shared thread pool to execute stun messages decoding and processing. Set minimum required Java version to 1.8.

* Added missing argument comment.

* Added pooling of MessageProcessor objects to avoid extra allocations per RawMessage.

* Made MessageProcessor to be ForkJoinTask<Void> to avoid hidden allocation inside ForkJoinPool.

* Fixed comments according to last changes.

* Added dedicated method to reset state of pooled processor. More comments.

* Fixed comment typo.

* ForkJoinPool by default uses all available processors.

* Rollback JDK 8 changes in pom file since it looks they were only necessary for local build due to misconfigured IDE.

* Avoid usage of Java 8 features (lambda expressions & method references)

* Revert "Rollback JDK 8 changes in pom file since it looks they were only necessary for local build due to misconfigured IDE."

This reverts commit 840f18a554c4910f1af781aa729c58e833b0621f.

* Revert "Avoid usage of Java 8 features (lambda expressions & method references)"

This reverts commit b6ce70ebb40859be8f9249e070b6915feab59200.

* Renamed MessageProcessor into MessageProcessingTask to better reflect changed meaning of class.

* Use ForkJoinPool with prefixed threads to simplify debugging.

* Removed todo.

* Use well-known thread pool instead of ForkJoinPool. Could be easily changed back to ForkJoinPool.

* Fixed missing space.

* Fixes according to code review.

* Fixed active tasks tracking which was broken when pooling was added.

* Keep track of task processing throughput via QueueStatistics.

* Updated comment.

* Fixed comment.

* Updated comment.

* Updated comment.

* Updated comment.

* Renamed field to have better name.

* Fixed formatting.

* Restored old formatting corrupted by IDE.

* Fixed formatting.

* Fixed comment.

* Fixed comment.

* Updated comment.

* Updated log message.

* Code-style fixes to match rest of file.

* Fixed code style to match existing code.

* Fixed formatting.

* Restored accidentally removed comment.

* Added myself to list of authors.
2018-11-29 12:52:23 -08:00
Yury Yaroshevich
3239ed12fc Stun server transaction: reduce number of threads used for expiration. (#154)
* Reorder fields so final fields set in constructor come first, then mutable state of transaction.

* Rename STUN transaction lifetime field.

* Eliminate isRetransmitting field which is actually computed property from response != null

* Use monotonic clock (System.nanoTime) to check expiration. Replaced synchronized methods with atomic variables.

* Re-factored TransactionID implementation. Use less mutable state. Fixed hash function to produce random values, instead of sequentially growing values.

* Do no perform full Hashtable lookup to find transaction with specified ID.

* Use check before acquiring lock in StunStack.

* Implement ScheduledExecutorService based expired transaction collector.

* Restored self-cancel of expired server transactions collector when no server transactions at all.

* Fixed isExpire check in StunServerTransaction

* Fixed collection runnable to remove not only values but also keys from Hashtable.

* Perform elapsed check over milliseconds, not nanoseconds.

* Do not leave null values in clientTransactions/serverTransactions Hashtables when removing transaction, but leaving it's ID in Hashtable.

* Remove condition around cheap logger calls.

* Minor formatting fixes.

* Log number of non-expired transactions after collection to verity it is not growing over time.

* Fixed multi-line string formatting.

* Moved construction of ScheduledThreadPoolExecutor to helper method. Adjusted default settings of pool.

* Allow to create single threaded pool as well as bounded to number of CPUs on machine pool.

* Fixed name collision with same class in other package.

* Minor styling changes to reduce diff.

* Removed unused import.

* Do check of response when it's actually supposed to be non null.

* Add actual length to error message.

* Allow transaction ID of incorrect size.

* Allow constructing TransactionID with invalid length.

* Rollback all refactoring other than reducing thread count.

* Use default 1 minute timeout for threads in pool.

* Fixed typo in method name.
2018-11-20 14:18:51 -08:00
Yury Yaroshevich
513fb588d6 Stun client transaction re-transmission based on ScheduledThreadPoolExecutor (#153)
* Hide Runnable interface in StunClientTransaction class.

* Use CustomizableThreadFactory to give custom names to threads.

* Extracted retransmission logic into separate class.

* Re-implement Retransmitter with ScheduledThreadPoolExecutor.

* Fixed retransmissionCounter increment.

* Directly call logger fine methods instead overload with Level.
2018-10-31 10:53:41 -07:00
Yury Yaroshevich
3fe34dcb97 Reduce number of threads created by ice4j. Eliminate ICE PaceMaker thread & Timer. (#152)
* Eliminate "ICE PaceMaker" thread & Timer inside ConnectivityCheckClient.

* Fixed PaceMaker stop and cleaning.

* Added braces to have explicit blocks for one-liners if/else.
2018-10-30 16:11:48 -07:00
Yury Yaroshevich
6bed63795f Reduce number of threads created by ice4j. Eliminate StunKeepAliveThread. (#151)
* Use ScheduleExecutorService to run STUN keep alives.

* Mark threads as daemon threads.

* Fixed comments. Rearranged properties read in keep alive runnable.

* Added early check that keep alives must not be sent

* Renamed method to check keep alive condition.

* Fixed formatting.

* Renamed metrod which check if KA should run.

* Created CustomizableThreadFactory which support thread name prefixes and if threads are daemons.

* Created dedicated runnable class which perform STUN keep-alive checks.

* Minor comments fixes.

* Do not expose Runnable interface from StunKeepAliveRunner.

* Mark CustomizableThreadFactory fields as final.

* Added java doc to CustomizableThreadFactory
2018-10-29 16:47:20 -07:00
Yury Yaroshevich
ba7e30c189 Fix thread leak when Agent is freed before termination timer triggered. (#150)
* Fix thread leak when Agent is freed before termination timer triggered.

* Use ScheduledExecutorService to terminate agent with timeout

* Fixed formatting to match project code style.
2018-10-24 11:05:00 -05:00
bgrozev
7d2ad8f9a2
feat: Makes the use of a component socket optional. (#147)
* feat: Makes the use of a component socket optional.
2018-10-05 17:15:00 -05:00
bgrozev
4aef25b91f
fix: Makes sure the ReadThread continues running after an exception. (#144) 2018-07-13 14:42:04 -05:00