commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11206 - in gnuradio/branches/developers/eb/vrt: gr-vr


From: eb
Subject: [Commit-gnuradio] r11206 - in gnuradio/branches/developers/eb/vrt: gr-vrt/src vrt/lib
Date: Tue, 16 Jun 2009 00:42:11 -0600 (MDT)

Author: eb
Date: 2009-06-16 00:42:10 -0600 (Tue, 16 Jun 2009)
New Revision: 11206

Added:
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h
Modified:
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc
   gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h
   gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.cc
Log:
Added code to check pkt_cnt value in VRT headers.  If it detects a
sequence error, it prints out an S followed by the number of packets
it estimates are missing (1 <= x <= 15).

When the vrt_source_32fc dtor fires, a summary is printed giving the
total number of packets received and the estimated number of missing
packets.

For now, be sure to run the applications as root, otherwise the huge
kernel socket buffer (62MB) is not allocated.



Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am  2009-06-16 
04:09:46 UTC (rev 11205)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/Makefile.am  2009-06-16 
06:42:10 UTC (rev 11206)
@@ -52,6 +52,7 @@
 lib_LTLIBRARIES = libgnuradio-vrt.la
 
 libgnuradio_vrt_la_SOURCES = \
+       missing_pkt_checker.cc \
        vrt_source_base.cc \
        vrt_source_32fc.cc \
        vrt_quadradio_source_32fc.cc
@@ -83,7 +84,8 @@
 #      vrt_sink_16sc.h \
 #      vrt_sink_32fc.h
 
-noinst_HEADERS = 
+noinst_HEADERS = \
+       missing_pkt_checker.h
 
 
 # ----------------------------------------------------------------------

Added: gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc       
                        (rev 0)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc       
2009-06-16 06:42:10 UTC (rev 11206)
@@ -0,0 +1,46 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <missing_pkt_checker.h>
+
+int
+missing_pkt_checker::check(const vrt::expanded_header *hdr)
+{
+  // FIXME assumes we're inspecting only a single stream
+
+  int nmissing = 0;
+  int actual = hdr->pkt_cnt();
+  int expected = (d_last_pkt_cnt + 1) & 0xf;
+  if (d_npackets != 0 && actual != expected){
+    d_nwrong_pkt_cnt++;
+    if (actual > expected)
+      nmissing = actual - expected;
+    else
+      nmissing = actual + 16 - expected;
+    d_nmissing_pkt_est += nmissing;
+  }
+  d_last_pkt_cnt = actual;
+  d_npackets++;
+  return nmissing;
+}


Property changes on: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Added: gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h        
                        (rev 0)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h        
2009-06-16 06:42:10 UTC (rev 11206)
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_MISSING_PKT_CHECKER_H
+#define INCLUDED_MISSING_PKT_CHECKER_H
+
+#include <vrt/expanded_header.h>
+#include <stdint.h>
+
+/*!
+ * \brief Check for missing packets
+ */
+class missing_pkt_checker
+{
+  // FIXME assumes we're inspecting only a single stream
+
+  uint64_t     d_npackets;             //< total number of packets
+  int          d_last_pkt_cnt;         //< the last pkt_cnt we saw
+  uint64_t     d_nwrong_pkt_cnt;       //< number of incorrect pkt_cnt
+  uint64_t     d_nmissing_pkt_est;     //< estimate of total number of missing 
pkts
+  
+public:
+  missing_pkt_checker()
+    : d_npackets(0), d_last_pkt_cnt(0xf), d_nwrong_pkt_cnt(0), 
d_nmissing_pkt_est(0) {}
+    
+  /*!
+   * \brief check header pkt_cnt and return 0 if OK, else estimate of number 
of missing packets.
+   */
+  int check(const vrt::expanded_header *hdr);
+
+  uint64_t npackets() const { return d_npackets; }
+  uint64_t nwrong_pkt_cnt() const { return d_nwrong_pkt_cnt; }
+  uint64_t nmissing_pkt_est() const { return d_nmissing_pkt_est; }
+};
+
+
+#endif /* INCLUDED_MISSING_PKT_CHECKER_H */


Property changes on: 
gnuradio/branches/developers/eb/vrt/gr-vrt/src/missing_pkt_checker.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc   
2009-06-16 04:09:46 UTC (rev 11205)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.cc   
2009-06-16 06:42:10 UTC (rev 11206)
@@ -28,21 +28,28 @@
 #include <vrt/expanded_header.h>
 #include <vrt/copiers.h>
 #include <gr_io_signature.h>
+#include <missing_pkt_checker.h>
 #include <iostream>
 
+#define VERBOSE 1              // define to 0 or 1
+
+
 class rx_32fc_handler : public vrt::rx_packet_handler
 {
   int                                d_noutput_items;
   std::complex<float>               *d_out;
   int                               *d_oo;             // output index
   std::vector< std::complex<float> > &d_remainder;
+  missing_pkt_checker               &d_checker;
+  
 
 public:
 
   rx_32fc_handler(int noutput_items, std::complex<float> *out,
-                 int *oo, std::vector< std::complex<float> > &remainder)
+                 int *oo, std::vector< std::complex<float> > &remainder,
+                 missing_pkt_checker &checker)
     : d_noutput_items(noutput_items), d_out(out),
-      d_oo(oo), d_remainder(remainder) {}
+      d_oo(oo), d_remainder(remainder), d_checker(checker) {}
 
   ~rx_32fc_handler();
 
@@ -60,6 +67,11 @@
                            size_t n32_bit_words,
                            const vrt::expanded_header *hdr)
 {
+  int nmissing = d_checker.check(hdr);
+  if (VERBOSE && nmissing != 0){
+    std::cerr << "S" << nmissing;
+  }
+
   // copy as many as will fit into the output buffer.
 
   size_t n = std::min(n32_bit_words, (size_t)(d_noutput_items - *d_oo));
@@ -92,6 +104,12 @@
 
 vrt_source_32fc::~vrt_source_32fc()
 {
+  if (VERBOSE){
+    std::cerr << "vrt_source_32fc: npackets = " << d_checker.npackets()
+             << " nwrong_pkt_cnt = " << d_checker.nwrong_pkt_cnt()
+             << " nmissing_pkt_est = " << d_checker.nmissing_pkt_est()
+             << std::endl;
+  }
 }
 
 int
@@ -114,7 +132,7 @@
     return oo;
   
   // While we've got room, and there are packets, handle them
-  rx_32fc_handler h(noutput_items, out, &oo, d_remainder);
+  rx_32fc_handler h(noutput_items, out, &oo, d_remainder, d_checker);
   bool ok = vrt_rx()->rx_packets(&h);
 
   if (!ok){

Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h    
2009-06-16 04:09:46 UTC (rev 11205)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_source_32fc.h    
2009-06-16 06:42:10 UTC (rev 11206)
@@ -24,6 +24,7 @@
 #define INCLUDED_VRT_SOURCE_32FC_H
 
 #include <vrt_source_base.h>
+#include <missing_pkt_checker.h>
 
 class vrt_source_32fc : public vrt_source_base
 {
@@ -31,6 +32,7 @@
   vrt_source_32fc(const char *name);
 
   std::vector< std::complex<float> >   d_remainder;
+  missing_pkt_checker                  d_checker;
 
 public:
   ~vrt_source_32fc();

Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.cc     
2009-06-16 04:09:46 UTC (rev 11205)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.cc     
2009-06-16 06:42:10 UTC (rev 11206)
@@ -90,6 +90,7 @@
 #if defined(SO_RCVBUFFORCE)
       if (setsockopt(d_fd, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbuf_size, 
sizeof(rcvbuf_size)) != 0){
        perror("setsockopt(SO_RCVBUFFORCE)");
+       fprintf(stderr, "Are you running as root?  If not, please do.\n");
       }
       else {
        fprintf(stderr, "SO_RCVBUFFORCE = %zd\n", d_buflen);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]