functions as a Layer 3 switch. The implementation
methodology is based on the flow identification by
packet capture as well as the policy routing
technique supported by the Linux OS. In the
implementation, a flow is defined as a TCP
connection, which is identified by the five-tuples of
protocol, source/destination addresses, and
source/destination ports in a packet header. This
means that the program is dedicated to the
distribution of TCP traffic across the network.
Because many applications are provided on the
TCP, it is rational to focus on TCP flows as the first
step of the study. To implement the rebalancing
algorithm for TCP flows, it is important to address
the following points:
How to detect the generation and completion
of a flow.
How to find the index (= k) of a destination
switch from the packets of a flow.
How to route packets of a flow to a middle
switch, which is selected by the algorithm and
generally not the same as that for a different
flow with the same destination.
The implemented program addressed these
points by capturing packets using the pcap library,
[18] and the Linux policy routing mechanism, [19].
From the captured packets, the program detects the
start and completion of a flow. The destination
switch of a flow can be identified from the
destination address of a captured packet by
appropriately associating the host-side network
addresses to the input/output switch index. The
Linux policy routing mechanism enables the
program to forward packets to the middle switch
selected by the algorithm, depending on not only the
destination address but also other flow identifier
elements, such as the source address and port
numbers.
The program uses the pcap library to capture
either TCP SYN or FIN packets, which are destined
for hosts connected to other input/output switches.
Through an SYN packet arrival, the program detects
the start of a new flow.
From the destination address of an SYN packet,
the program identifies the destination switch k
through the association between the destination
network address and switch index k. In our
implementation, the host-side network addresses of
an input/output switch k are set to the range of
192.168.p + qk.0/24 to 192.168.p + q(k + 1) –
1.0/24, where p and q represent integers such that
p + q(m + 1) < 256. Then, if the destination address
is 192.168.x.y
switch index k is
immediately computable by (x – p) / q.
When an SYN packet is detected at an
input/output switch i and its destination switch k is
identified as mentioned above, the rebalancing
algorithm is executed to determine a middle switch j
from F(i, 1, k), F(i, 2, k),…, F(i, m, k). Furthermore,
the route for the flow is set to forward packets to j
and updates F(i, j, k). The program of each
input/output switch i manages F(i, j, k) using a two-
dimensional array indexed by j and k. It is
unnecessary for switch i to know the F(i, j, k) of
other switches i (i i). The flow identifier of a new
flow, index j of the selected middle switch, and
index k of the destination switch are stored in a hash
table T. The information recorded in T is necessary
for flow completion and rerouting. The flow
identifier is also stored in a list L, which is used in
the flow rerouting process.
The completion of a flow is detected by the
receipt of a FIN packet. The program extracts the
flow identifier from the packet header and searches
for its middle switch j and destination switch k from
table T. Then, the hash table entry is deleted.
Moreover, the routing (i.e., packet marking rule,
explained below) for that flow is removed from the
“mangle” table through the “iptables” command.
This removal of the marking rule is performed one
or more seconds later after the FIN detection to
forward the ACK packet for the FIN packet from
the remote host. With the completion of the flow,
F(i, j, k) is updated. The rerouting of an existing
flow is performed if necessary. The flow to be
rerouted is selected from the flow list L. The list L is
periodically updated by removing completed flows.
Routing is performed through m routing tables
rt1, rt2, …, rtm, where rtj is set to route packets to a
middle switch j. Each table is associated with a rule,
which sets packets marked with j to refer to rtj. The
rules are configured through the Linux “ip rule”
command. The rule-setting process is performed in
the initialization phase of the program. Provided that
the rules are properly set, assume that the algorithm
selects a flow to be routed to the middle switch j. In
this situation, the program marks the packets of the
flow with j. This marking is achieved by applying
the “iptables” command to the “mangle” table, with
the “--set-mark” option. Through these operations,
the packets of the flow are successfully routed to the
middle switch j.
A drawback of this scheme is that the SYN
packet is not marked. Thus, it is dropped because a
proper table is not found for the packet. To avoid
this, the program sets every SYN packet to be sent
to a default route. In addition, RST packets are also
WSEAS TRANSACTIONS on CIRCUITS and SYSTEMS
DOI: 10.37394/23201.2022.21.29
Satoru Ohta, Daichi Miyamoto