-- S.MG, 2018 -- Tester for UDP communications relying on libudp and libmt with Ada.Calendar; use Ada.Calendar; -- for local time with Ada.Calendar.Time_Zones; use Ada.Calendar.Time_Zones; -- UTC_Time_Offset with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; -- for unix-like with Interfaces; use Interfaces; with UDP; with MT; package UDP_Tester is -- knobs for Tester, change as required -- used for obtaining Unix-like time from value ret by Ada.Calendar.Clock Epoch : constant Time := Formatting.Time_Of(1970, 1, 1, 0.0); -- Header of each packet is: -- 4 octets local time unix format; -- 2 octets total length of message (header+payload) Header_Len : constant Positive := 6; -- packages sent will be between Header_Len and Max_Len Max_Len : constant Positive := 2048; -- helper methods procedure Create_If_Not_Exists( Filename: in String; Header: in String); -- will send messages with lengths between Header_Len and Max_Len -- messages are sent at 1 second intervals (i.e. 1 second between 2 messages) -- sizes are chosen based on MT prng with seed = unixtime when sender starts -- payloads are simply I mod 256 where I is position of octet in message -- data for all sent messages is logged in a .txt file in current dir -- if the log files exist, new content will be APPENDED to it -- if the log file does not exist, it will be created procedure Sender( Receiver_IP: in String; Receiver_Port: in Unsigned_16; Sender_Port: in Unsigned_16 ); -- receiver method with endless loop, receiving UDP messages on given port -- data for all received messages is logged in a .txt file in current dir -- an additional err log contains any octets that are different from expected -- if the log files exist, new content will be APPENDED to it -- if the log file does not exist, it will be created procedure Receiver( Receiver_Port: in Unsigned_16 ); end UDP_Tester;