-
+ 1DD063E7677409E44FA53DB1551400F6C3256B47B925DD789A8AF51C2BEBD15AD1F9418F372FCF7D0DDDD33908336178C734E69358F88A0AD03F57BAE2367196
udp/udp_tester/udp_tester.ads
(0 . 0)(1 . 48)
596 -- S.MG, 2018
597 -- Tester for UDP communications relying on libudp and libmt
598
599 with Ada.Calendar; use Ada.Calendar; -- for local time
600 with Ada.Calendar.Time_Zones; use Ada.Calendar.Time_Zones; -- UTC_Time_Offset
601 with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; -- for unix-like
602 with Interfaces; use Interfaces;
603
604 with UDP;
605 with MT;
606
607 package UDP_Tester is
608
609 -- knobs for Tester, change as required
610
611 -- used for obtaining Unix-like time from value ret by Ada.Calendar.Clock
612 Epoch : constant Time := Formatting.Time_Of(1970, 1, 1, 0.0);
613
614 -- Header of each packet is:
615 -- 4 octets local time unix format;
616 -- 2 octets total length of message (header+payload)
617 Header_Len : constant Positive := 6;
618 -- packages sent will be between Header_Len and Max_Len
619 Max_Len : constant Positive := 2048;
620
621 -- helper methods
622 procedure Create_If_Not_Exists( Filename: in String; Header: in String);
623
624 -- will send messages with lengths between Header_Len and Max_Len
625 -- messages are sent at 1 second intervals (i.e. 1 second between 2 messages)
626 -- sizes are chosen based on MT prng with seed = unixtime when sender starts
627 -- payloads are simply I mod 256 where I is position of octet in message
628 -- data for all sent messages is logged in a .txt file in current dir
629 -- if the log files exist, new content will be APPENDED to it
630 -- if the log file does not exist, it will be created
631 procedure Sender( Receiver_IP: in String;
632 Receiver_Port: in Unsigned_16;
633 Sender_Port: in Unsigned_16 );
634
635 -- receiver method with endless loop, receiving UDP messages on given port
636 -- data for all received messages is logged in a .txt file in current dir
637 -- an additional err log contains any octets that are different from expected
638 -- if the log files exist, new content will be APPENDED to it
639 -- if the log file does not exist, it will be created
640 procedure Receiver( Receiver_Port: in Unsigned_16 );
641
642
643 end UDP_Tester;