{'fraction_non_alphanumeric': 0.03239326282804544, 'fraction_numerical': 0.009674892283587935, 'mean_word_length': 4.49161109916111, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On Routing Optimization in Networks with Embedded Computational Services

Modern communication networks are increasingly equipped with in-network computational capabilities and services. Routing in such networks is significantly more complicated than the traditional routing. A legitimate route for a flow not only needs to have enough communication and computation resources, but also has to conform to various application-specific routing constraints. This paper presents a comprehensive study on routing optimization problems in networks with embedded computational services. We develop a set of routing optimization models and derive low-complexity heuristic routing algorithms for diverse computation scenarios. For dynamic demands, we also develop an online routing algorithm with performance guarantees. Through evaluations over emerging applications on real topologies, we demonstrate that our models can be flexibly customized to meet the diverse routing requirements of different computation applications. Our proposed heuristic algorithms significantly outperform baseline algorithms and can achieve close-to-optimal performance in various scenarios.


I. INTRODUCTION
Modern communication networks are increasingly equipped with in-network computational capabilities and services. Software-Defined Networking (SDN) [1] [2] technology can decouple data plane and control plane, and the routing decision can be made in a centralized fashion rather than hop-by-hop, utilizing more information for better routing decision. Traffic flows traversing such networks are processed by different types of middle-boxes in-flight. For example, in a 5G [3] core network, traffic from/to mobile user devices must pass through special network elements, including eNodeB, serving gateways, and packet data network gateways. To improve security and/or boost application performance, an application flow may also traverse other types of middle-boxes for application-specific processing, e.g., intrusion detection and prevention, content caching to reduce latency and network traffic, rendering of VR/AR objects to offload user devices, object detection from video/lidar camera data acquired by autonomous vehicles, etc. In a cloud-native network, to improve performance and resilience, middle-boxes are replicated throughout the network, and can be elastically provisioned on commodity servers through Network Function Virtualization (NFV) [4] [5].
Routing is a critical component of networking. The main goal of the traditional network routing is to forward user traffic to their destinations with the lowest possible delay, while maintaining the network-wide load balance and resilience. Routing in networks with embedded computational services is significantly more complicated. It has to find a path for each flow that simultaneously has sufficient bandwidth and computation resources to meet the flow's traffic and computation demands. Load balance and resilience have to be maintained on both communication links and computing nodes. To further complicate matters, application-specific computational services will introduce diverse additional routing requirements. Some application flows have to traverse multiple types of middle-boxes in certain preset orders, and the routing path may have to contain cycles. The traffic volume of a flow might increase or decrease after processing, consequently, the flow conservation law no longer holds. Some applications require the computation to be done on a single computation node, while some applications can split their computation load to multiple paths and multiple nodes to achieve the parallelization gain. How traffic and computation are split directly impacts the load balance and resilience of the whole network. The existing routing models cannot directly address these new challenges and requirements. The goal of our study is to comprehensively explore the design space of routing in networks with embedded computational services. We develop a set of routing optimization models and derive low-complexity heuristic routing algorithms for diverse computation scenarios. Towards this goal, we made the following contributions.
1) For routing with non-splittable flows, we show that the problem is NP-Hard, and develop a loop-friendly mixed integer program (MIP) model to characterize the interplay between traffic routing, computation load distribution, and network delay performance. We further design a Metric-TSP type of heuristic algorithm to achieve close-to-optimal performance. 2) When flows can be arbitrarily split, we prove the equivalence between the routing with computational services problem and the regular routing problem using the segment routing idea. We develop a Linear Program (LP) routing optimization model by extending the classic Multi-Commodity-Flow (MCF) model to work with heterogeneous middle-boxes and traffic scaling resulting from the processing. The LP model can be further extended to study the joint optimization of traffic routing and computation resource provisioning. 3) For come-and-go dynamic traffic demands, we convert the online routing problem into a flow packing problem, and develop a primal-dual type of online routing algorithm with performance guarantees. 4) We evaluate the developed models and algorithms using emerging computation applications over real network topologies. Through extensive experiments, we demonstrate that our models can be flexibly customized to meet the diverse routing requirements of different arXiv:2210.03338v1 [cs.NI] 7 Oct 2022 2 computation applications. Our algorithms significantly outperform baseline routing algorithms, and can achieve close-to-optimal performance in various scenarios.

II. RELATED WORK
For routing with in-network processing, there are existing studies to address various application scenarios with different assumptions. In the context of edge/fog computing, in [6], besides the computation allocation, they also considered mobility and privacy in the joint optimization problem. In [7], authors focused on the service allocation problem for AR offloading. Some papers, [8] [9] [10], focused on approximation algorithm. The authors of [8] [9] used randomized rounding with linear programming relaxation as the key idea to deal with the non-splittable flows. Authors of [10] developed a fully polynomial-time approximation scheme (FPTAS) for an NP-Hard problem in IoT scenarios. In [11] [12], the problem is studied without hard link capacity constraints. For the middle-box traversal order, [13] focused on the case where the traversal order is fixed. In the [14], authors used graph layering to conform to the order of traversal. Authors of [15] studied the case with arbitrary traversal order. For routing with cycles, one strategy is to calculate all paths with a certain number of cycles in advance [15] [16] [17], and then use the path-based routing formulation to find the optimal traffic routing and demand allocation. The number of candidate paths increases exponentially, and the pre-calculated paths may miss some good paths. Among all these studies, the one that is closest to ours is [15]. The main assumption of their work is that flows are infinitely splittable. In real world applications, it is equally important to study non-splittable and finitely splittable flows. For infinitely splittable flows, their model assumes universal middle-boxes while our model can handle heterogeneous middle-boxes. Our segment routingbased formulation also makes it easy to study traffic scaling after processing and joint routing and provisioning. Table I summarizes the main differences between our work and the most related studies. We consider a generic network represented by a directed graph G = (V, E), where V denotes a set of nodes, and E denotes a set of directed links connecting the nodes. The graph G is assumed to be mesh-connected, having multiple paths connecting each pair of nodes. Every link e is associated with bandwidth capacity of C e . The node set V contains standard routers and special middle-boxes attached to routers. There might be different types of middle-boxes. For a type-r middlebox z, its processing capacity is N r z . A set of flows are to be routed and processed in the network. Each flow d is characterized by its source node s d , destination node t d , traffic volume h d , and its demand for type-r processing W r d . The Routing with In-Network Processing (RINP) problem is to find paths with sufficient bandwidth and processing resources for all flows, subject to bandwidth/resource capacities on all links/nodes.
There are different variations of RINP along different dimensions.
1) Universal vs. Heterogeneous middle-boxes: In the traditional networks, different types of middle-boxes are designed for specific processing tasks. The new trend is to implement middle-box functions on generic computing servers using NFV. Each computing node can be configured to process any demand. The capacity of a middle-box can be measured by its universal computation power N r , and the flow processing demand can be characterized by the total computation power needed. 2) Non-splittable vs. Infinitesimal Flow/demand: When the flow granularity is small, e.g., one flow for each user application session, splitting the flow to multiple network paths and multiple middle-boxes will be inefficient/impractical. On the other hand, in a backbone network, each flow is indeed the aggregated user traffic from city A to city B. It is therefore more flexible to split the traffic as well as the associated processing demand to multiple paths, and if a path contains multiple middleboxes, the processing demand can be further split to utilize all available resources. 3) Constant vs. Elastic Traffic Volume: Certain types of innetwork processing will increase or decrease the traffic volume of the processed flow. For example, after an edge server rendered online game updates, the size of the rendered video stream will typically be larger than the game updates. On the other hand, after an edge server processed the Lidar data captured by an autonomous vehicle, it only needs to upload the learned representations to the cloud server, which has a volume much lower than the raw data. 4) Fixed vs. Reconfigurable Processing Capacity: The traditional middle-boxes have fixed capacities, while the software-based virtual middle-boxes can be reconfigured on-demand to match the processing needs. The RINP problem can be more efficiently solved by jointly routing flows and provisioning middle-boxes.
IV. RINP OPTIMIZATION MODELS The optimization objective of RINP depends on the actual situation. Some popular objectives are to minimize the link/node delay, minimize the maximum link/node utilization, maximize the processed flows, and certain combinations of them. In this paper, we use minimizing network delay as an example objective for static optimization and maximizing the processed flows for dynamic optimization. The developed formulations can be easily customized for other objectives. non-negative constant, the fraction of traffic of candidate path p routed on link e y dp binary variable, whether demand d is routed on candidate path p ∈ P d D(e) variable, set of demands routed on link e P (e) variable, set of selected paths (y dp = 1) passing through link e

A. Non-splittable Flow
We start with the simple case that each flow can only take a single path, i.e., non-splittable. An example is shown in Fig. 1(a), there are only two middle-boxes, each with a capacity of 1, to complete the processing demand of 2, the flow has to take a path with cycles to pass through the two middleboxes before reaching its destination. We will first show that the non-splittable RINP problem is NP-Hard by reducing the well-known Metric Traveling Salesman Problem (TSP) to nonsplittable RINP. We then develop a Mixed-Integer Program (MIP) to study the interplay between traffic routing, demand processing, and network delay optimization.
Proof: Given a set of nodes and the distances between them, the Traveling Salesman Problem (TSP) is to find an optimal order of traversing all the nodes with the shortest total distance. Metric-TSP (M-TSP) is a special case of TSP where the distances between nodes form a metric to satisfy the triangle inequality: . For a given graph G = (V, E) and the distance metric d(·), we construct a special instance of non-splittable RINP on G by: 1) placing one unit of computing capacity on each node, 2) setting the propagation delay on link (v 1 , v 2 ) to d(v 1 , v 2 ), 3) creating one flow with the same source and destination node, 4) setting the flow's traffic volume to << C e so that the congestion delay is negligible, and setting the flow's processing demand to |V |. Obviously, to satisfy the flow's processing demand, the flow has to visit all nodes in the graph, and to minimize the total delay RINP has to find the path with the shortest distance. The only potential discrepancy between RINP solution and the M-TSP solution is that M-TSP solution can only visit each node once while in principle RINP solution may have to visit a node multiple times, as illustrated in the example in Fig. 1(a). However, due to the metric distance, we can easily show that the RINP solution for the specially constructed network can be guaranteed to be cycle-free. Suppose the RINP solution visits some nodes more than once, without loss of generality, let k be the first node that is visited twice, i and j are the nodes visited before and after the second visit to k. By removing the second visit of k, i.e., replacing the path segment i → k → j with i → j, the total path length can potentially be reduced due to the triangle inequality. Using this process, we can remove all the duplicate visits to get a cycle-free RINP path that has either the same length or a shorter length than the original path. This path is a cycle-free solution for M-TSP.
For more generic non-splittable RINP, we develop a MIP model to analytically investigate how traffic routing and demand splitting impact network-wide performance. The notations are defined in Table II.

MIP-RINP: min
where (1a) is the total network delay modeled using the M/M/1 formula. (1b) describes the total traffic rate on a link can not exceed its bandwidth capacity, and the total type-r resources 4 consumed on a node can not be larger than its type-r resource capacity discounted by the target utilization ρ r . (1c) is the flow conservation for single non-splittable path. As illustrated in Fig. 1(a), non-splittable flow may have to take a path with cycles. To allow a flow to traverse a link/node multiple times, routing variable u ed is configured to be a non-negative integer, instead of binary. On a relay node, the total number of times its outgoing links are traversed should be equal to the total number of times its incoming links are traversed. The difference between the two numbers should be 1 for the source node, and −1 for the destination. (1d) calculates the total traffic carried by link e for demand d. Since we only have a single path for d, whenever the path traverses link e, the total demand volume of h d will be added to the link. So the total traffic carried by a link is proportional to the number of times the link is traversed by the single path. Meanwhile, the resources on a node can be accessed by a flow only if the flow passes the node through links attached to it. Therefore, we want to know whether or not flow d traverses link e, which is indicated by a binary variable ε ed in (1e). ε ed is forced to take value 1 if u ed > 0, and value 0 if u ed = 0 (B is a large positive constant). Finally, (1f) is the conservation law for resources: all the resource demands exit from the source node through its outgoing links, the unsatisfied demand at the destination is zero, and on an intermediate node, the difference between the incoming unprocessed resource demand and the outgoing unprocessed resource demand is the amount of demand w r vd processed on that node. Similar to x ed in (1d), if the path visits a link multiple times, y r ed is the sum of the unprocessed demand from all the visits. (1g) are the traffic routing variables, and (1h) are the resource demand splitting variables. The two sets of variables are coupled through (1e). By replacing the convex delay function in (1a) with a piece-wise linear function, the optimization problem becomes a mixed-integer program.
If the processing demand is also non-splittable, we can replace w r vd by W r d k r vd , where k r vd is a binary variable indicating whether type-r processing of d is done on node v. Then y r ed and constraint (1f) can be taken out from the formulation. The added new constraints are: where the first equation requires the processing will be done on exactly one node, and the inequality dictates that a flow can only utilize processing resources on the traversed nodes.

B. Infinitely Splittable Flow
Non-splittable flow is too limiting for large flows. The traditional Traffic Engineering (TE) of backbone networks assumes arbitrary traffic splitting and develops Multi-Commodity Flow (MCF) based convex/linear programming to optimize network design objectives. The obtained optimal routes are typically cycle-free. For RINP, if a flow can be arbitrarily split into multiple paths, the traffic and processing demand splitting become more flexible. For the example in Fig. 1(b), with traffic splitting, the flow can utilize two paths, one for traversing each middle-box. While the bottom path is cycle-free, the upper path still contains a cycle, i.e., not a simple path. Even with the infinitely splittable flow, RINP still cannot be directly solved using the MCF model.
We address this challenge using the segment routing idea as shown in Fig. 1(c) . We start with universal middle-box. Flow splitting leads to both traffic and processing demand splitting among multiple paths. We assume that the processing demand allocated on a path is proportional to the traffic volume allocated on that path. If there are multiple middle-boxes on a path, the processing demand allocated on that path can be further arbitrarily split among these middle-boxes. In general, a legitimate RINP path can "stop" at multiple middle-boxes to get the processing done before reaching the final destination. We define an n-stop RINP path as a path on which n middleboxes process the flow. Note, since a middle-box can simply forward traffic without processing it, an n-stop path may traverse more than n middle-boxes. The single RINP path in Fig. 1(a) is 2-stop, while the two RINP paths in Fig. 1 Theorem 2: Any n-stop RINP path can be decomposed to n 1-stop RINP paths.
Proof: Let s d z 1 , · · · , z n , t d be any n-stop RINP path. The traffic flow on this path is f and the total processing demand is w, and the processing demand allocated to middlebox z i is w i , and n i=1 w i = w. For any z i , we can generate a 1-stop RINP path that follows exactly the same route as the n-stop RINP path, but only stops at z i and gets w i amount of processing done, and all the other middle-boxes only forward the traffic. To follow the proportional demand splitting rule, the traffic allocated on this path is f w i /w. It is easy to check that the n 1-stop RINP paths carry the total traffic of f to t d , and all the processing demands of w are processed. . Theorem 3: Traffic routing subproblem of RINP can be optimally solved by an equivalent Multi-Commodity-Flow routing problem for pure traffic flows.
Proof: We prove this by construction. Let R d be a set of legitimate RINP routes for flow d with total traffic volume h d and total processing demand W d . And the total processing demand allocated to middle-box z i is w i . According to Theorem 2, all RINP paths in R d can be decomposed to 1-stop RINP paths. Any 1-stop RINP path stopping at z i can be decomposed into two segments, s d z i and z i t d . The first segments of all the 1-stop RINP paths stopping at z i share the same source s d and destination z i , and the total traffic flow must be h d w i /W d (due to proportional demand splitting). Similarly, the second segments of all the 1-stop RINP paths stopping at z i share the same source z i and destination t d , and the total traffic flow is h d w i /W d . In other words, the bandwidth consumed by R d on all links can be used to carry traffic for 2|P | pure traffic subflows Meanwhile, it is obvious that any MCF routing solution for the 2|P | traffic subflows, can be used to carry traffic for R d to enable processing w i on z i .
As illustrated in Fig. 2, based on Theorem 3, we can replace each RINP flow with two sets of traffic subflows. One set consists of subflows from the source to all middle-boxes, and the other set consists of subflows from all middle-boxes to the destination. The traffic volumes of the subflows are set to be proportional with the processing demand split among the middle-boxes. The following is an MCF-type convex/linear program for infinitely splittable RINP.
SR-Infinite: min where (2b) is the allocation of processing demand/traffic among all computing nodes. Here we assume the resource demand splitting is proportional to the traffic splitting. (2c) dictates that the traffic of the first and second segments share link capacity, (2d) is the flow conservation for the first segment demand from s d to z, while (2e) is the flow conservation for the second segment demand from z to t d . Both segments have an identical volume of h z d . If the traffic volume increases/decreases after being processed, we only need to change h where φ d is the ratio of the traffic volume after processing over the original volume. After being processed by computing node z, all traffic going to the same destination can be aggregated and routed together. The total volume of the aggregated demand from z to v is d:t d =v h z d . To further reduce the number of routing variables and routing constraints in the formulation, we can replace flow-based routing variables with destination-based routing variables. Let η ev be the amount of post-processing traffic (regardless of the processing node) destined to node v (regardless of the source), the aggregated second-segment routing constraints on any node v ∈ V can be rewritten as: where the left-hand side is the difference between the outgoing traffic destined to v and incoming traffic destined to v, the right-hand side means if v is one of the computing node, the difference is simply the total post-processing traffic from v to v, if v is the destination itself, then the difference is all postprocessing traffic to v, for other relay nodes, the difference should be zero. The number of routing variables is reduced from |V | 2 |P ||E| in (2e) to |V ||E| here. The number of routing constraints is also reduced from |V | 3 |P | to |V | 2 . Both are reduced by a factor of |V ||P |. By replacing (2e) with (3), and replacing (2c) with d∈D z∈P we have a more compact optimization problem.

C. Joint Routing and Resource Provisioning Problem
The routing optimization models can be easily extended to study the joint optimization of traffic routing and middle-box provisioning by making the middle-box capacity N r z in (1b) and N z in (2b) variables under some total resource budget constraint. Flexible resource provisioning can make the routing job easier, and can play an important role in network failure recovery. We will demonstrate this through case studies in Section VII-C.

D. Heterogeneous Middle-boxes
When middle-boxes are heterogeneous, each flow can have multiple types of processing demands.
1) Non-splittable Flow: The MIP optimization model in Sec. IV-A has already considered different types of demands. In the optimal solution, the traversal order of different types of middle-boxes can be arbitrary. This may not be acceptable for certain application scenarios. For example, in cellular core networks, there are predefined orders for middle-box traversal, e.g., mobile traffic has to first go through a firewall before being routed to a load balancer. RINP with predefined middlebox traversal order was studied in [14] using graph layering.
2) Infinitely Splittable Flow: When the traversal order of heterogeneous middle-boxes is predefined, the LP formulation for homogeneous middle-box can be extended to study heterogeneous middle-boxes. If there are k types of middle-boxes, let the middle-box index i represent its order of traversal. Extending the 2-segment routing idea, each RINP path now consists of k + 1 segments, s d z (1) · · · z (k) t d , where z (i) is some type-i middle-box. Similar to Theorem 3, each RINP demand can be replaced by k + 1 sets of pure traffic subflows, one set for each segment. The number of subflows at segment k is |P k−1 ||P k |. An example of two-types of middle-boxes is illustrated in Fig. 3. MCF linear/convex program model can be established in a similar fashion to (2a). Due to the space limit, we skip the detailed model here and refer interested users to our technical report [18].

A. Heuristic for Non-splittable Flow
Even though the non-splittable version of RINP is NP-Hard, we can still leverage the solution of the infinitely splittable RINP to develop a close-to-optimal single path solution. More specifically, we relax the non-splittable requirement and get the optimal infinitely splittable solution by solving the LP defined in (2a). While the paths cannot be used, the processing demand allocation, namely { h z d h d W d } can be used for the single path solution. For all computing nodes with non-zero processing demand allocation, we then find with a close-to-shortest path to traverse them using an approximation algorithm solving the Metric-TSP problem, as illustrated in Algorithm 1: 1. We sort all flows by their demand volumes; 2. We solve the LP of segment routing with the infinitely splittable flow, denoted by SR in line 3, to get a set of computing nodes Z d to be used by each flow d, and the demand allocation on each computing node 3. Process all flows in the decreasing order of volume. For each flow d, find the path with enough capacity by removing links with a capacity less than its volume h d (line 6). Generate an overlay graph G z consisting of the source, destination, and all the used computing nodes for demand d (line 7). The distance between two overlay nodes is the current shortest path in the underlay network (considering the congestion delay) (line 8).
4. Find the shortest path in the overlay graph G z to traverse all computing nodes Z d using M-TSP approximation algorithm. (line 9). We use Christofides algorithm [19] here. 5. Map the overlay path back to the underlay network (line 10), take the bandwidth consumed by flow d out of the underlay network (line 11), and process the next flow.
6. Evaluate the network delay and return.

B. Finitely Splittable Flow
Real situations may lie between the infinitely splittable flow and the non-splittable flow. While non-splittable is too rigid, splitting flow to too many paths will introduce much overhead for implementation, such as too many flow entries in the routing table. Finitely splittable means that the maximum number k of paths each flow can be split to is controlled. One way to get a k-split solution is to evenly split traffic and computation demands of a flow equally and get k subflows, each of which can be treated as an independent flow and obtain the RINP solution using the MIP formulation in (1a). We call this scheme MIP-K. However, such an approach has to work with a set of k|D| subflows. It is impractical to solve MIP for any reasonably large network.  12: end for 13: return e∈E e.delay 1) Heuristic: To address this scalability issue, we came up with a fast heuristic algorithm. Motivated by that Segment Routing can lead to the optimal solution for the infinitely splittable flow case, our heuristic algorithm also follows the segment routing framework. We first equally divide each flow into k subflows, then iteratively find the shortest twosegment path for each subflow, and update the computation and bandwidth resource capacities. If two subflows of the same original flow share the same path, they will be merged them back into a larger subflow. The pseudo-code is in Algorithm 2. For each demand list, we sort the subflows in descending order of their volumes. In each iteration, find all the available computing nodes, Z d , whose available computation resource is more than the current computation demand. For every 2segment path through z ∈ Z d , find the shortest (smallest delay) path from s d to some computing node z, and then to t d . In the pseudo-code, BP and BP C denote the best path, and the best path cost. SP and SP C are the functions for computing the shortest path and shortest path cost in the current graph (considering the link congestion delay).

VI. ONLINE ROUTING ALGORITHM WITH PERFORMANCE GUARANTEE
The previous formulations assume the application demands are known, and can be used for routing optimization in longterm traffic engineering. In practice, application flows come and go with a finite duration. Whenever a new application flow joins the network, the online routing algorithm has to find a feasible routing path for it without knowing the future application flows.

A. Online Routing Optimization Models
Similar to other online routing studies, e.g. [14], [20], we want to accept as many flows as possible over time. The objective of online routing optimization is to maximize the total accepted flows, while complying with the capacity constraints on computation nodes and communication links.
Node Capacity Constraint Conversion: To simplify the problem, we convert computation node capacity constraints into virtual link capacity constraints. More specifically, each for z in Z d : do 8: if BP C > SP C(s d , z) + SP C(z, t d ) then  computing node is split into two virtual routing nodes: the inbound node connects to the computing node's inbound links, and the outbound node connects to the computing node's outbound links. A virtual link is introduced from the inbound node to the outbound node. The bandwidth capacity of the virtual link is set as the computing node capacity divided by the resource demand of per unit traffic. Consequently, if the traffic flow traversing the virtual link is bounded by the link capacity, the resource demand of the flow is bounded by the computing node capacity. In Fig. 4, the purple nodes are routers with computing resources capacity of 100 and 200, respectively. Each computing node is split into two copies in the extended virtual graph. Solid lines and dotted lines mark physical and virtual links, respectively. The demand is from Source to T erminal, and its traffic volume is 8 units, and needs 160 units of computing resources. The resource demand of each traffic unit is 160/8 = 20. The capacity of virtual links introduced for the two computing nodes is 100/20 = 5 and 200/20 = 10, respectively. After such conversion, the bottleneck of the upper path is 5, and only the lower path is feasible for the demand.
Candidate Path with Computation Resources: After the conversion at the previous step, not all the paths complying with the link capacity constraints are feasible. For example, if a flow does not traverse any virtual link, its computing resource demand will not be satisfied. To address this issue, we introduce two virtual links from the inbound copy to the outbound copy of each computing node: if a flow traverses the red link, it consumes the computing resources on the node; if a flow traverses the green link, it is only forwarded by the node without consuming any computing resources. The red virtual link capacity is set according to the computing node capacity, and the green link capacity can be set to a large value so that it is never a bottleneck. By requiring each candidate path to contain exactly one red link, we can make sure that a flow will be processed correctly when routed on a candidate path. Fig. 5 shows an example of generating candidate paths in a network with two computing nodes. After removing the paths with either no red link, or two red links, there are two valid paths: P ath 1 uses the green link for Segment 1 and the red link for Segment 2, and P ath 2 uses the red link for Segment 1 and the green link for Segment 2.
After the previous conversion and candidate path generation, we now present the routing model to maximize the total accepted demands: where P d is the set of candidate paths for flow d, and y dp is a binary variable indicating whether d is routed on path p.
Other notations are defined in Table II. By introducing Lagrange multipliers (z d , d ∈ D, x et , e ∈ E, t ∈ T ) for the constraints, the Lagrangian function The corresponding dual optimization problem becomes: Due to the strong duality theorem, any feasible solution of the dual problem is the upper bound of the optimal solution of the routing problem.

B. Online Primal-Dual Algorithm
While the optimization problem can be solved offline, we need an online routing algorithm to route each flow as it arrives without knowing the future flows. It is expected that the total accepted flow volume by the online routing algorithm is lower than the offline optimal solution. Following the general framework of the online approximation algorithm [20], we develop the following online routing algorithm with a guaranteed ratio of accepted traffic over the offline optimum. Set y dp = 1, z d = τ d h d

7:
for each link e on path p do P (e) = P (e) + {p} 10: Ce∆ dp , 11: where ∆ dp e∈E δ edp 12: end for 13: else 14: Reject the demand d 15: end if In Algorithm 3, when a new demand d is introduced, we first check whether there exists a path that satisfies the dual constraint. If so, that path is picked, and update the dual variable x et and decision variables, D(e) and P (e), accordingly. If not, reject the demand d. Due to Line 5 in Algorithm 3, at any step of the update, before the update, τ d δ edp . After the update, assuming h d δ edp < C e , we have C. Performance Guarantee Theorem 4: The accepted demands by the online routing algorithm is ≥ 1 3 of the offline optimal solution.
Proof: Obviously, the (z d , x et ) generated by the algorithm is a feasible solution for the dual problem (z d = τ d h d ).
After each demand is introduced, the increase in the routing objective is simply τ d h d , resulting from y dp increases from 0 to 1; The increase in the dual objective is: where the last inequality is due to Line 5 in Algorithm 3. After all iterations, the objective value of the dual solution is less than three times the objective of the routing solution.
Since dual feasible solution is the upper bound of the accepted demands of the offline optimal routing solution, so the accepted demands of the online routing solution are no less than 1 3 of the offline optimal routing solution.
Theorem 5: Upper bound for the link capacity violation of online routing algorithm is W e log(∆ e (2γ e + 1) + 1) Proof: It is clear that for any h d ≥ 1 (Taylor Expansion), We can choose W e so that In other words, where α e max p∈P (e) h d δ edp , and the last equality holds due to function (1 + x c ) 1/x is a decreasing function of x. When h d < 1, due to Bernoulli's Inequality, (8) holds naturally by setting W e = 1. Now define another sequence x e,t and update it synchronously with x e,t as: where ∆ e max p∈P (e) ∆ dp . Comparing Line 10 in Algorithm 3 with (11), due to (8), both the multiplicative increase factor (the first term) and the additive increase (the second term) of x et are larger than x et . So we can conclude x et > x et . Meanwhile, (11) can be transformed into: together with x et (0) = 0, at the end of the online algorithm, h d δ edp ≤ C e W e log(∆ e (2γ e + 1) + 1). 9 In other words, the capacity violation factor on any link is bounded by W e log(∆ e (2γ e + 1) + 1).
To eliminate link capacity violation, we revise our online routing algorithm so that a path is picked only when the capacities of all links on the path will not be violated after the new flow is admitted. This change will potentially reduce the accepted traffic ratio. As will be shown in the experiment section, the loss of accepted traffic can be well justified by completely avoiding link capacity violation.

VII. EVALUATION
We now evaluate the proposed models and algorithms using emerging applications over real network topologies.

A. Non-spilttable Flow -VR Rendering
In the VR scenario, one user communicates with another user through realtime 360 degree video streaming. Rendering of 360 video is computation-intensive, it is therefore beneficial to offload the computation from the user device to edge computing nodes. The realtime video stream has to be processed as a whole, i.e., the flow is Non-Spilttable, and follows a single path. To generate a realistic VR scenario, we used the method in [7] to generate our data. For topology, we use the locations of Starbucks stores in the Lower Manhattan of New York City as the locations for users. Each store is connected to a close-by computing node, forming a star topology as shown on Fig. 6(a). Each computing node is connected to two or three nearby computing nodes. There are 24 nodes and 56 links in the network. We synthesize four sets of VR flows between Starbucks customers.
To evaluate the SR-TSP heuristic, in Table III, we compare its solution with the optimal MIP solution on different datasets. The average performance loss of SR-TSP is about 8% from the global optimal. In Fig. 6(b), we evaluate how the performance gap increases as traffic and computation demands scale up. We also develop a greedy baseline algorithm in which each source node finds the nearest computing node with sufficient computation capacity for processing, then the processed traffic is routed to the destination following the shortest path. SR-Infinite is the LP solution for infinitely splittable flow, which serves as a lower bound for the MIP solution. It can be seen that as the demands scale up, the network delay increases for all the algorithms. The gap between baseline and other algorithms is also getting larger and larger. SR-TSP uses the optimal infinitely splittable solution to get computation demand allocation and then uses mature TSP Heuristic to solve the problem of computing node traversal. It achieves a good tradeoff between time complexity and routing performance.

B. Finitely Splittable -Smart City
In the case of a smart city, there are many cameras on the streets. The rapid processing of the information captured by the cameras provides great help for the city's fire and police emergency response. Edge computing can support in-network video analytics for fast response. Unlike the non-splittable VR flows, video from one intersection is separable because there are typically multiple camera videos from different viewing angles, even video from a single viewing angle can be divided and processed in parallel.
Realtime video camera data from New York City was used for evaluation. For the same camera, there are two video analytics tasks, one for the Fire department and one for the Police. We assume that the computing power required for fire detection is proportional to the number of nearby houses. Based on the data from Zillow, we counted the number of houses within a radius of half a block. Assuming that the computing power required by the police camera is related to the traffic flow of the street, we conducted the query of the precise location traffic flow and the reasoning of the fuzzy location traffic flow according to [21] [22] [23] to complete our data set. It contains 40 nodes and 15 cameras. A total of 30 streams flow from cameras to nearby fire and police stations.
We focus on the k-split routing. For each test, we randomly select 60% of demands for evaluation, and the representative results are shown in Fig. 7(a). As the split scale k increases, the performance gets better. For non-splitting, the performance is bad: the network delay of MIP and SR-Iteration are 245.87 and 247.79, respectively. But once the spilt degree goes to 2, the performance improved a lot. SR-Infinite is the optimal solution when the splitting can go to infinity. We can see that 10 as the k goes to 4, the solution from MIP can already match the optimal. This finding is important since MIP incurs high complexity. In our example, MIP with k = 4 uses 12.63s, but MIP with k = 9 uses 189s, while their solution quality is almost the same. Secondly, when the network and demands are large, an alternative method is to use SR-Iteration to find a quick solution, even though it incurs 20% higher delay than MIP. The solution quality of SR-Iteration also improves a lot from k = 1 to k = 9, but it saturates when k is large. In Fig. 7(b), for the same dataset, we draw the boxplot to show how the split scale affects the number of paths taken by each flow. The green arrow is the average number of paths taken under k. We can see that most flows only take less than three paths even though they are allowed to take up to k paths. But some demands can still take advantage of large k. In the split scale k = 9, one demand is routed to seven different paths! This suggests that we can assign different splitting degrees to different demands.

C. Infinitely Splittable and Placement -WAN
A flow in Wide-Area-Networks (WAN) typically represents a set of user flows that share the same ingress and egress points. It is often treated as infinitely splittable in traffic engineering. We evaluate RINP with the infinitely splittable flow in the context of WAN.
Dataset. We obtain two WAN datasets. The first is obtained from [24]. It presents a publicly available dataset from GÉANT, the European Research and Educational Network. The GÉANT topology consists of 23 nodes with 74 directed links. The average node degree is 3.217. We randomly sample 12 node-to-node demands in the given traffic matrix. We set link capacity to 80,000 for each link and pick three nodes not in the source node set and not in the destination set as computing nodes. The second dataset is obtained by [25]. We pick topology Abilene, which represents a high-performance backbone network across the America. It consists of 12 nodes with 30 directed links. The average node degree is 2.5. For the demand setting, we randomly sample 6 node-to-node demands in the traffic matrix. The link capacity is 40,000 for each link as described in the dataset. We also pick two nodes, SNVAng and IPLSng as computing nodes. Without loss of generality, for both datasets, we assume the computational resource demand for each flow equals its traffic volume.
Greedy Computation Allocation vs. Joint Optimization. To demonstrate the importance of joint optimization of traffic routing and demand allocation, we develop a baseline algorithm that greedily allocates the flow with the largest computation load to the most powerful computing node, then conducts LP-based routing optimization for the greedy computation load allocations. The result is shown in Fig. 8. For topology GÉANT, the network delay of the baseline is always above the LP solution of segment routing. The average increment is about 57.58%. For topology Abilene, the network delay of the baseline is also always above segment routing. The average increment is about 55.29%.
With Placement vs. Without Placement. We compare segment routing when the computational capacity is fixed for each computational node with when the computational capacity can be freely allocated among computational nodes as long as the sum of their computational capacity is the same as the fixed case. The result is shown in Fig. 9. The percentage represents the ratio of the network delay without placement over that with placement. For both topologies, the network delay is the same when the demand scale is not very large. The reason is that when demand scale is small, the original fixed computational capacity distribution is enough to handle all demands that follow the best routes. For topology GÉANT, with placement version outperforms the fixed version when the demand scale goes up to 6. When demand scale is 10, the network delay of the fixed version is about 131.0% of the with placement version. For topology Abilene, with placement version outperforms the fixed version when the demand scale goes up to 8. When the demand scale is 10, the network delay of the fixed version is about 105.0% of the network delay of the with placement version. Adaptation to Link Failures. We run segment routing when computational capacity can be freely allocated among computational nodes under a given budget. For both topologies, we run it on three different configurations by disabling some links. The pie chart shows the ratio of the computational capacity allocated to each computation node. The result for GÉANT is shown in Fig. 10. Blue represents node 3, orange represents node 13, and the green represents node 16. Initially, the allocation of the computational capacity among node 3, 13 and 16 is shown as Fig. 10(a). After cutting three bidirectional links connected to node 16, the allocation is shown as Fig. 10(b). The computational capacity allocated to node 16 is drastically reduced. After cutting two more bidirectional links connected to node 13, the allocation is shown in Fig. 10(c). The computational capacity allocated to node 13 also drastically reduces, and most computational capacity is allocated to node 3. Similar results for Abilene network can be found in our technical report [18]. Impact of Traffic Scaling after Processing. In this part, we run segment routing when the flow size changes after going through a computational node. We first take the scale factor into account in our model for different scale factors. We then compare it with the case when the traffic scaling is ignored when calculating the optimal segment routing. The result is shown in Fig. 11. The percentage represents the ratio of the network delay when ignoring traffic scaling to the network delay when considering traffic scaling. For topology GÉANT, the network delay is shown in Fig. 11(a). Except for the scale factor 0.5 and 1, the network delay of ignoring the scale factor is higher than that of considering the scale factor. For topology Abilene, the network delay is shown in Fig. 11(b). Except the scale factor 1, the network delay of ignoring the scale factor is higher than that of considering the scale factor.

D. Online Routing Algorithm with Guarantee
Dataset. To evaluate the online routing algorithm, we synthesize dynamic traffic demands. The topology is the same as the Smart City problem in Section VII-B. In the graph of 40 nodes, 14 nodes were selected as computing nodes. Without loss of generality, the ratio between the computing demand and the flow size is 1 : 1. Each link capacity is 550 units, and node capacity is 300 units. We pick 8 source-destination pairs. New flows arrive at the network according to the Poisson process and are assigned to each source-destination pair in a round-robin fashion. The time duration of each flow follows lognormal distribution, i.e., τ = e µ+σZ , where Z is the standard normal variable. When a flow is active, the traffic volume follows the Gaussian distribution.
Performance. For the online algorithm, we compare two versions, one with link violation and one without violation. We also use the shortest path algorithm as the baseline, and the upper bound is obtained from the MIP model implemented by Gurobi. In Fig. 12, the flow arrival rate is two flows/minute, the lognormal duration parameters are µ = 0.974 minutes, and σ = 0.5 minutes. The average flow volume is 85 units. To evaluate the impact of flow volume variations, we conducted two experiments with flow volume standard deviation of 10 and 20, respectively. Our online algorithms significantly outperform the shortest path routing. The accepted traffic of the online algorithm without violation is only slightly lower than the MIP solution. With link violation allowed, the online algorithm can accept a little bit more traffic than MIP. Fig. 13 shows the total traffic of active flows over time. This suggests that our online algorithm can efficiently utilize available communication and computation resources in the network to support dynamic flows. Violation. In the online routing algorithm, the link violation theoretical upper bound has been given. But in practice, within a reasonable demand flow size range, the violation is rare. To check the actual violation, Fig. 14 plots the Median and Max link utilization over time. We also plot the boxplot distribution of link utilization in Fig. 15 and Fig. 16 for different demand parameter settings. For all the experiments, the flow arrival rate is still two flows/minute. There are three settings of flow time duration parameters (µ, σ): (0.974, 0.5), (0.598, 1.0), (0.379, 1.2), respectively. Under those settings for lognormal distribution, the average duration is the same, but the variance increases from the first setting to the last setting. We also try three average flow sizes of 70, 85, and 100, with the standard deviation fixed at 10. It is worth noting that with flow size expectation of 85, the network capacity is reached 1 . In Fig. 15, as the average flow size increases, the link utilization increases. With the same average flow size, as the duration variance increases, the link utilization decreases, this is because more dynamic flow duration leads to more rejected flows by the online routing algorithm. Even though the 12 maximum utilization can go up to 1.75, utilization on most of the links are still below one. In Fig. 16, with capacity violation control, no utilization goes over 1, and the differences between different flow sizes and different duration variations become smaller, while the overall trends agree with Fig. 15. In this paper, we studied optimal routing in networks with embedded computational services. We developed routing optimization models and fast heuristic algorithms that take into account the unique features of routing with in-network processing and various routing requirements resulting from the computation needs of diverse applications. For the dynamic demand scenario, we came up with an online routing algorithm with a performance guarantee. We demonstrated through evaluations that our models and algorithms are highly customizable and can achieve close-to-optimal performance in a wide range of application scenarios. While the current work is focused on optimizing the network performance, we will investigate the robustness and resilience of RINP in our future work. In particular, we are interested in exploring how traffic routing and computation resource provisioning can help each other to quickly recover from major failures in networks with embedded computational services, as demonstrated in our preliminary results in Section VII-C.