Send the first DHCPv6 message with a delay to avoid synchronization.
Per RFC8415 section 18.2.1 the first Solicit message from the client
on the interface should be delayed by a random amount of time between
0 and SOL_MAX_DELAY(1s). Send the first message with a delay in the
PacketRetransmitState, the delay can be 0, depends on the substate.
Bug: 260934173
Test: TH
Change-Id: If5aeaa0118515d9de3134c636871a8771cf0b148
diff --git a/src/android/net/dhcp6/Dhcp6Client.java b/src/android/net/dhcp6/Dhcp6Client.java
index 0c3a903..ce63d86 100644
--- a/src/android/net/dhcp6/Dhcp6Client.java
+++ b/src/android/net/dhcp6/Dhcp6Client.java
@@ -236,11 +236,13 @@
private long mRetransTimeout = -1;
private int mRetransCount = 0;
private long mMaxRetransDurationMillis = 0;
+ private final long mInitialDelayMillis;
private final long mInitialRetransTimeMillis;
private final long mMaxRetransTimeMillis;
private final int mMaxRetransCount;
- PacketRetransmittingState(final long irt, final long mrt, final int mrc) {
+ PacketRetransmittingState(final long delay, final long irt, final long mrt, final int mrc) {
+ mInitialDelayMillis = delay;
mInitialRetransTimeMillis = irt;
mMaxRetransTimeMillis = mrt;
mMaxRetransCount = mrc;
@@ -249,7 +251,7 @@
@Override
public void enter() {
super.enter();
- sendMessage(CMD_KICK);
+ sendMessageDelayed(CMD_KICK, mInitialDelayMillis);
}
@Override
@@ -495,7 +497,7 @@
class SolicitState extends PacketRetransmittingState {
SolicitState() {
// TODO: use the actual constants.
- super((long) 0/* IRT */, (long) 0 /* MRT */, 0 /* MRC */);
+ super((long) 0 /* delay */, (long) 0/* IRT */, (long) 0 /* MRT */, 0 /* MRC */);
}
@Override
@@ -544,7 +546,7 @@
class RequestState extends PacketRetransmittingState {
RequestState() {
// TODO: use the actual constants.
- super((long) 0/* IRT */, (long) 0 /* MRT */, 0 /* MRC */);
+ super((long) 0 /* delay */, (long) 0/* IRT */, (long) 0 /* MRT */, 0 /* MRC */);
}
@Override
@@ -669,7 +671,7 @@
abstract class ReacquireState extends PacketRetransmittingState {
ReacquireState() {
// TODO: use the actual constants.
- super((long) 0/* IRT */, (long) 0 /* MRT */, 0 /* MRC */);
+ super((long) 0 /* delay */, (long) 0/* IRT */, (long) 0 /* MRT */, 0 /* MRC */);
}
@Override