Engineering Protocols & Kannel

by Kari Grano, Jukka Paakki, Jukka Viljamaa, Antti Viljamaa 





Listing One

and state connection is

  init send_conn;

  state rec_conn is

     ...

  end rec_conn;

  state send_conn is

      ...

      state disconnected arcs

         conn_req -> {

            peer ! SendFrameReq.create(T_CIND, NO_DAT);

            go opening

         }

         disc_req -> { err("not connected") }

         send_req -> { err("not connected") }

      end disconnected

  end send_conn

end connection



Listing Two

t_exp -> {

    if t_exp.num <> REC_TIMER then

      f : IFrame;

      if send_count >= RETX_MAX then

        up ! new RecLost;

        send_buffer.clear;

        ...

        send_window.clear;

        current:= 0;

        send_count:= 0

      else

        sw_iter.initiate(send_window);

        loop sw_iter.exhausted.until;

          f:= sw_iter.get_current;

          if f.frame_num = t_exp.num then

             peer ! f;

             tim ! TStart.create(t_exp.num, TIME);

             send_count:= send_count+1;

             break

          end;

          sw_iter.next

        end loop

      end if

    end if

}



Listing Three

ack -> {

    f,g : IFrame;

    loop send_window.remove_head(f).while;

      tim ! TStop.create(f.frame_num);

      send_count:= 0;

      if send_buffer.remove_head(g) then

         g.frame_num:= current;

         peer ! g;

         tim ! TStart.create(g.frame_num, TIME);

         send_window.put_tail(g);

         inc(current)

      end;

      (f.frame_num = ack.frame_num).until

    end loop

}



Listing Four

nak -> {

    f : IFrame;

    loop send_window.first(f).while;

      (f.frame_num = nak.frame_num).until;

      send_window.remove_head(f);

      tim ! TStop.create(f.frame_num)

    end loop;

    sw_iter.initiate(send_window);

    loop sw_iter.exhausted.until;

      f:= sw_iter.get_current;

      peer ! f;

      tim ! TStart.create(f.frame_num, TIME);

      sw_iter.next

    end loop

}



Listing Five

main(dvec[string]) is

  send_buffer:= IFrame_queue.create(SEND_BUFFER_SIZE);

  send_window:= IFrame_queue.create(SEND_WINDOW_SIZE);

  sw_iter:= IFrame_queue_iter.create(send_window);

  current:= 0;                   -- Number for next iframe

  expected:= 0;

  send_count:= 0;                -- Retransmission counters

  rec_count:= 0;

  if arg.size < 4 then

     stdout.print_str("Usage: " + arg.get(0) + " s-port host t-port\n");

     SYS.shutdown

  end;

  peer.configure(SOCK_SPORT, arg.get(1)); -- source port

  peer.configure(SOCK_THOST, arg.get(2)); -- target host

  peer.configure(SOCK_TPORT, arg.get(3)); -- target port

  peer.configure(SOCK_TCP, "false");      -- use UDP

  peer.open

end main









3





