[vls-devel] Patch to regulate network output

Marian Durkovic md at bts.sk
Mon Mar 3 17:54:07 CET 2003


Hi all,


   in order to solve the problem with large packet bursts I've modified the
netoutput.cpp to ensure that appropriate gap is inserted after each packet
sent to the network. The gap is calculated from the new config parameter
MaxMbps assuming that 10 Mbps stream needs to send 1000 packets/s 
(gap = 1 milisecond). When this parameter is unset, no traffic averaging
is performed.

   One issue related to this is that the standard nanosleep() on Linux
typically sleeps for minimum 20 miliseconds (!) so in order to have this
functionality, we need the high-resolution-timers compiled into the kernel
- see http://sourceforge.net/projects/high-res-timers/

   I'm including the patch below, probably some #ifdefs need to be added 
in order not to compile on standard kernels...


	With kind regards,

		M.

--------------------------------------------------------------------------
----                                                                  ----
----   Marian Durkovic                       network  manager         ----
----                                                                  ----
----   Slovak Technical University           Tel: +421 2 524 51 301   ----
----   Computer Centre, Nam. Slobody 17      Fax: +421 2 524 94 351   ----
----   812 43 Bratislava, Slovak Republic    E-mail: md at bts.sk        ----
----                                                                  ----
--------------------------------------------------------------------------



--- vls/src/modules/netchannel/netoutput.h.orig     Fri Aug  9 15:42:32 2002
+++ vls/src/modules/netchannel/netoutput.h          Mon Mar  3 17:12:22 2003
@@ -61,6 +61,7 @@
   C_String m_strType;
   C_String m_strInterface;
   int m_iTTL;
+  int m_iMaxMbps;

 #ifdef BUGGY_VLC
   virtual int PrivateWriteTo(int iBuffLen) = 0;



--- vls/src/modules/netchannel/netoutput.cpp.orig    Fri Aug  9 15:42:32 2002
+++ vls/src/modules/netchannel/netoutput.cpp         Mon Mar  3 17:53:36 2003
@@ -39,6 +39,7 @@
 #include "../../server/output.h"

 #include "netoutput.h"
+#include "posix_time.h"

 #ifdef HAVE_NET_IF_H
 #include <net/if.h>
@@ -67,6 +68,8 @@
   m_strInterface = pApp->GetSetting(strChannelName+".Interface", "");
   C_String strTTL = pApp->GetSetting(strChannelName+".TTL", "0");
   m_iTTL = strTTL.ToInt();
+  C_String strMaxMbps = pApp->GetSetting(strChannelName+".MaxMbps", "0");
+  m_iMaxMbps = strMaxMbps.ToInt();

   // Init the buffer
   // The first slot is reserved for the Rtp Header
@@ -301,6 +304,13 @@
       ASSERT(pPacket);
       // And release it
       m_pTsProvider->ReleasePacket(pPacket);
+    }
+
+    if (m_iMaxMbps) {
+      struct timespec ts;
+      ts.tv_sec=0;
+      ts.tv_nsec=10000000 / m_iMaxMbps;
+      clock_nanosleep(CLOCK_REALTIME_HR, NULL, &ts, NULL);
     }
   }
 }
-- 
This is the vls-devel mailing-list, see http://www.videolan.org/streaming/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>



More information about the vls-devel mailing list