anchor.diff:      end.
   
   read_packets_test(R, RP, Msgs, Node) ->
  -    Len = length(Msgs),
       Receiver = self(),
       Tracer =
   	spawn_link(
  
positive.code: %%
  %% Starts a slave node that on command sends a bunch of messages
  %% to our UDP port. The receiving process just receives and
  %% ignores the incoming messages, but counts them.
  %% A tracing process traces the receiving process for
  %% 'receive' and scheduling events. From the trace, 
  %% message contents is verified; and, how many messages
  %% are received per in/out scheduling, which should be
  %% the same as the read_packets parameter.
  %% 
  
  %% OTP-6249 UDP option for number of packet reads.
  read_packets(Config) when is_list(Config) ->
      N1 = 5,
      N2 = 7,
      {ok,R} = gen_udp:open(0, [{read_packets,N1}]),
      {ok,RP} = inet:port(R),
      {ok,Node} = start_node(gen_udp_SUITE_read_packets),
      Die = make_ref(),
      Loop = erlang:spawn_link(fun () -> infinite_loop(Die) end),
      %%
      Msgs1 = [erlang:integer_to_list(M) || M <- lists:seq(1, N1*3)],
      [V1|_] = read_packets_test(R, RP, Msgs1, Node),
      {ok,[{read_packets,N1}]} = inet:getopts(R, [read_packets]),
      %%
      ok = inet:setopts(R, [{read_packets,N2}]),
      Msgs2 = [erlang:integer_to_list(M) || M <- lists:seq(1, N2*3)],
      [V2|_] = read_packets_test(R, RP, Msgs2, Node),
      {ok,[{read_packets,N2}]} = inet:getopts(R, [read_packets]),
      %%
      stop_node(Node),
      Mref = erlang:monitor(process, Loop),
      Loop ! Die,
      receive
  	{'DOWN',Mref,_,_, normal} ->
  	    case {V1,V2} of
  		{N1,N2} ->
  		    ok;
  		_ when V1 =/= N1, V2 =/= N2 ->
  		    ok
  	    end
      end.
  
  infinite_loop(Die) ->
      receive 
  
negative.code: 	  [link,{priority,high}]),
      receive
  	{Sender,{port,SP}} ->
  	    erlang:trace(R, true,
  			 [running_ports,'send',{tracer,Tracer}]),
  	    erlang:yield(),
  	    Sender ! {Receiver,go},
  	    read_packets_recv(Msgs),
  	    erlang:trace(R, false, [all]),
  	    Tracer ! {Receiver,get_trace},
  	    receive
  		{Tracer,{trace,Trace}} ->
  		    {read_packets_verify(R, SP, Trace), Trace}
  	    end
      end.
  
  read_packets_send(_S, _RP, 0) ->
      ok;
  read_packets_send(S, RP, Msgs) ->
      ok = gen_udp:send(S, localhost, RP, "UDP FLOOOOOOD"),
      read_packets_send(S, RP, Msgs - 1).
  
  read_packets_recv(0) ->
      ok;
  