anchor.diff:      %% The peer sends a message before the expiry of another watchdog
       %% to induce failback.
   
  -    ?EVENT({watchdog, Ref, _, {suspect, okay}, _}, WdH + 2000),
  -    ?EVENT({up, Ref, _, _}, 0),
  +    {suspect, okay} = ?WD_EVENT(Ref),
  +    ?EVENT({up, Ref, _, _}),
  +
  +    %% N+1 sent DWR's, N/N+1 received DWA's
  +    R1 = N+1,
  +    A1 = choose(M == 'DWA', R1, N),
  +    [R1,_,_,A1] = wd_counts(SvcName),
   
       %%   OKAY          Timer expires &      SendWatchdog()
       %%                 !Pending             SetWatchdog()
  
positive.code:     %% An exchange of 3 watchdogs (the first directly after
      %% capabilities exchange) brings the connection back up.
  
      ?EVENT({watchdog, Ref, _, {reopen, okay}, _}, 2, WdL, WdH),
      ?EVENT({up, Ref, _, _, #diameter_packet{}}, 0),
  
      %% Non-response brings it down again.
  
      ?EVENT({watchdog, Ref, _, {okay, suspect}, _}, 2, WdL, WdH),
      ?EVENT({down, Ref, _, _}, 0),
      ?EVENT({watchdog, Ref, _, {suspect, down}, _}, 1, WdL, WdH),
  
      %% Reestablish after another watchdog.
  
      recv_reopen(Type, Ref, WdL, WdH),
  
      %%   REOPEN        Timer expires &      NumDWA = -1
      %%                 Pending &            SetWatchdog()
  
negative.code: %% Watchdog timer as a callback.
  -define(WD(T), {?MODULE, id, [T]}).
  
  %% Watchdog timers used by the testcases.
  -define(WD_TIMERS, [10000, ?WD(10000)]).
  
  %% Watchdog timer of the misbehaving node. Longer than the peer's so
  %% that DWR is never sent at watchdog timeout.
  -define(PEER_WD, 20000).
  
  %% A timeout that ensures one watchdog. To ensure only one watchdog
  %% requires (Wd + 2000) + 1000 < 2*(Wd - 2000) ==> 7000 < Wd for the
  %% case with random jitter.
  -define(ONE_WD(Wd), jitter(Wd,2000) + 1000).
  
  %% Receive an event message from diameter.
  -define(EVENT(T),
          apply(fun() ->  %% apply to not bind T_
                        receive #diameter_event{info = T = T_} ->
                                log_event(T_)
                        end
                end,
                [])).
  
  %% Receive a watchdog event.
  -define(WD_EVENT(Ref), log_wd(element(4, ?EVENT({watchdog, Ref, _, _, _})))).
  
  %% Log to make failures identifiable.
  -define(LOG(T),   ?LOG("~p", [T])).
  -define(LOG(F,A), ct:pal("~p: " ++ F, [self() | A])).
  
  %% ===========================================================================
  
  suite() ->
      [{timetrap, {minutes, 5}}]. %% 20 watchdogs @ 15 sec
  
  all() ->
      [reopen].
  