{'fraction_non_alphanumeric': 0.026214931779855895, 'fraction_numerical': 0.005212325617047371, 'mean_word_length': 4.98019801980198, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Boundaries of Flow Table Usage Reduction Algorithms Based on Elephant Flow Detection

The majority of Internet traffic is caused by a relatively small number of flows (so-called elephant flows). This phenomenon can be exploited to facilitate traffic engineering: resource-costly individual flow forwarding entries can be created only for elephants while serving mice over the shortest paths. Although this idea already appeared in proposed TE systems, it was not examined by itself. It remains unknown what extent of flow table occupancy and operations number reduction can be achieved or how to select thresholds or sampling rates to cover the desired fraction of traffic. In this paper, we use reproducible traffic models obtained from a 30-day-long campus trace covering 4 billion flows, to answer these questions. We establish theoretical boundaries for flow table usage reduction algorithms that classify flows since the first packet, after reaching a predefined counter threshold or detect elephants by sampling. An important finding is that simple packet sampling performs surprisingly well on realistic traffic, reducing the number of flow entries by a factor up to 400, still covering 80% of the traffic. We also provide an open-source software package allowing the replication of our experiments or the performing of similar evaluations for other algorithms or flow distributions.


I. INTRODUCTION
It is widely believed that the distribution of flow lengths and sizes in the Internet follows the Pareto principle: the majority of traffic is comprised of a relatively small number of flows. Such flows are called elephant flows. The remaining flows, which are large in number but carry very little traffic, are called mice flows. In practice, flow length and size distributions are even more long-tailed than the Pareto rule (80/20) assumes. According to recent analysis, 80% of traffic is caused by only 0.2-0.4% of flows [1] [2].
This phenomenon can be exploited to facilitate quality of service (QoS) provisioning and traffic engineering (TE). In per-packet routing, due to loop prevention constraints, only a subset of disjoint paths existing between selected nodes can be used [3]. Adaptive (load-sensitive) routing is also impossible in a per-packet approach, as the dynamic alteration of link costs leads to instability (route flapping) which ultimately deteriorates network performance; this has been shown by early ARPANET pitfalls [4] and definitively proven in [5].
Flow-based routing can overcome these problems by maintaining separate per-flow forwarding entries. It allows flows between the same endpoints to follow any number of alternative paths. Adaptive flow routing is also more stable than selecting paths at the packet level, as the load on each link fluctuates more slowly, as has been shown in [6]. To sum up, with flow-based routing more traffic can be served using existing infrastructure, reducing the need for links oversubscription.
However, despite recent technological advancements, the number of simultaneous flows in networks still overwhelms the capacities of switch flow tables [7]. Moreover, in the case of centralized control plane usage, controller throughput can impose additional limits on the rate of incoming flows. This is confirmed in practice. The real deployments, like Google's B4 [8], are limited to proactive systems. Such systems forward packets according to predefined, per-prefix shortest-path entries. Specific entries are created for heavyhitter aggregates, which are detected basing on external information (for example, a notification of an expected migration between datacentres). In the case of non-private WANs, such a piece of information is not available. A possible solution would be to focus on dynamically identified elephant flows. This would significantly reduce the number of flow entries while simultaneously keeping most traffic covered by TE.
The problem is early identification of whether a particular flow is, or more precisely will become an elephant. Issues related to elephant flow detection have been the subject of many papers. However, most works have been directed in the context of flow accounting and monitoring and focus on detection accuracy. In the case of traffic engineering, detection accuracy is not the most important issue. Instead, the focus should be put on the moment of identification, and particularly on the amount of traffic transmitted by the flows after their classification as elephants (i.e. when they have individual entries) and the resulting reduction in flow table occupancy. None of the previous works analyzes these parameters or provides numerical boundaries for them.
Moreover, any elephant-related mechanism performance strictly depends upon flow length and size distribution. Papers make different, and often over-simplistic and arbitrary assumptions, for example by considering constant elephantto-mice ratio and sizes, which do not correspond with reality. Other papers use distributions obtained from real traffic traces; however, they are either irreproducible or simplified to a single distribution function.
The definition of elephant flow is another factor, which differs among many papers. The analysis presented in this paper is independent of the elephant flow definition. We did not assume a fixed elephant definition, because we do not focus on strict classification of flows as mice or elephants. Instead, our goal is the statistical reduction of flow table occupancy.
This paper aims to fill the gap in research and provide numerical boundaries for the performance of flow table usage reduction algorithms. The key point of our research is the use of realistic, accurate, and reproducible flow length and size distributions. We analyze the performance of three approaches, which can provide boundaries to several classes of elephant detection algorithms: • first, which assumes a pre-established knowledge about flow length/size and classifies it accordingly since its first packet, • threshold, which classifies a flow as an elephant after transmitting a predefined amount of packets or bytes, • sampling, which performs packet sampling and classifies flows in a probabilistic manner.
Similar ideas have appeared already as a part of proposed TE systems (see Section II: Related works). However, metrics in these papers were related to overall TE system performance (like packet loss). The trade-off between table occupancy reduction and traffic coverage has not been analyzed. Therefore, the novelty of this paper lies in: • Analysis of parameters relevant to traffic engineering in the context of SDN: the fraction of traffic covered, reduction of the number of flow entry operations (and thus controller traffic), and reduction of flow table occupancy. • Providing theoretical upper and lower boundaries for several classes of flow table usage reduction algorithms based on elephant flow classification. • Use of realistic and accurate distribution mixtures obtained from 30-day-long 4-billion flow trace of campus/residential traffic, which is many orders of magnitude more than in previous research. • Reproducibility of the research, as both the distribution mixtures and code used for analysis are provided as an open-source package [9].
II. RELATED WORKS The idea of performing adaptive routing only for elephants while keeping mice on the shortest paths is not new. According to our knowledge, it was first proposed in 1999 in [10]. The authors, however, did not solve the problem of detecting elephant flows. They propose the usage of per-flow counters or timers, which is pointless considering that our goal is the reduction in the number of tracked flows and flow table operations. Moreover, their analysis is based on a one-week trace collected in 1997, which is both outdated and too short. A similar approach was proposed in [11], but concerned the top destination IP prefixes (so-called heavy hitters) instead of 5-tuple flows.
This approach has been recently reiterated, specifically in the SDN context. The general idea is to initially install shortest path wildcard entries and monitor the traffic in order to identify elephant flows. After identification, the controller can compute alternative non-congested paths for them based on the global network view and install individual entries for these most significant flows in order to load-balance traffic.
Hedera [12] was proposed as a dynamic flow scheduling system for datacentres, aimed at going beyond equal-cost multipath (ECMP) routing limitations. By default, all flows are load-balanced onto ECMP paths. Such a path is used until the flow grows and meets a predefined threshold rate. After reaching the threshold, elephants are rerouted in midconnection onto flow-specific paths, computed dynamically by the controller. Hedera assumes that the edge switches collect flow statistics for all flows using OpenFlow counters. This means that it actually only reduces non-edge switches overhead, while the edge switches still have to maintain individual entries for all flows.
In 2011, Curtis et al. presented a system called Mahout [13]. Unlike Hedera, it performs elephant detection at the end hosts by monitoring socket buffers (via a shim layer in the OS). After reaching a predefined threshold, it marks subsequent packets of flow using an in-band signaling mechanism. The switches in the network are configured to forward these marked packets to the controller, which as with Hedera computes the best path and installs flow-specific entries in switches. With that approach, overhead can be eliminated from the switches and controller, as elephant detection is moved to end hosts, which however must be modified.
DevoFlow [14] is another example of a complete TE system based on modified Openflow switches, which key feature is focusing on significant flows. To detect these flows, it explores both threshold and sampling approaches, which is similar to this paper. However, the traffic model used in DevoFlow was a datacentre workload, which considerably differs from the residential/ISP load. Moreover, the authors "reverse engineered" the flow distributions they used from plots presented in another paper and did not make them available, which makes their results both inaccurate and unreproducible. Authors do not analyze the amount of traffic covered. Instead, the only performance indicator provided is the aggregate throughput of the whole network, which also depends on topology, demands matrix, and routing decisions. Only absolute values of the number of flow entries are provided, so the relative reduction of table occupancy also cannot be determined. Only three thresholds/sampling probabilities are analyzed, whereas our paper provides analysis for the continuous spectrum of values.
A similar system to DevoFlow is proposed in [15]. It detects elephant flows only on edge switches with the use of a Bloom filters variant, called randomized counter sharing. However, the traffic model used for the evaluation of this mechanism is oversimplified: the authors assume the power law for the flowsize distribution, where 20% of all flows account for 80% of traffic volume. This is, as shown in [1] and [2], far from reality.
OpenSample [16] is a TE system based on the rerouting of elephant flows, which are detected by sampling packet headers on switches with sFlow. The authors claim that it can achieve a low latency of measurements with a high degree of accuracy. Unlike Mahout and MicroTE, OpenSample can be implemented without end host modifications and unlike Hedera, it does not require the use of expensive OpenFlow counters. The authors provide an analysis of the percentage of traffic covered after detection and after rerouting. However, the used traffic model is extremely simplified. They consider only two classes of flows, short flows with an exponential distribution of mean 1 MB size, and long flows with the same exponential distribution but a 1 GB mean flow size. The paper also does not analyze flow table occupancy reduction.
Planck [17] is another system, similar to OpenSample. It deserves special attention because it does not use sFlow for packet sampling. Instead, the authors propose the use of a port mirroring feature to redirect all packets to a single monitoring port. Because the total traffic forwarded through the switch usually exceeds the capacity of the monitoring port, some packets are dropped, which effectively provides a packet sample. Such an approach has several advantages over sFlow, specifically, the reduced load of switch CPU and significantly lower latencies. As a result of this, the Planck-based traffic engineering system can reroute congested flows within milliseconds, which can improve its overall performance.
The following surveys provide a good overview of SDN traffic engineering systems: [18] [19]. The use of packet sampling for traffic engineering purposes is indicated in [20], which also provides a good overview of other packet sampling techniques. It has to be noted that several other, non-sampling based techniques for elephant/heavy-hitters detection and flow  [32].
Moreover, in the wake of growing machine learning popularity, it recently started being employed as well. Going specifically to flow classification based on the first packet, in [33] authors propose a machine learning based flow classification based on for the NFV offloading. Classification is performed using features extracted from the header of the first packet (5tuple, size of the first packet). In [34] prediction of new flows size and duration is done at the flow start through a Locally Weighted Regression (LWR) model, using the previous flows behavior and its temporal correlation with the new flow.
To sum up, most of the works mentioned in previous paragraphs focus on the issue from the network monitoring or accounting point of view. The main evaluated parameters are related to detection accuracy; it includes false positive ratio, false-negative ratio, and the precision of flow length/size estimation from the sample. On the other hand, papers focusing on the concept from SDN and traffic engineering point of view, examine the performance of the TE whole system and analyze metrics like network throughput or packet loss. Therefore, despite the idea already appeared as a part of proposed systems, it has not been examined in isolation. Its numerical performance boundaries are yet to be explored.

A. First
In the first algorithm, a flow entry is created on the arrival of the flow's first packet when the length/size of flow will exceed the selected threshold. Thus, it assumes that based on the first packet, the length/size of the whole flow can be determined. The flowchart of the first algorithm is show in Figure 1.
It is impossible to achieve in reality: it is not possible to know in advance how long a flow will be, despite that classification with the first packet would be the most beneficial. Classifying a flow correctly with the first packet would allow avoiding rerouting it in the middle. Flow rerouting may result in transport layer issues. Specifically, packets may become reordered, which can cause their retransmission. Additionally, path change can misdirect congestion control algorithms, which usually work basing on observed path delay and throughput estimation.
However, the first approach is still worth evaluating, because it can provide an upper boundary for the performance of all elephant detection algorithms. Moreover, an (imperfect) flow classification with the first packet can be achieved with the help of machine learning based algorithms, which attempt to predict the flow length/size basing on header values. Such algorithms are becoming a hot research topic, especially in combination with their realization in programmable dataplanes, like P4 [28] [35]. Thus, the results of first approach will provide an upper baseline for all of these research.

B. Threshold
As already mentioned, in practice switches cannot know in advance whether a newly appeared flow will eventually become an elephant or a mice flow. Thus, they cannot create an entry for this flow when its first packet appears. Instead, flow entry can be created when the amount of traffic or the number of transmitted packets exceeds a certain elephant detection threshold. The most trivial approach is to use per-flow counters on each switch. A counter reaching a threshold would cause a flow entry to be created. This is the outline of threshold algorithm, which is shown in Figure 2.
Such an algorithm is realizable, however, it has obvious drawbacks. Per-flow counters must be stored and updated with each packet. In the case of OpenFlow, flow entries aimed at packet counting use the same memory as any other flow entry, so it would not yield any reductions in flow table usage. In the case of other data plane technologies, the low-overhead implementation of accurate per-flow counters may be possible, as shown by TurboFlow for P4 [36]. Moreover, solutions based on inexact counters, like Bloom filters or sketches, can also classify elephant flows after reaching a predefined threshold, at the same time requiring a reduced amount of memory. Thus, the results of the threshold algorithm can provide an upper bound for all algorithms, which are based of any kind of counting. This includes exact counters and inexact counting methods, based on Bloom filters or sketching.

C. Sampling
An alternative approach is to use sampling. Packets without entries in flow tables can be randomly sampled with some probability p. If a packet is sampled, a new flow entry is created and subsequent packets of that flow are forwarded in accordance with it, without being sampled. Otherwise, the packet is forwarded basing on aggregated (usually ECMP) entry without the creation of a flow entry, and sampling is performed for the rest of the packets until a flow entry is created, as shown in Figure 3.
The probability that a flow has an entry in the flow table after reaching n packets is given by: This means, that by adjusting p, a network operator can adaptively control how many flow entries will be stored in tables and how much traffic will be covered by them.
The sampling algorithm can also be used to sample flows according to their size. In this way, larger packets have a greater probability of being sampled. Such an approach is called Non-Uniform Probabilistic Sampling in RFC 5475 [37]. It is enough to scale the sampling probability for each packet proportionally to its size. In our simulation, we scaled provided sampling probabilities by relative packet size: • s is the packet size, and • s max is the maximum packet size. In our calculations and simulations, we assume that sampling is performed only on edge switches (i.e. any given packet can be sampled only once when it enters the network). An alternative setup would be a network in which all switches sample packets independently (i.e. a packet is sampled on all switches on its path). In such a case, the effective sampling probability value can be calculated using the following equation: where: • p ef f is the effective sampling probability, • P (k) is the probability of going through path k, is the probability of being sampled at switch i of path k, and • l (k) is the length of this path. Assuming that the probability of going through the each path is the same (i.e. each switch is traversed by a high number of flows, going through a variety of paths), the above equation can be simplified to: where: • p is the sampling probability set by the operator on a single switch, and • l avg is the average length of path in the network.
The p ef f value, calculated with the above equation, can be used to read values from tables presented in Appendix A to determine what traffic coverage and occupancy reduction will be achieved with selected p in the case of all-switch sampling.
The advantage of sampling method is that it is stateless, i.e. there is no need to store and update any kind of counters. Additionally, it has a negligible performance impact, as random number generation can be performed using a hardware random generator or a simple software pseudorandom generator with a few CPU cycles. The P4 standard allows to perform sampling in dataplane 1 . Alternatively to on-switch sampling, a lowoverhead port mirroring based approach can be used, as proposed in Planck system [17]. However, as classification happens not with the first packet, but in the middle of a flow, it may cause rerouting resulting in transport layer issues. Nevertheless, it provides a lower boundary for all algorithms which classify flows not on the first packet.

IV. RESULTS
In this section, we present the results of the simulations, as well as analytical calculations. The following parameters are analyzed: • traffic coverage -the percentage of traffic (bytes) in the network which were transmitted by flows after their detection (i.e. when they had an individual entry), • operations reduction -the factor by which the number of flow entry additions/removals (and thus the controller traffic) can be reduced, • occupancy reduction -the factor by which the average number of flow entries in tables can be reduced. All these values are presented relative to the baseline case, in which all flows have their entries created with their first packets (the classic SDN reactive mode). In our analysis we assume that all flows have the same rate. This means that, as long we focus only on relative performance metrics, any flow aging issues are irrelevant here.
As already mentioned, flow size and length distributions have a crucial impact on the performance of any elephantrelated algorithms. In this paper we use flow length and size distributions from the agh_2015 dataset presented in [2]. These are based on traffic traces collected on the outgoing interface of the campus/residential network. Unlike CAIDA traces, which are truncated to one hour, which distorts tails of distributions and therefore makes them unsuitable for such analysis, they were collected over a continuous period of 30 days and consisting of more than 4 billion flows. Both the timespan of the collection and the number of flows are many orders of magnitude higher than in previously published flow statistics. These distributions are in line with selected values of CAIDA and BME traces presented in [1], which confirms their credibility. The authors of [2] provide accurately fitted distribution mixture models. They allow an analytical calculation of all the performance parameters of the evaluated algorithms, which also would be impossible with the CAIDA data. We also use them to generate flow samples in packetlevel simulations.
For selected values of thresholds (in cases of first and threshold algorithms) and sampling probability (in the case of sampling algorithm) we performed packet-level simulations. Packets were randomly generated, basing on the distribution mixtures from the used traffic model. For each value of threshold/sampling probability, we performed the experiment five times with different random seeds, each time generating 1 billion flows, and calculated mean values from these five runs. All algorithms are evaluated using both flow length (number of packets) and flow size (amount of bytes) as an elephant classification criterion. Results of these simulations are shown in Table II and Table III provided in Appendix A. Additionally, we use distribution mixture equations provided in [2] to calculate the performance for a continuous spectrum of threshold/sampling probability values, which is impossible with simulations. This allows straightforward plotting and comparison of algorithms performance against each other.
Analytically calculated reduction of flow table occupancy is shown in Figure 4 on y-axis (logarithmic). Similarly, reduction in number of operations is presented on Figure 5. The x-axis (linear) on both figures is the desired traffic coverage. In the occupancy calculation, we assumed that the average packet interarrival time is the same for all flows. The presented results of analytical calculations are in line with selected values obtained in simulations, which confirms their correctness.
It can be seen that the first algorithm achieves the best performance. For any target traffic coverage, it gives the largest reduction, both in flow table occupancy and operations number. Additionally, in the case of the first algorithm, operations number and occupancy reduction factors are the same. While its implementation is impossible in practice, the results are still valuable as they provide an upper boundary for all flow table usage reduction algorithms based on elephant/mice classification. Because of that, on Figure 6 and Figure 7, we also show the analytically calculated performance of all algorithms relative to it.
In the case of threshold algorithm, the average reduction of flow table occupancy is always higher than the reduction of the number of flow entry operations. This is expected as flows are added not with their first packet but with some subsequent packet, so they occupy the flow table for only a fraction of their lifetime. Unfortunately, the same applies to traffic coverage. To achieve similar traffic coverage, a lower threshold value has to be used than in the first approach, which also results in lower table occupancy reduction. Occupancy in the case of threshold algorithm is approximately 1.5 times higher than with the first and the number of flow entries operations is 2-3 times higher. Its usability is limited in OpenFlow switches, but lowoverhead implementation may be possible in other dataplane technologies (such as P4). Apart from that, it provides an upper boundary for all algorithms based on some kind of inexact counting, for example, Bloom filters or sketches.
In the case of sampling algorithm, similarly as in threshold, the average reduction of flow table size is higher than the reduction of the number of flow entry operations, for the same reason. It can be also seen that, in general, decreasing sampling probability results in an exponential increase in the flow table occupancy reduction, but only in a linear decrease in traffic coverage. In the case of sampling algorithm, occupancy is 2-4 times higher and operations number is 3-7 times higher than in the first. However, the numbers are still high. For example, with a target of 80% traffic coverage, which we believe is a fair target in TE case, it can reduce the number of flow table entries by a factor of 225 (packet sampling) or 401 (size-based non-uniform sampling). Thus, the performance of sampling stays within the same order of magnitude as the performance of first and threshold algorithms. Unlike them, it is trivial to implement, has negligible computational overhead, and does not require any memory.
Finally, all algorithms achieve better performance when size is used as a threshold/sampling base. This can be attributed to the fact that longer flows have a larger average packet size.    Flow   In this paper, we use flow sizes to calculate traffic coverage. However, it would be more beneficial to maximize the coverage of flow rates. It has been shown that there is a correlation between flow sizes and rates [38]. Therefore, the idea that high-rate flows could be identified using flow sizes is theoretically correct [39]. Nevertheless, it may be interesting to directly use flow rates for traffic coverage calculations.
Similarly, we assumed that packet interarrival time is the same for all flows and does not depend on flow length or size, in other words, that the flow duration is proportional to flow length/size. Using real flow durations to calculate occupancy would give more accurate results. However, the calculation of flow rate and duration distributions requires accurate timestamps. Hardware NetFlow agents usually cannot assign accurate timestamps to generated flow records [40]. Therefore, packet traces instead of flow records should be analyzed in order to obtain accurate flow rate and duration distributions. Unfortunately, sufficiently long packet traces are not publicly available (CAIDA traces, as we already stated, are truncated to one hour).
In our research, we followed the NetFlow default 15 seconds inactive timeout. It will be interesting to perform similar evaluations for flows with other timeouts, especially subsecond (so-called flowlets). Flowlet-based traffic engineering is an interesting concept since the number of simultaneous flowlets is several orders of magnitude lower than the number of simultaneous flows. However, we also expect that gains from elephant-mice flow differentiation will be lower for flowlets.
Another interesting research direction is the usage of elephant-based traffic engineering in distributed systems. In centralized approaches, all switches send detected elephants to the central controller, which installs flow-specific paths on all switches at once. In distributed systems, the installation of elephant flow-specific entry would have to be coordinated between all switches without the usage of a central controller.
Implementation aspects are also very important. The exact counting of packets of all candidate flows is resource-intensive in OpenFlow switches. Novel dataplane technologies, like P4 or eBPF, can allow the implementation of low-overhead perflow counters [36]. An interesting alternative is the inexact counting of significant queue contributors based on count-min sketches, which was proven to run on P4 switch at line rate and identify elephants with high accuracy and low latency [32]. High performance and low latency out-of-band sampling mechanisms, like [17], are also an interesting research topic.

VI. CONCLUSIONS
The contribution of this paper is fourfold. First, it examines elephant-based flow table usage reduction approaches from the traffic engineering point of view. The idea, although already appeared as a part of some TE systems, was not analyzed numerically in isolation. It remained unknown what extent of flow table occupancy and operations number reduction can be achieved, how to select thresholds or sampling rates to cover the desired fraction of traffic.
Secondly, the presented results of the first and threshold algorithms provide upper boundaries for whole classes of flow table usage reduction algorithms. The Table I presents boundaries provided by each of the analyzed algorithms. Such boundaries were not previously available.
Thirdly, we discovered the surprisingly good performance of the sampling algorithm. It introduces a negligible overhead to the packet processing pipeline and does not require any memory (unlike counters or Bloom filters), yet when applied to realistic traffic, it can reduce the number of flow entries by a factor of 400, while still maintaining 80% of the traffic covered by individual flow entries. Thus, it can provide a lower bound for the performance of other algorithms and in cases when flow rerouting is acceptable, it can eliminate the need for more sophisticated solutions.
Finally, the key aspect of our analysis is the usage of accurate and reproducible flow length and size distribution mixtures. The accuracy of used distributions has a crucial impact on results. We acknowledge that various networks can have different distributions; therefore, we provide an opensource software package allowing both the replication of our experiments and the performing of similar evaluations for other algorithms or flow distributions [9].
The elephant detection for forwarding purposes is becoming currently an attractive research topic (e.g. ML-based detection in P4). However, to analyze more sophisticated solutions, baselines and theoretical boundaries need to be established first. This is the goal of this paper. It sets the baseline for analysis of the performance of flow table occupancy reduction algorithms of various classes and provide methodology, traffic model and software which can be used by other researchers.

ACKNOWLEDGMENT
The research was carried out with the support of the project "Intelligent management of traffic in multi-layer Software-Defined Networks" founded by the Polish National Science Centre under project no. 2017/25/B/ST6/02186.

APPENDIX
The tables below present packet-level simulation results for all analyzed algorithms. They can be also used as reference for researchers and network operators on how to set threshold values or sampling probabilities to achieve a desired traffic coverage or flow table usage reduction.