Patch for IP-DSCP Prioritization

Discuss issues related to PS3 Media Server development (only for programmers)

Patch for IP-DSCP Prioritization

Postby bgm » Tue Aug 03, 2010 11:38 pm

Hi,

In this patch the IP/DSCP code default of Best-effort (000000) is changed to Class 5 (101000), activating priority on ethernet and wireless (WMM) . Correctness proved by wireshack capture, only thing is some TCP handshake still are issued with best-effort. Also i have an experimental UDP engine but the only thing left is to make the PS3 recognize that the server is alive, responding the issued SYN, with a SYN-ACK, to further test.

Email for contact: brunogm0@gmail.com

Links used:
WMM QoS: http://en.wikipedia.org/wiki/802.11e
Testing if WMM is effectively enabled and its benefits:
http://www.smallnetbuilder.com/wireless/wireless-features/30837-does-wi-fi-multimedia-wmm-really-do-anything-part-1
http://www.smallnetbuilder.com/wireless/wireless-features/30837-does-wi-fi-multimedia-wmm-really-do-anything-part-2
http://www.smallnetbuilder.com/wireless/wireless-features/30837-does-wi-fi-multimedia-wmm-really-do-anything-part-3

Theoretical limits on Bandwidth:
802.11g only Max Link 54Mbps Max TCP 24.4Mbps Max UDP 30.5Mbps


PATCH:
Code: Select all
Index: net/pms/network/HTTPServer.java
===================================================================
--- net/pms/network/HTTPServer.java   (revision 410)
+++ net/pms/network/HTTPServer.java   (working copy)
@@ -117,25 +124,28 @@
          address = new InetSocketAddress(port);
       }
       PMS.minimal("Created socket: " + address);
       
       if (!PMS.getConfiguration().isHTTPEngineV2()) {
          serverSocketChannel = ServerSocketChannel.open();
          
          serverSocket = serverSocketChannel.socket();
          serverSocket.setReuseAddress(true);
+         serverSocket.setPerformancePreferences(0, 1, 2);
          serverSocket.bind(address);
          
          if (hostName == null && iafinal !=null)
             hostName = iafinal.getHostAddress();
          else if (hostName == null)
             hostName = InetAddress.getLocalHost().getHostAddress();
          runnable = new Thread(this);
          runnable.setDaemon(false);
          runnable.start();
          
       } else {
+         
          group = new DefaultChannelGroup("myServer");
          factory = new NioServerSocketChannelFactory(
             Executors.newCachedThreadPool(),
@@ -143,19 +153,27 @@
          ServerBootstrap bootstrap = new ServerBootstrap(factory);
          HttpServerPipelineFactory pipeline = new HttpServerPipelineFactory();
          bootstrap.setPipelineFactory(pipeline);
+         bootstrap.setOption("tcpNoDelay", true);
          bootstrap.setOption("child.tcpNoDelay", true);
+         bootstrap.setOption("keepAlive", true);
          bootstrap.setOption("child.keepAlive", true);
          bootstrap.setOption("reuseAddress", true);
          bootstrap.setOption("child.reuseAddress", true);
          bootstrap.setOption("child.sendBufferSize", 65536);
          bootstrap.setOption("child.receiveBufferSize", 65536);
+         bootstrap.setOption("trafficClass", 160);         // DSCP class 5, AC_VID has 6 bit MSB 40 decimal value, concatenated with 2bit ECN value 00
+         bootstrap.setOption("child.trafficClass", 160); 
+         
+         PMS.debug("Bootstrap Channel Traffic class " + bootstrap.getOption("trafficClass"));
+         PMS.debug("Bootstrap Child Traffic class " + bootstrap.getOption("child.trafficClass"));
          channel = bootstrap.bind(address);
          group.add(channel);
          if (hostName == null && iafinal !=null)
             hostName = iafinal.getHostAddress();
          else if (hostName == null)
             hostName = InetAddress.getLocalHost().getHostAddress();
       }
       
       return true;
Index: net/pms/network/UPNPHelper.java
===================================================================
--- net/pms/network/UPNPHelper.java   (revision 410)
+++ net/pms/network/UPNPHelper.java   (working copy)
@@ -76,6 +76,10 @@
       try
       {
          DatagramSocket ssdpUniSock = new DatagramSocket();
+         ssdpUniSock.setTrafficClass(160); //DSCP class 5:  0x28, ECN: 0x00
+         PMS.debug("Reply Traffic class " + ssdpUniSock.getTrafficClass());         
 
          PMS.debug( "Sending this reply [" + host + ":" + port + "]: " + StringUtils.replace(msg, CRLF, "<CRLF>"));
          InetAddress inetAddr = InetAddress.getByName(host);
@@ -134,9 +138,11 @@
       PMS.debug("Multicast socket is on interface: " + ssdpSocket.getInterface());
       ssdpSocket.setTimeToLive(32);
       //ssdpSocket.setLoopbackMode(true);
+      ssdpSocket.setTrafficClass(160); //DSCP class 5:  0x28, ECN: 0x00
       ssdpSocket.joinGroup(getUPNPAddress());
       PMS.debug("Socket Timeout: " + ssdpSocket.getSoTimeout());
       PMS.debug("Socket TTL: " + ssdpSocket.getTimeToLive());
+      PMS.debug("Socket Traffic Class: " + ssdpSocket.getTrafficClass());
       return ssdpSocket;
    }
    
@@ -213,7 +219,9 @@
                      socket.setNetworkInterface( PMS.get().getServer().getNi());
                   }
                   socket.setTimeToLive(4);
+                  socket.setTrafficClass(160); //DSCP class 5:  0x28, ECN: 0x00
                   socket.setReuseAddress(true);
+                  PMS.debug("Multicast Traffic class " + socket.getTrafficClass());         
                   socket.joinGroup(getUPNPAddress());
                   while(true)
                   {
bgm
 
Posts: 4
Joined: Mon Aug 02, 2010 1:25 am

Re: Patch for IP-DSCP Prioritization

Postby ExSport » Wed Sep 15, 2010 6:24 pm

Seems promissing. Any update on it? :)
ExSport
 
Posts: 2167
Joined: Mon Jan 19, 2009 5:40 pm

Re: Patch for IP-DSCP Prioritization

Postby bgm » Fri Apr 22, 2011 11:38 pm

:D

The patch works really well in wireless or ethernet, effectively activating the QoS Wireless MultiMedia extensions and other prioritizations in the network stack.
Now i am busy with the http://www.bufferbloat.net/ problem and work.

Guys a media server generates streaming traffic that have to be correctly tagged or it will conflict with normal best- effort traffic. My patch just tags the network traffic with the correct VIDEO mark.

So it is safe to apply my patch in the Official version or whatever to create the sole streaming program that correctly tag its traffic as streaming. :mrgreen:

So long and thanks for all the fish...
bgm
 
Posts: 4
Joined: Mon Aug 02, 2010 1:25 am

Re: Patch for IP-DSCP Prioritization

Postby SubJunk » Tue May 17, 2011 10:50 am

The patch was applied in r573 but we had to remove it in r585 because it was causing at least one renderer (Sony Bravia Z5500) to not work with PMS (#1042)
If you have an updated patch that could fix that I will reconsider adding it :)
SubJunk
 
Posts: 1210
Joined: Fri Mar 27, 2009 5:25 am

Re: Patch for IP-DSCP Prioritization

Postby bgm » Sat Jun 04, 2011 3:16 am

Well, i dont have one bravia to test it out, but if its not working then its the bravia is not respecting the IP protocol. even so can you confirm that if using the net engine v1 this bravia works?
bgm
 
Posts: 4
Joined: Mon Aug 02, 2010 1:25 am

Re: Patch for IP-DSCP Prioritization

Postby SubJunk » Sat Jun 04, 2011 4:07 am

bgm wrote:bravia is not respecting the IP protocol
I think that is likely.
However, unfortunately, Sony is so popular that if they don't respect the protocol then it's not practical for us to use it, either.
It's a real shame.
SubJunk
 
Posts: 1210
Joined: Fri Mar 27, 2009 5:25 am

Re: Patch for IP-DSCP Prioritization

Postby SharkHunter » Sat Jun 04, 2011 12:15 pm

Now as much as I hate it I have to defend Sony here. They are NOT violating any spec. If they where then every firewall vendor in the world is. The DSCP is just another field in the IP header taht you can perform filtering on. Fire up a linux node set some ipfilter with tos/dscp set to a pattern and those packet will be filtered. Is this a spec violation? No I would say. The DSCP is meant to give certain packets priority over others and the biggest drawback is that if no one is in control of the setting of these bits everyone will set them to max prio. Sensible routers ignore the value when they come from end users (or untrusted systems) and then sets them to whatever it feels like (usally 0).
The Sony Bravia might have some que policy stuff unknown to us and if an IP pkt comes (from an untrusted src) with these bits set to anything but 0 it is configured to drop them, just like a firewall could do.

The sensible thing to do if this helps for some renders would be to allow it to configurable, since there might be other firewalls/renders that also dislikes non-zero DSCP.
SharkHunter
 
Posts: 941
Joined: Tue Jun 01, 2010 8:39 pm

Re: Patch for IP-DSCP Prioritization

Postby SubJunk » Sat Jun 04, 2011 1:14 pm

Good points, SharkHunter
SubJunk
 
Posts: 1210
Joined: Fri Mar 27, 2009 5:25 am

Re: Patch for IP-DSCP Prioritization

Postby SharkHunter » Sat Jun 04, 2011 5:30 pm

SubJunk wrote:Good points, SharkHunter

Well I've spent too much time working with these protocols and had these discussions of RFC this and RFC that for half my life now. I'm still geekish enough to remeber all the fields of the IPv4 header. That is something that should have left my mind ages ago so my brothers girlfriends name would stick instead :)
SharkHunter
 
Posts: 941
Joined: Tue Jun 01, 2010 8:39 pm

Re: Patch for IP-DSCP Prioritization

Postby danialpaul1 » Fri Nov 25, 2011 10:26 am

are those protocols well worth your time ? If yes then ahead !
danialpaul1
 
Posts: 1
Joined: Sat Nov 19, 2011 9:42 pm

Next

Return to Developers

Who is online

Users browsing this forum: No registered users and 4 guests