Initialize the retransmission parameters for SolicitState.
Per RFC8415 section 18.2.1:
IRT SOL_TIMEOUT
MRT SOL_MAX_RT
MRC 0
MRD 0
Bug: 260934173
Test: TH
Change-Id: I3eeff44d8e42007263ed14722593f8be16e9c616
diff --git a/src/android/net/dhcp6/Dhcp6Client.java b/src/android/net/dhcp6/Dhcp6Client.java
index ce63d86..c26943b 100644
--- a/src/android/net/dhcp6/Dhcp6Client.java
+++ b/src/android/net/dhcp6/Dhcp6Client.java
@@ -106,9 +106,10 @@
private static final int CMD_DHCP6_PD_REBIND = PRIVATE_BASE + 4;
private static final int CMD_DHCP6_PD_EXPIRE = PRIVATE_BASE + 5;
- // Timers and timeouts.
- // TODO: comply with RFC8415 section 15(Reliability of Client-Initiated Message Exchanges)
- private static final int SECONDS = 1000;
+ // Transmission and Retransmission parameters in milliseconds.
+ private static final int SECONDS = 1000;
+ private static final long SOL_TIMEOUT = 1 * SECONDS;
+ private static final long SOL_MAX_RT = 3600 * SECONDS;
// Per rfc8415#section-12, the IAID MUST be consistent across restarts.
// Since currently only one IAID is supported, a well-known value can be used (0).
@@ -496,8 +497,11 @@
*/
class SolicitState extends PacketRetransmittingState {
SolicitState() {
- // TODO: use the actual constants.
- super((long) 0 /* delay */, (long) 0/* IRT */, (long) 0 /* MRT */, 0 /* MRC */);
+ // First Solicit message should be delayed by a random amount of time between 0
+ // and SOL_MAX_DELAY(1s).
+ // TODO: request SOL_MAX_RT option from server.
+ super((long) (new Random().nextDouble() * SECONDS) /* delay */, SOL_TIMEOUT /* IRT */,
+ SOL_MAX_RT /* MRT */, 0 /* MRC */);
}
@Override