-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set DiffServ (QoS) bit on Outbound Connections
The QoS option is configurable using DiffServ names AF11, etc. DiffServ names correspond with rfc4594 recommended values, that are also implemented with iptables. A ToS bit is Configurable using DefaultConnectionOptions.TosPriority configuration parameter on create server. The QoS feature was implmeented with a dual stack network in mind. setsockopt will throw an error if the wrong address family flag is called. - Adding Configuration Parameter TosPriority to ConnectonOptions. - dscpName to interger value in tos.go. - Test dscp value mapping is compliant with RFC4594 recommened values. - TestTosPriority in connection_test.go to verify the outgoing socket has the correct ToS Bit set. - Helper function IsTosPriority to determine if bit matches
- Loading branch information
Showing
7 changed files
with
231 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) 2015 Uber Technologies, Inc. | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package tos | ||
|
||
// ToS represents a const value DF, CS3 etc | ||
// Assured Forwarding (x=class, y=drop precedence) (RFC2597) | ||
// Class Selector (RFC 2474) | ||
// IP Precedence (Linux Socket Compat RFC 791 | ||
type ToS uint8 | ||
|
||
// Assured Forwarding (x=class, y=drop precedence) (RFC2597) | ||
// Class Selector (RFC 2474) | ||
|
||
const ( | ||
// CS3 Class Selector 3 | ||
CS3 ToS = 0x18 | ||
// CS4 Class Selector 4 | ||
CS4 ToS = 0x20 | ||
// CS5 Class Selector 5 | ||
CS5 ToS = 0x28 | ||
// CS6 Class Selector 6 | ||
CS6 ToS = 0x30 | ||
// CS7 Class Selector 7 | ||
CS7 ToS = 0x38 | ||
// AF11 Assured Forward 11 | ||
AF11 ToS = 0x0a | ||
// AF12 Assured Forward 11 | ||
AF12 ToS = 0x0c | ||
// AF13 Assured Forward 12 | ||
AF13 ToS = 0x0e | ||
// AF21 Assured Forward 13 | ||
AF21 ToS = 0x12 | ||
// AF22 Assured Forward 21 | ||
AF22 ToS = 0x14 | ||
// AF23 Assured Forward 22 | ||
AF23 ToS = 0x16 | ||
// AF31 Assured Forward 23 | ||
AF31 ToS = 0x1a | ||
// AF32 Assured Forward 31 | ||
AF32 ToS = 0x1c | ||
// AF33 Assured Forward 32 | ||
AF33 ToS = 0x1e | ||
// AF41 Assured Forward 33 | ||
AF41 ToS = 0x22 | ||
// AF42 Assured Forward 41 | ||
AF42 ToS = 0x24 | ||
// AF43 Assured Forward 42 | ||
AF43 ToS = 0x26 | ||
// EF Expedited Forwarding (RFC 3246) | ||
EF ToS = 0x2e | ||
// Lowdelay 10 | ||
Lowdelay ToS = 0x10 | ||
// Throughput 8 | ||
Throughput ToS = 0x08 | ||
// Reliability 4 | ||
Reliability ToS = 0x04 | ||
// Lowcost 2 | ||
Lowcost ToS = 0x02 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package tos | ||
|
||
import "fmt" | ||
|
||
var ( | ||
_tosNameToValue map[string]ToS | ||
_tosValueToName = map[ToS]string{ | ||
CS3: "CS3", | ||
CS4: "CS4", | ||
CS5: "CS5", | ||
CS6: "CS6", | ||
CS7: "CS7", | ||
AF11: "AF11", | ||
AF12: "AF12", | ||
AF13: "AF13", | ||
AF21: "AF21", | ||
AF22: "AF22", | ||
AF23: "AF23", | ||
AF31: "AF31", | ||
AF32: "AF32", | ||
AF33: "AF33", | ||
AF41: "AF41", | ||
AF42: "AF42", | ||
AF43: "AF43", | ||
EF: "EF", | ||
Lowdelay: "Lowdelay", | ||
Throughput: "Throughput", | ||
Reliability: "Reliability", | ||
Lowcost: "Lowcost", | ||
} | ||
) | ||
|
||
func init() { | ||
_tosNameToValue = make(map[string]ToS, len(_tosValueToName)) | ||
for tos, tosString := range _tosValueToName { | ||
_tosNameToValue[tosString] = tos | ||
} | ||
} | ||
|
||
// MarshalText implements TextMarshaler from encoding | ||
func (r ToS) MarshalText() ([]byte, error) { | ||
return []byte(_tosValueToName[r]), nil | ||
} | ||
|
||
// UnmarshalText implements TextUnMarshaler from encoding | ||
func (r *ToS) UnmarshalText(data []byte) error { | ||
v, ok := _tosNameToValue[string(data)] | ||
if !ok { | ||
return fmt.Errorf("invalid ToS %q", string(data)) | ||
} | ||
*r = v | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters