class ConnectivityCheckClient extends Object implements ResponseCollector
Modifier and Type | Class and Description |
---|---|
private class |
ConnectivityCheckClient.PaceMaker
A class to control periodically scheduled runnable that actually sends
the checks for a particular check list in the pace defined in RFC 5245.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
alive
A flag that determines whether we have received a STUN response or not.
|
private ConcurrentMap<String,ScheduledFuture<?>> |
checkListCompletionCheckers
Timer that is used to let some seconds before a CheckList is considered
as FAILED.
|
private static Logger |
classLogger
The Logger used by the ConnectivityCheckClient
class for logging output.
|
private Logger |
logger
The
Logger used by ConnectivityCheckClient instances. |
private Queue<ConnectivityCheckClient.PaceMaker> |
paceMakers
The
ConnectivityCheckClient.PaceMaker s that are currently running checks in this client. |
private Agent |
parentAgent
The agent that created us.
|
private ScheduledExecutorService |
scheduledExecutorService
A scheduled executor service to perform scheduled task of the client
|
private StunStack |
stunStack
The StunStack that we will use for connectivity checks.
|
Constructor and Description |
---|
ConnectivityCheckClient(Agent parentAgent,
ScheduledExecutorService scheduledExecutorService)
Creates a new ConnectivityCheckClient setting
parentAgent as the agent that will be used for retrieving
information such as user fragments for example.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
checkSymmetricAddresses(StunResponseEvent evt)
|
(package private) boolean |
isAlive()
Returns a boolean value indicating whether we have received a STUN
response or not.
|
private void |
processErrorResponse(StunResponseEvent ev)
In case of a role conflict, changes the state of the agent and
reschedules the check, in all other cases sets the corresponding peer
state to FAILED.
|
void |
processResponse(StunResponseEvent ev)
Handles the response as per the procedures described in RFC 5245
or in other words, by either changing the state of the corresponding pair
to FAILED, or SUCCEEDED, or rescheduling a check in case of a role
conflict.
|
private void |
processSuccessResponse(StunResponseEvent ev)
Handles STUN success responses as per the rules in RFC 5245.
|
void |
processTimeout(StunTimeoutEvent ev)
Sets the state of the corresponding
CandidatePair to
CandidatePairState.FAILED and updates check list and timer
states. |
protected void |
sendBindingIndicationForPair(CandidatePair candidatePair)
Creates a STUN Binding
Indication to a candidate pair. |
protected TransactionID |
startCheckForPair(CandidatePair candidatePair)
Creates a STUN
Request containing the necessary PRIORITY and
CONTROLLING/CONTROLLED attributes. |
protected TransactionID |
startCheckForPair(CandidatePair candidatePair,
int originalWaitInterval,
int maxWaitInterval,
int maxRetransmissions)
Creates a STUN
Request containing the necessary PRIORITY and
CONTROLLING/CONTROLLED attributes. |
void |
startChecks()
Starts client connectivity checks for the first
IceMediaStream
in our parent Agent . |
void |
startChecks(CheckList checkList)
Starts client connectivity checks for the
CandidatePair s in
checkList |
void |
stop()
Stops and removes all PaceMakers.
|
private void |
updateCheckListAndTimerStates(CandidatePair checkedPair)
Updates all check list and timer states after a check has completed
(both if completion was successful or not).
|
private static final Logger classLogger
ConnectivityCheckClient
, because it doesn't take into account
the per-instance log level. Instances should use logger
instead.private final Agent parentAgent
private final ScheduledExecutorService scheduledExecutorService
private final StunStack stunStack
private final Queue<ConnectivityCheckClient.PaceMaker> paceMakers
ConnectivityCheckClient.PaceMaker
s that are currently running checks in this client.private ConcurrentMap<String,ScheduledFuture<?>> checkListCompletionCheckers
private boolean alive
private Logger logger
Logger
used by ConnectivityCheckClient
instances.public ConnectivityCheckClient(Agent parentAgent, ScheduledExecutorService scheduledExecutorService)
parentAgent
- the Agent that is creating this instance.scheduledExecutorService
- the ScheduledExecutorService
to execute clients tasksboolean isAlive()
public void startChecks()
IceMediaStream
in our parent Agent
. This method should only be called by
the parent Agent
when connectivity establishment starts for a
particular check list.public void startChecks(CheckList checkList)
CandidatePair
s in
checkListcheckList
- the CheckList
to start client side connectivity
checks for.protected void sendBindingIndicationForPair(CandidatePair candidatePair)
Indication
to a candidate pair. It is used
as a keep-alive.candidatePair
- that CandidatePair
that we'd like to send
an indicationprotected TransactionID startCheckForPair(CandidatePair candidatePair)
Request
containing the necessary PRIORITY and
CONTROLLING/CONTROLLED attributes. Also stores a reference to
candidatePair in the newly created transactionID so that we
could then refer back to it in subsequent response or failure events.candidatePair
- that CandidatePair
that we'd like to start
a check for.TransactionID
used in the connectivity
check client transaction or null if sending the check has
failed for some reason.protected TransactionID startCheckForPair(CandidatePair candidatePair, int originalWaitInterval, int maxWaitInterval, int maxRetransmissions)
Request
containing the necessary PRIORITY and
CONTROLLING/CONTROLLED attributes. Also stores a reference to
candidatePair in the newly created transactionID so that we
could then refer back to it in subsequent response or failure events.candidatePair
- that CandidatePair
that we'd like to start
a check for.originalWaitInterval
- maxWaitInterval
- maxRetransmissions
- TransactionID
used in the connectivity
check client transaction or null if sending the check has
failed for some reason.public void processResponse(StunResponseEvent ev)
processResponse
in interface ResponseCollector
ev
- the StunResponseEvent
that contains the newly received
response.private void updateCheckListAndTimerStates(CandidatePair checkedPair)
checkedPair
- the pair whose check has just completed.private void processSuccessResponse(StunResponseEvent ev)
ev
- the event that delivered the error response.private boolean checkSymmetricAddresses(StunResponseEvent evt)
Response
in evt had a
source or a destination address that match those of the Request
,
or false otherwise.RFC 5245: The agent MUST check that the source IP address and port of the response equal the destination IP address and port to which the Binding request was sent, and that the destination IP address and port of the response match the source IP address and port from which the Binding request was sent. In other words, the source and destination transport addresses in the request and responses are symmetric. If they are not symmetric, the agent sets the state of the pair to Failed.
evt
- the StunResponseEvent
that contains the Response
we need to examineResponse
in evt had a
source or a destination address that matched those of the
Request
, or false otherwise.private void processErrorResponse(StunResponseEvent ev)
ev
- the event that delivered the error response.public void processTimeout(StunTimeoutEvent ev)
CandidatePair
to
CandidatePairState.FAILED
and updates check list and timer
states.processTimeout
in interface ResponseCollector
ev
- the StunTimeoutEvent
containing the original
transaction and hence CandidatePair
that's being checked.public void stop()
Copyright © 2018. All rights reserved.