public class DTLSFlight extends Object
HandshakeMessages but may also contain AlertMessages and
ChangeCipherSpecMessages. See
RFC 6347 for
details.
Scandium offers also the possibility to stop the retransmission with
receiving the first response message instead of the complete flight. That is
currently configurable using
DtlsConnectorConfig.isEarlyStopRetransmission(). Only for the flight
before the very last flight of a handshake, it must be ensured, that the
retransmission is only stopped, after that very last flight is received
completely. Though the very last flight in DTLS 1.2 is always a flight with
CCS and FINISH, the implementation just use message of type handshake to stop
the retransmissions.
Even with stopped retransmission, a flight may timeout a handshake, if the
handshake response could not received completely. That timeout with stopped
retransmission is implemented using the timeout of the current try/retry and
the timeout used for the retry, when the maximum number of retries is
reached.
To support both variants, the flight provides the responseStarted
and responseCompleted flags and a general handle to a timeout task.| Constructor and Description |
|---|
DTLSFlight(DTLSSession session,
int flightNumber)
Creates an empty flight to be sent within a session with a peer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDtlsMessage(int epoch,
DTLSMessage messageToAdd)
Adds a dtls message to this flight.
|
boolean |
contains(DTLSMessage message)
Check, if the provided message is contained in this flight.
|
List<DatagramPacket> |
getDatagrams(int maxDatagramSize,
int maxFragmentSize,
Boolean useMultiHandshakeMessageRecords,
Boolean useMultiRecordMessages,
boolean backOff)
List of datagrams to be sent for this flight.
|
int |
getFlightNumber()
Get the flight number.
|
int |
getNumberOfMessages()
Get number of dtls messages of this flight.
|
List<Record> |
getRecords(int maxDatagramSize,
int maxFragmentSize,
boolean useMultiHandshakeMessageRecords)
Get wrapped records for flight.
|
int |
getTimeout()
Get timeout.
|
int |
getTries()
Get number of (re-)tries.
|
void |
incrementTimeout()
Called, when the flight needs to be retransmitted.
|
static int |
incrementTimeout(int timeoutMillis)
Increment the timeout, here we double it.
|
void |
incrementTries()
Increment number of (re-)tries.
|
boolean |
isResponseCompleted()
Check, if retransmission was cancelled.
|
boolean |
isResponseStarted()
Indicates, that first handshake message of the response is received.
|
boolean |
isRetransmissionNeeded()
Indicate, if flight needs retransmission.
|
void |
scheduleRetransmission(ScheduledExecutorService timer,
Runnable task)
Schedule timeout or retransmission task.
|
void |
setResponseCompleted()
Cancels retransmission of this flight.
|
void |
setResponseStarted()
Signal, that the first handshake message of the response is received.
|
void |
setRetransmissionNeeded(boolean needsRetransmission)
Set retransmission needs.
|
void |
setTimeout(int timeout)
Set timeout
|
protected void |
wrapMessage(org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage epochMessage)
Wraps a DTLS message into (potentially multiple) DTLS records and add
them to the flight.
|
public DTLSFlight(DTLSSession session, int flightNumber)
session - the session to get record sequence numbers from when
sending out the flightflightNumber - number of the flight. Used for logging and
MessageCallback.onDtlsRetransmission(int).NullPointerException - if session or peer address of session is
nullpublic void addDtlsMessage(int epoch,
DTLSMessage messageToAdd)
epoch - the epoch of the dtls message.messageToAdd - the dtls message to add.public int getNumberOfMessages()
public boolean contains(DTLSMessage message)
message - message to checktrue, if message is contained, false, if not.protected final void wrapMessage(org.eclipse.californium.scandium.dtls.DTLSFlight.EpochMessage epochMessage)
throws HandshakeException
epochMessage - dtls message and epochHandshakeException - if the message could not be encrypted using
the session's current security parameterspublic List<Record> getRecords(int maxDatagramSize, int maxFragmentSize, boolean useMultiHandshakeMessageRecords) throws HandshakeException
maxDatagramSize - maximum datagram sizemaxFragmentSize - maximum fragment sizeuseMultiHandshakeMessageRecords - enable to use dtls records with
multiple handshake messages.HandshakeException - if the message could not be encrypted using
the session's current security parameterspublic List<DatagramPacket> getDatagrams(int maxDatagramSize, int maxFragmentSize, Boolean useMultiHandshakeMessageRecords, Boolean useMultiRecordMessages, boolean backOff) throws HandshakeException
maxDatagramSize - maximum datagram sizemaxFragmentSize - maximum fragment sizeuseMultiHandshakeMessageRecords - enable to use dtls records with
multiple handshake messages.useMultiRecordMessages - use datagrams with multiple dtls recordsbackOff - send flight in back off mode.HandshakeException - if the message could not be encrypted using
the session's current security parameterspublic int getFlightNumber()
public int getTries()
public void incrementTries()
public int getTimeout()
public void setTimeout(int timeout)
timeout - timeout in milliseconds.public void incrementTimeout()
MAX_TIMEOUT_MILLIS.incrementTimeout(int)public boolean isRetransmissionNeeded()
true, if flight needs retransmission, false,
otherwise.public void setRetransmissionNeeded(boolean needsRetransmission)
needsRetransmission - true, if flight needs retransmission,
false, otherwise.public boolean isResponseStarted()
true, if the first handshake message of the response is
received, false, otherwise.public void setResponseStarted()
DtlsConnectorConfig.isEarlyStopRetransmission() is configured,
this stops sending retransmissions but keep a scheduled timeout task.public void setResponseCompleted()
scheduleRetransmission(ScheduledExecutorService, Runnable).public boolean isResponseCompleted()
true, if retransmission was cancelled, false,
otherwise.public void scheduleRetransmission(ScheduledExecutorService timer, Runnable task)
timer - timer to schedule task.task - task to be scheduled executedpublic static int incrementTimeout(int timeoutMillis)
MAX_TIMEOUT_MILLIS.timeoutMillis - timeout in millisecondsincrementTimeout()Copyright © 2023 Eclipse Foundation. All rights reserved.