Manual for Skex

Skex is a user-land tool to control the network traffic from the socket level. It depends on the socket level traffic control provided by our kernel patch and CONFIG_SOCKET_EX option must be enabled when compiling the kernel. Refer to here for how to compile the kernel. The traffic control is based on socket group.

1. What's a socket group

A socket group is a set of sockets, whose aggregate traffic is subject to some actuation constraint. Usually, the administrator specifies the socket group by only listing several listening ports. All the connections for these listening ports belong to the same socket group. For example, if the listening ports 21 and 80 are in one socket group, then all the TELNET and HTTP connections are in one socket group.

Three types of socket groups are supported:

2. Create a socket group

skex -A <type> [-n] parameter
<type> can be:
    aa:    absolute rate based accept group
    ra:    relative ratio based accept group
    ao:    absolute rate based output group
    af:    absolute rate based output group for FTP

-n: this option controls what happens when the process tries to accept/output more than allowed. When this option is specified, an error will be returned to the process. Otherwise, the process will be blocked.
This option must be specified for those services started by inetd or xinetd, because the inetd or xinet process is responsible to start more than one type of service and can never be blocked. It should also be specified for those applications that use one thread to service multiple connections.

Before creating a socket group, the application must have been started to listen to the port. Once successfully creating a group, a group id will be printed out. the other parameters depend on the socket group type,

  1. absolute rate based accept group
       skex -A aa [-n] port rate

  2. rate must be an integer

    example:
        skex -A aa -n 143 10
    each second at least 10 IMAP connections can be accepted. Since IMAP server (at least the IMAPD server by UW)  is started by inetd, -n option is used.

  1. relative ratio based accept group
        skex -A ra port value ......
    value can be a floating point value

    example:
       skex -A ra 8080 2.3 8081 1.2
    The number of the connections accepted at ports 8080 and 8081 should be maintained at the ratio of 2.3 : 1.2
       skex -A ra 8080 2.3 8081 1.2 8082 3
    The number of the connections accepted at ports 8080, 8081 and 8082 should be maintained at the ratio of 2.3 : 1.2 : 3

  2. absolute rate based output group / absolute rate based output group for FTP
       skex -A ao port value
    value must be an integer

    example:
        skex -A ao 80 1024000
    this will limit the bandwidth usage of HTTP to be at most 100KB/s
        skex -A af 21 1024000
    this will limit the bandwidth usage of FTP to be at most 1000KB/s

3.  Edit the socket group

skex -E <type> <id> parameter
<id> is the group id printed out by skex when the group is created successfully.

The other parameters are the same as those used to create a group. Note that the -n option can not be specified here.

4.  Destroy socket group(s)

skex -D <group id>
skex -F

The first will destroy a single socket group specified by <group id>. The second will destroy (flush) all the socket groups

Back to Home