{"id":3907,"date":"2013-12-17T19:33:21","date_gmt":"2013-12-17T18:33:21","guid":{"rendered":"https:\/\/www.kolja-engelmann.de\/blog\/?p=3907"},"modified":"2013-12-17T19:33:21","modified_gmt":"2013-12-17T18:33:21","slug":"ip-pakete-in-windows-78-mittels-dscp-flag-priorisieren","status":"publish","type":"post","link":"https:\/\/www.kolja-engelmann.de\/blog\/2013\/12\/ip-pakete-in-windows-78-mittels-dscp-flag-priorisieren\/","title":{"rendered":"IP-Pakete in Windows 7\/8 mittels DSCP Flag priorisieren"},"content":{"rendered":"<p>Ich werde bevormundet \ud83d\ude41 Windows schreibt mir vor was ich zu tun und zu lassen habe. Egal ob ich Administrator oder Bill Gates pers\u00f6nlich bin, Windows l\u00e4sst mich manches nicht tun und das prangere ich an.<\/p>\n<p>In einem meiner Projekte versuchte ich via C# eine TCP-Socketverbindung mit einer h\u00f6heren Priorit\u00e4t auszustatten, damit diese stets Vorrang vor den restlichen Datenpaketen auf der selben \u00dcbertragungsleitung erhalten und nicht im Falle einer \u00dcberlastsituation einfach verloren gehen oder verz\u00f6gert ankommen. Das IP-Header Feld <a href=\"http:\/\/de.wikipedia.org\/wiki\/IP-Paket#TOS_.28Type_of_Service.29\" target=\"_blank\">Type Of Service<\/a>\u00a0(ToS) oder Differentiated Services Code Point (DSCP) wie es seit 1998 genannt wird, war dazu genau der richtige Hebel. Mit den korrekten Werten gef\u00fcllt, erh\u00e4lt ein IP-Paket auf dem Windows internen Netzwerkstack Vorrang vor anderen Paketen (wird also stets vorn in die Paketwarteschlange eingereiht) und auch Netzwerkelemente auf dem Weg zum Empf\u00e4nger, lassen dieses Paket schneller passieren (nat\u00fcrlich nur wenn auch diese QoS unterst\u00fctzen und das DSCP Feld auswerten).<\/p>\n<div id=\"attachment_3908\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-field-werte.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-3908\" class=\"size-large wp-image-3908\" alt=\"tos-dscp-field-werte\" src=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-field-werte-500x184.png\" width=\"500\" height=\"184\" srcset=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-field-werte-500x184.png 500w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-field-werte-300x110.png 300w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-field-werte.png 1323w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><p id=\"caption-attachment-3908\" class=\"wp-caption-text\">Quelle: <a href=\"http:\/\/www.tucny.com\/Home\/dscp-tos\">tucny.com<\/a><\/p><\/div>\n<p>F\u00fcllt man das Feld also mit dem Wert 46 (was normalerweise im VoIP Umfeld nur dem wichtigen RTP Traffic zugestanden wird), sollten meine IP-Kontrollpakete bevorzugt behandelt werden. Also nutzte ich folgende kleine Methode, um die wichtigen Flags zu setzen:<\/p>\n<pre class=\"lang:c# decode:true\">\/\/\/ &lt;summary&gt;\r\n\/\/\/ Set socket options for the QoS parameter\r\n\/\/\/ &lt;\/summary&gt;\r\n\/\/\/ &lt;param name=\"pSocket\"&gt;&lt;\/param&gt;\r\nprivate void SetSocketOptions(Socket pSocket)\r\n{\r\n\tpSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.BsdUrgent, 1);\r\n\tpSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.Expedited, 1);\r\n\tpSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, 1);\r\n\t\/\/ Der Dezimalwert 184 entspricht dem DSCP Wert 46. .NEt unterst\u00fctzt nur das Setzen des 8bit ToS Feldes, nicht direkt des 6Bit DSCP Feldes\r\n\tpSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.TypeOfService, 184);\r\n}<\/pre>\n<p>Ein Blick in die gesendeten Pakete via Wireshark offenbarte mir jedoch, dass keine meiner \u00c4nderungen \u00fcbernommen wurden. Alle Felder blieben leer.<\/p>\n<p><a href=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/wireshark-tos-dscp-result.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-3909\" alt=\"wireshark-tos-dscp-result\" src=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/wireshark-tos-dscp-result-500x93.png\" width=\"500\" height=\"93\" srcset=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/wireshark-tos-dscp-result-500x93.png 500w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/wireshark-tos-dscp-result-300x56.png 300w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/wireshark-tos-dscp-result.png 880w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a>Wie sich herausstellte, untersagt Windows Programmen und auch Programmierern die Anpassung \u00a0dieser Werte und ersetzt sie mit dem jeweiligen Standardwert. Manche behaupten man k\u00f6nne dieses Verhalten mit zwei Eintr\u00e4gen in der Registry abstellen, andere sagen man m\u00fcsse sein Programm mit Administratorrechten starten. Bei mir half das leider alles nichts.<\/p>\n<pre class=\"lang:default decode:true\">Windows Registry Editor Version 5.00\r\n\r\n[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters]\r\n\"DisableUserTOSSetting\"=dword:00000000\r\n\r\n[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\Tcpip\\QoS]\r\n\"Do not use NLA\"=\"1\"<\/pre>\n<p>Die L\u00f6sung, wenn auch eine sehr unsch\u00f6ne, liegt in der Verwendung des Group Policy Editor <code>gpedit.msc<\/code>.<\/p>\n<ol>\n<li>\u00d6ffne gpedit.msc<\/li>\n<li>Navigiere zu Computerkonfiguration &#8211;&gt; Windows Einstellungen &#8211;&gt; Richtlinienbasierter QoS<\/li>\n<li>Erstelle eine neue Regel, w\u00e4hle einen Namen und den gew\u00fcnschten DSCP Wert<\/li>\n<li>W\u00e4hle aus f\u00fcr welche Anwendungen, Quell- und Zieladressen, Quell- und Zielports diese Regel gilt<\/li>\n<li>Fertig<\/li>\n<\/ol>\n\n\t\t<style>\n\t\t\t#gallery-1 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 33%;\n\t\t\t}\n\t\t\t#gallery-1 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div id='gallery-1' class='gallery galleryid-3907 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen3.png'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen3-150x150.png\" class=\"attachment-thumbnail size-thumbnail no-lazy\" alt=\"\" aria-describedby=\"gallery-1-3910\" srcset=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen3-150x150.png 150w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen3-160x160.png 160w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen3-120x120.png 120w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-3910'>\n\t\t\t\tGroup Policy Editor \u00f6ffnen\n\t\t\t\t<\/dd><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen1.png'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen1-150x150.png\" class=\"attachment-thumbnail size-thumbnail no-lazy\" alt=\"\" aria-describedby=\"gallery-1-3912\" srcset=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen1-150x150.png 150w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen1-160x160.png 160w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen1-120x120.png 120w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-3912'>\n\t\t\t\tDSCP Wert festlegen\n\t\t\t\t<\/dd><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen2.png'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen2-150x150.png\" class=\"attachment-thumbnail size-thumbnail no-lazy\" alt=\"\" aria-describedby=\"gallery-1-3911\" srcset=\"https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen2-150x150.png 150w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen2-160x160.png 160w, https:\/\/www.kolja-engelmann.de\/blog\/wp-content\/uploads\/2013\/12\/tos-dscp-screen2-120x120.png 120w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/dt>\n\t\t\t\t<dd class='wp-caption-text gallery-caption' id='gallery-1-3911'>\n\t\t\t\tProgramm\/Adresse\/Ports definieren\n\t\t\t\t<\/dd><\/dl><br style=\"clear: both\" \/>\n\t\t<\/div>\n\n<p>Nach dieser Anpassung wurden meine Kontrollpakete sofort (ohne Neustart) bevorzugt durch das Netz gesendet und konnten trotz \u00dcberlastsituation meinen Client steuern. Warum ich jedoch selbst als Programmierer diese Werte nicht im Code anpassen kann, sondern auf den Gruppenrichtlinieneditor zur\u00fcckgreifen muss, wird wohl ein Microsoft&#8217;sches R\u00e4tsel bleiben.<\/p>","protected":false},"excerpt":{"rendered":"<p>Ich werde bevormundet \ud83d\ude41 Windows schreibt mir vor was ich zu tun und zu lassen habe. Egal ob ich Administrator oder Bill Gates pers\u00f6nlich bin, Windows l\u00e4sst mich manches nicht tun und das prangere ich&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[98,39],"class_list":["post-3907","post","type-post","status-publish","format-standard","hentry","category-allgemein","tag-net","tag-c"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/posts\/3907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/comments?post=3907"}],"version-history":[{"count":0,"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/posts\/3907\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/media?parent=3907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/categories?post=3907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kolja-engelmann.de\/blog\/wp-json\/wp\/v2\/tags?post=3907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}