public static int verifyMessage(byte[] data, int len, bool verbose)
        {
            long calced_cksum = 0;

            if (len < MINIMUM_VERIFIABLE_MSG_LEN)
            {
                return(-1); // too small to be a verifiable msg
            }
            calced_cksum = VerifiableMessage.inet_cksum(data, len);

            if (verbose)
            {
                System.Console.WriteLine("Calculated cksum = " + calced_cksum);
            }

            if (calced_cksum == 0)
            {
                return(1); // success
            }
            for (int i = 0; i < 4; i++)
            {
                if (data[i + 2] != MAGIC_NUMBER[i])
                {
                    return(-1); // no magic number found, not a verifiable message - failed
                }
            }

            return(0); // magic number found, but bad checksum - failed
        }
        public static byte[] constructVerifiableMessage(int len)
        {
            // bytes 0 and 1 are for the checksum
            // bytes 2 through 5 are for the 4 byte magic number
            // remaining bytes are generated randomly
            byte[] message = new byte[len];
            long   cksum;

            Array.Copy(MAGIC_NUMBER, 0, message, 2, 4);

            for (int i = 6; i < len; i++)
            {
                message[i] = (byte)(GENERATOR.Next() & 0xff);
            }

            cksum = VerifiableMessage.inet_cksum(message, len);

            message[0] = (byte)((cksum >> 8) & 0xff);
            message[1] = (byte)(cksum & 0xff);


            return(message);
        }
示例#3
0
        public int onReceive(object cbArg, LBMMessage msg)
        {
            // keep the sqn of a regular or hot failover sequence
            UInt64 sqn = (UInt64)msg.sequenceNumber();

            if (_verbose)
            {
                if ((msg.flags() & LBM.MSG_FLAG_HF_64) > 0)
                {
                    sqn = msg.hfSequenceNumber64();
                }
                else if ((msg.flags() & LBM.MSG_FLAG_HF_32) > 0)
                {
                    sqn = (UInt64)msg.hfSequenceNumber32();
                }
            }
            switch (msg.type())
            {
            case LBM.MSG_DATA:
                if (stotal_msg_count == 0)
                {
                    data_start_time = Environment.TickCount;
                }
                else
                {
                    data_end_time = Environment.TickCount;
                }

                msg_count++;
                total_msg_count++;
                stotal_msg_count++;
                subtotal_msg_count++;
                byte_count       += msg.length();
                total_byte_count += msg.length();

                if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0)
                {
                    rx_msgs++;
                }
                if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0)
                {
                    otr_msgs++;
                }

                if (_verbose)
                {
                    Console.WriteLine("@{0}.{1:000000}[{2}{3}][{4}][{5}]{6}{7}{8}{9}{10}{11}{12}, {13} bytes",
                                      msg.timestampSeconds(), msg.timestampMicroseconds(), msg.topicName(),
                                      String.Empty, msg.source(), sqn,
                                      ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0 ? "-RX" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_HF_64) != 0 ? "-HF64" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_HF_32) != 0 ? "-HF32" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_HF_DUPLICATE) != 0 ? "-HFDUP" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_HF_PASS_THROUGH) != 0 ? "-PASS" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_HF_OPTIONAL) != 0 ? "-HFOPT" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_OTR) != 0 ? "-OTR" : String.Empty),
                                      msg.length());

                    if (lbmrcv.verifiable)
                    {
                        int rc = VerifiableMessage.verifyMessage(msg.data(), msg.data().Length, lbmrcv.verbose);
                        if (rc == 0)
                        {
                            System.Console.WriteLine("Message sqn " + sqn + " does not verify!");
                        }
                        else if (rc == -1)
                        {
                            System.Console.Error.WriteLine("Message sqn " + sqn + " is not a verifiable message.");
                            System.Console.Error.WriteLine("Use -V option on source and restart receiver.");
                        }
                        else
                        {
                            if (lbmrcv.verbose)
                            {
                                System.Console.WriteLine("Message sqn " + sqn + " verfies");
                            }
                        }
                    }
                    else if (lbmrcv.sdm)
                    {
                        try
                        {
                            SDMsg.parse(msg.data());

                            LBMSDMField f = SDMsg.locate("Sequence Number");

                            long recvdseq = ((LBMSDMFieldInt64)f).get();
                            System.Console.Out.WriteLine("SDM Message contains " + SDMsg.count() + " fields and Field Sequence Number == " + recvdseq);
                        }
                        catch (LBMSDMException sdme)
                        {
                            System.Console.Out.WriteLine("Error occurred processing received SDM Message: " + sdme);
                        }
                    }
                }
                break;

            case LBM.MSG_BOS:
                System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session");
                break;

            case LBM.MSG_EOS:
                //data_end_time = System.DateTime.Now.Ticks;
                System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session");
                if (_end_on_eos)
                {
                    if (_summary)
                    {
                        print_summary();
                    }
                    end();
                }
                subtotal_msg_count = 0;
                break;

            case LBM.MSG_UNRECOVERABLE_LOSS:
                unrec_count++;
                total_unrec_count++;
                if (_verbose)
                {
                    System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + sqn + "],");
                    System.Console.Out.WriteLine(" LOST");
                }
                break;

            case LBM.MSG_UNRECOVERABLE_LOSS_BURST:
                burst_loss++;
                if (_verbose)
                {
                    System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + sqn + "],");
                    System.Console.Out.WriteLine(" LOST BURST");
                }
                break;

            case LBM.MSG_REQUEST:
                if (stotal_msg_count == 0)
                {
                    data_start_time = Environment.TickCount;
                }
                else
                {
                    data_end_time = Environment.TickCount;
                }
                msg_count++;
                stotal_msg_count++;
                subtotal_msg_count++;
                byte_count       += msg.data().Length;
                total_byte_count += msg.data().Length;
                if (_verbose)
                {
                    System.Console.Out.Write("Request ["
                                             + msg.topicName()
                                             + "]["
                                             + msg.source()
                                             + "]["
                                             + sqn
                                             + "], ");
                    System.Console.Out.WriteLine(msg.data().Length
                                                 + " bytes");
                }
                break;

            case LBM.MSG_HF_RESET:
                if (_verbose)
                {
                    Console.WriteLine("[{0}][{1}][{2}]{3}{4}{5}{6}-RESET\n", msg.topicName(), msg.source(), sqn,
                                      ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0 ? "-RX" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_OTR) != 0 ? "-OTR" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_HF_64) != 0 ? "-HF64" : String.Empty),
                                      ((msg.flags() & LBM.MSG_FLAG_HF_32) != 0 ? "-HF32" : String.Empty));
                }
                break;

            default:
                System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]");
                break;
            }
            msg.dispose();
            return(0);
        }
示例#4
0
        static void Main(string[] args)
        {
            if (System.Environment.GetEnvironmentVariable("LBM_LICENSE_FILENAME") == null &&
                System.Environment.GetEnvironmentVariable("LBM_LICENSE_INFO") == null)
            {
                SetEnvironmentVariable("LBM_LICENSE_FILENAME", "lbm_license.txt");
            }
            LBM lbm = new LBM();

            lbm.setLogger(new LBMLogging(logger));

            LBMObjectRecycler objRec = new LBMObjectRecycler();

            int          send_rate    = 0;                                              //	Used for lbmtrm | lbtru transports
            int          retrans_rate = 0;                                              //
            char         protocol     = '\0';                                           //
            int          msglen       = 25;
            int          linger       = 5;
            int          delay        = 1;
            ulong        bytes_sent   = 0;
            int          pause        = 0;
            int          i;
            bool         block                         = true;
            int          hfbits                        = 32;
            int          n                             = args.Length;
            bool         monitor_context               = false;
            int          monitor_context_ivl           = 0;
            bool         monitor_source                = false;
            int          monitor_source_ivl            = 0;
            string       application_id                = null;
            int          mon_format                    = LBMMonitor.FORMAT_CSV;
            int          mon_transport                 = LBMMonitor.TRANSPORT_LBM;
            string       mon_format_options            = null;
            string       mon_transport_options         = null;
            bool         error                         = false;
            bool         done                          = false;
            bool         use_hf                        = false;
            ulong        seq_counter                   = 0;
            long         channel                       = -1;
            string       tape_file                     = null;
            StreamReader tape_scanner                  = null;
            int          tape_msgs_sent                = 0;
            const string OPTION_MONITOR_CTX            = "--monitor-ctx";
            const string OPTION_MONITOR_SRC            = "--monitor-src";
            const string OPTION_MONITOR_TRANSPORT      = "--monitor-transport";
            const string OPTION_MONITOR_TRANSPORT_OPTS = "--monitor-transport-opts";
            const string OPTION_MONITOR_FORMAT         = "--monitor-format";
            const string OPTION_MONITOR_FORMAT_OPTS    = "--monitor-format-opts";
            const string OPTION_MONITOR_APPID          = "--monitor-appid";

            for (i = 0; i < n; i++)
            {
                try
                {
                    switch (args[i])
                    {
                    case OPTION_MONITOR_APPID:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        application_id = args[i];
                        break;

                    case OPTION_MONITOR_CTX:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_context     = true;
                        monitor_context_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_SRC:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_source     = true;
                        monitor_source_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_FORMAT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("csv") == 0)
                        {
                            mon_format = LBMMonitor.FORMAT_CSV;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("lbm") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBM;
                        }
                        else if (args[i].ToLower().CompareTo("udp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_UDP;
                        }
                        else if (args[i].ToLower().CompareTo("lbmsnmp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBMSNMP;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_transport_options += args[i];
                        break;

                    case OPTION_MONITOR_FORMAT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_format_options += args[i];
                        break;

                    case "-c":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        try
                        {
                            LBM.setConfiguration(args[i]);
                        }
                        catch (LBMException Ex)
                        {
                            System.Console.Error.WriteLine("lbmsrc error: " + Ex.Message);
                            error = true;
                        }
                        break;

                    case "-d":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        delay = Convert.ToInt32(args[i]);
                        break;

                    case "-D":
                        if (verifiable)
                        {
                            System.Console.Error.WriteLine("Unable to use SDM because verifiable messages are on. Turn off verifiable messages (-V).");
                            System.Environment.Exit(1);
                        }
                        sdm = true;
                        break;

                    case "-f":
                        use_hf = true;
                        break;

                    case "-i":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        seq_counter = ulong.Parse(args[i]);
                        break;

                    case "-h":
                        print_help_exit(0);
                        break;

                    case "-l":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        msglen = Convert.ToInt32(args[i]);
                        break;

                    case "-n":
                        block = false;
                        break;

                    case "-L":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        linger = Convert.ToInt32(args[i]);
                        break;

                    case "-M":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        msgs = long.Parse(args[i]);
                        break;

                    case "-N":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        channel = Convert.ToInt64(args[i]);
                        break;

                    case "-P":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        pause = Convert.ToInt32(args[i]);
                        break;

                    case "-R":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        ParseRateVars parseRateVars = lbmExampleUtil.parseRate(args[i]);
                        if (parseRateVars.error)
                        {
                            print_help_exit(1);
                        }
                        send_rate    = parseRateVars.rate;
                        retrans_rate = parseRateVars.retrans;
                        protocol     = parseRateVars.protocol;
                        break;

                    case "-s":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        stats_sec = Convert.ToInt32(args[i]);
                        break;

                    case "-t":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        tape_file = args[i];
                        if (!File.Exists(tape_file))
                        {
                            System.Console.Error.WriteLine("{0} does not exist. Verify the file specified by (-t) exists.", tape_file);
                            print_help_exit(1);
                        }
                        tape_scanner = new StreamReader(tape_file);
                        break;

                    case "-V":
                        if (sdm)
                        {
                            System.Console.Error.WriteLine("Unable to use verifiable messages because sdm is on. Turn off sdm (-D).");
                            System.Environment.Exit(1);
                        }
                        verifiable = true;
                        break;

                    case "-x":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        hfbits = Convert.ToInt32(args[i]);

                        if (hfbits != 32 && hfbits != 64)
                        {
                            Console.WriteLine("-x " + hfbits + " invalid, HF sequence numbers must be 32 or 64 bit");
                            print_help_exit(1);
                        }
                        break;

                    default:
                        if (args[i].StartsWith("-"))
                        {
                            error = true;
                        }
                        else
                        {
                            done = true;
                        }
                        break;
                    }
                    if (error || done)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    /* type conversion exception */
                    System.Console.Error.WriteLine("lbmsrc: error\n" + e.Message + "\n");
                    print_help_exit(1);
                }
            }
            if (error || i >= n)
            {
                /* An error occurred processing the command line - print help and exit */
                print_help_exit(1);
            }
            if (tape_scanner != null && !use_hf)
            {
                print_help_exit(1);
            }

            byte [] message = new byte[msglen];

            if (verifiable)
            {
                int min_msglen = VerifiableMessage.MINIMUM_VERIFIABLE_MSG_LEN;
                if (msglen < min_msglen)
                {
                    System.Console.WriteLine("Specified message length " + msglen + " is too small for verifiable message.");
                    System.Console.WriteLine("Setting message length to minimum (" + min_msglen + ").");
                    msglen = min_msglen;
                }
            }

            LBMSourceAttributes sattr = new LBMSourceAttributes();

            sattr.setObjectRecycler(objRec, null);
            LBMContextAttributes cattr = new LBMContextAttributes();

            cattr.setObjectRecycler(objRec, null);

            /* Check if protocol needs to be set to lbtrm | lbtru */
            if (protocol == 'M')
            {
                try
                {
                    sattr.setValue("transport", "LBTRM");
                    cattr.setValue("transport_lbtrm_data_rate_limit", send_rate.ToString());
                    cattr.setValue("transport_lbtrm_retransmit_rate_limit", retrans_rate.ToString());
                }
                catch (LBMException ex)
                {
                    System.Console.Error.WriteLine("Error setting LBTRM rate: " + ex.Message);
                    System.Environment.Exit(1);
                }
            }
            if (protocol == 'U')
            {
                try
                {
                    sattr.setValue("transport", "LBTRU");
                    cattr.setValue("transport_lbtru_data_rate_limit", send_rate.ToString());
                    cattr.setValue("transport_lbtru_retransmit_rate_limit", retrans_rate.ToString());
                }
                catch (LBMException ex)
                {
                    System.Console.Error.WriteLine("Error setting LBTRU rate: " + ex.Message);
                    System.Environment.Exit(1);
                }
            }

            LBMContext ctx   = new LBMContext(cattr);
            LBMTopic   topic = ctx.allocTopic(args[i], sattr);
            LBMSource  src;
            SrcCB      srccb = new SrcCB();

            if (use_hf)
            {
                src = ctx.createHotFailoverSource(topic, new LBMSourceEventCallback(srccb.onSourceEvent), null, null);
            }
            else
            {
                src = ctx.createSource(topic, new LBMSourceEventCallback(srccb.onSourceEvent), null, null);
            }

            LBMSourceChannelInfo channel_info = null;
            LBMSourceSendExInfo  exInfo       = null;

            if (channel != -1)
            {
                if (use_hf)
                {
                    Console.WriteLine("Error creating channel: cannot send on channels with hot failover.");
                    Environment.Exit(1);
                }
                channel_info = src.createChannel(channel);
                exInfo       = new LBMSourceSendExInfo(LBM.SRC_SEND_EX_FLAG_CHANNEL, null, channel_info);
            }

            SrcStatsTimer stats;

            if (stats_sec > 0)
            {
                stats = new SrcStatsTimer(ctx, src, stats_sec * 1000, null, objRec);
            }
            LBMMonitorSource lbmmonsrc = null;

            if (monitor_context || monitor_source)
            {
                lbmmonsrc = new LBMMonitorSource(mon_format, mon_format_options, mon_transport, mon_transport_options);
                if (monitor_context)
                {
                    lbmmonsrc.start(ctx, application_id, monitor_context_ivl);
                }
                else
                {
                    lbmmonsrc.start(src, application_id, monitor_source_ivl);
                }
            }

            if (delay > 0)
            {
                System.Console.Out.WriteLine("Will start sending in {0} second{1}...\n",
                                             delay, ((delay > 1) ? "s" : ""));

                System.Threading.Thread.Sleep(delay * 1000);
            }

            System.Console.Out.WriteLine("Sending {0} messages of size {1} bytes to topic [{2}]\n",
                                         msgs, msglen, args[i]);
            System.Console.Out.Flush();
            long start_time = System.DateTime.Now.Ticks;
            long msgcount   = 0;

            if (verifiable)
            {
                message = VerifiableMessage.constructVerifiableMessage(msglen);
            }
            else if (sdm) // If using SDM messages, create the message now
            {
                CreateSDMessage();
            }

            // hfexinfo holds hot failover sequence number at bit size
            LBMSourceSendExInfo hfexinfo = null;

            if (use_hf)
            {
                int hfflags = (hfbits == 64) ? LBM.SRC_SEND_EX_FLAG_HF_64 : LBM.SRC_SEND_EX_FLAG_HF_32;
                hfexinfo = new LBMSourceSendExInfo(hfflags, null);
            }
            for (msgcount = 0; msgcount < msgs;)
            {
                try {
                    // If using SDM messages, Update the sequence number
                    if (sdm)
                    {
                        byte [] m = UpdateSDMessage(seq_counter);
                        if (m != null)
                        {
                            message = m;
                            msglen  = message.Length;
                        }
                    }

                    bool sendReset = false;
                    srccb.blocked = true;

                    if (use_hf)
                    {
                        if (tape_scanner != null)
                        {
                            string tape_str, tape_line = null;
                            tape_line = tape_scanner.ReadLine();

                            if (tape_line == null)
                            {
                                break;
                            }

                            // Make sure the hf optional send ex flag is off
                            hfexinfo.setFlags(hfexinfo.flags() & ~LBM.SRC_SEND_EX_FLAG_HF_OPTIONAL);
                            if (tape_line.EndsWith("o"))
                            {
                                tape_str = tape_line.Substring(0, tape_line.Length - 1);
                                hfexinfo.setFlags(hfexinfo.flags() | LBM.SRC_SEND_EX_FLAG_HF_OPTIONAL);
                            }
                            else if (tape_line.EndsWith("r"))
                            {
                                tape_str  = tape_line.Substring(0, tape_line.Length - 1);
                                sendReset = true;
                            }
                            else
                            {
                                tape_str = tape_line;
                            }

                            if (hfbits == 64)
                            {
                                hfexinfo.setHfSequenceNumber64(ulong.Parse(tape_str));
                            }
                            else
                            {
                                hfexinfo.setHfSequenceNumber32(uint.Parse(tape_str));
                            }
                        }
                        else if (hfbits == 64)
                        {
                            hfexinfo.setHfSequenceNumber64(seq_counter);
                        }
                        else
                        {
                            hfexinfo.setHfSequenceNumber32((uint)seq_counter);
                        }

                        if (sendReset)
                        {
                            ((LBMHotFailoverSource)src).sendReceiverReset(LBM.MSG_FLUSH, hfexinfo);
                        }
                        else
                        {
                            ((LBMHotFailoverSource)src).send(message, msglen, 0, block ? 0 : LBM.SRC_NONBLOCK, hfexinfo);
                        }
                        if (tape_scanner != null)
                        {
                            tape_msgs_sent++;
                        }
                    }
                    else if (exInfo != null)
                    {
                        src.send(message, msglen, block ? 0 : LBM.SRC_NONBLOCK, exInfo);
                    }
                    else
                    {
                        src.send(message, msglen, block ? 0 : LBM.SRC_NONBLOCK);
                    }
                    srccb.blocked = false;
                    if (tape_scanner == null)
                    {
                        seq_counter++;
                        msgcount++;
                    }
                }
                catch (LBMEWouldBlockException) {
                    while (srccb.blocked)
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                    continue;
                }
                bytes_sent += (ulong)msglen;
                if (pause > 0)
                {
                    System.Threading.Thread.Sleep(pause);
                }
            }
            long   end_time = System.DateTime.Now.Ticks;
            double secs     = (end_time - start_time) / 10000000.0;

            System.Console.Out.WriteLine("Sent {0} messages of size {1} bytes in {2} seconds.\n",
                                         (tape_scanner == null) ? msgs : tape_msgs_sent, msglen, secs);

            print_bw(secs, (tape_scanner == null) ? msgs : tape_msgs_sent, bytes_sent);
            System.Console.Out.Flush();
            if (linger > 0)
            {
                System.Console.Out.WriteLine("Lingering for {0} second{1}...\n",
                                             linger, ((linger > 1) ? "s" : ""));
                System.Threading.Thread.Sleep(linger * 1000);
            }
            stats = new SrcStatsTimer(ctx, src, 0, null, objRec);
            if (channel_info != null)
            {
                src.deleteChannel(channel_info);
            }
            objRec.close();
            src.close();

            if (tape_scanner != null)
            {
                tape_scanner.Close();
                tape_scanner.Dispose();
            }
            ctx.close();
        }
示例#5
0
        public int onReceive(object cbArg, LBMMessage msg)
        {
            switch (msg.type())
            {
            case LBM.MSG_DATA:
                if (stotal_msg_count == 0)
                {
                    data_start_time = Environment.TickCount;
                }
                else
                {
                    data_end_time = Environment.TickCount;
                }

                msg_count++;
                total_msg_count++;
                stotal_msg_count++;
                subtotal_msg_count++;
                byte_count       += msg.length();
                total_byte_count += msg.length();

                if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0)
                {
                    rx_msgs++;
                }
                if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0)
                {
                    otr_msgs++;
                }

                if (_verbose)
                {
                    Console.Write("[@{0}.{1:000000}]", msg.timestampSeconds(), msg.timestampMicroseconds());
                    if (msg.channelInfo() != null)
                    {
                        switch (msg.channelInfo().channelFlags())
                        {
                        case LBM.MSG_FLAG_NUMBERED_CHANNEL:

                            System.Console.Out.Write("["
                                                     + msg.topicName()
                                                     + ":"
                                                     + msg.channelInfo().channelNumber()
                                                     + "]["
                                                     + msg.source()
                                                     + "]["
                                                     + msg.sequenceNumber()
                                                     + "], ");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        System.Console.Out.Write("["
                                                 + msg.topicName()
                                                 + "]["
                                                 + msg.source()
                                                 + "]["
                                                 + msg.sequenceNumber()
                                                 + "], ");
                    }
                    if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0)
                    {
                        System.Console.Out.Write("-RX- ");
                    }
                    if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0)
                    {
                        System.Console.Out.Write("-OTR- ");
                    }

                    System.Console.Out.WriteLine(msg.data().Length + " bytes");

                    if (lbmhfxrcv.verifiable)
                    {
                        int rc = VerifiableMessage.verifyMessage(msg.data(), msg.data().Length, lbmhfxrcv.verbose);
                        if (rc == 0)
                        {
                            System.Console.WriteLine("Message sqn " + msg.sequenceNumber() + " does not verify!");
                        }
                        else if (rc == -1)
                        {
                            System.Console.Error.WriteLine("Message sqn " + msg.sequenceNumber() + " is not a verifiable message.");
                            System.Console.Error.WriteLine("Use -V option on source and restart receiver.");
                        }
                        else
                        {
                            if (lbmhfxrcv.verbose)
                            {
                                System.Console.WriteLine("Message sqn " + msg.sequenceNumber() + " verfies");
                            }
                        }
                    }
                }
                break;

            case LBM.MSG_BOS:
                System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session");
                break;

            case LBM.MSG_EOS:
                //data_end_time = System.DateTime.Now.Ticks;
                System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session");
                if (_end_on_eos)
                {
                    if (_summary)
                    {
                        print_summary();
                    }
                    end();
                }
                subtotal_msg_count = 0;
                break;

            case LBM.MSG_UNRECOVERABLE_LOSS:
                unrec_count++;
                total_unrec_count++;
                if (_verbose)
                {
                    System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],");
                    System.Console.Out.WriteLine(" LOST");
                }
                break;

            case LBM.MSG_UNRECOVERABLE_LOSS_BURST:
                burst_loss++;
                if (_verbose)
                {
                    System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],");
                    System.Console.Out.WriteLine(" LOST BURST");
                }
                break;

            case LBM.MSG_REQUEST:
                if (stotal_msg_count == 0)
                {
                    data_start_time = Environment.TickCount;
                }
                else
                {
                    data_end_time = Environment.TickCount;
                }
                msg_count++;
                stotal_msg_count++;
                subtotal_msg_count++;
                byte_count       += msg.data().Length;
                total_byte_count += msg.data().Length;
                if (_verbose)
                {
                    System.Console.Out.Write("Request ["
                                             + msg.topicName()
                                             + "]["
                                             + msg.source()
                                             + "]["
                                             + msg.sequenceNumber()
                                             + "], ");
                    System.Console.Out.WriteLine(msg.data().Length
                                                 + " bytes");
                }
                break;

            default:
                System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]");
                break;
            }
            msg.dispose();
            System.Console.Out.Flush();
            return(0);
        }