## 3 Problem Definition
### ILP Formulation  
This section provides the mathematical formulation for managing the routing and scheduling of data frames between IoV infrastructure devices through TSN to ensure real-time synchronous communications. This problem could be defined as an ILP model to determine the routing and periodic slots for each service request arrival to meet its requirements. The objective is to minimize the end-to-end delay in transmitting data frames. The ILP is called the One-Request Joint Routing and Slot-Capacity-Aware Flow Placement (One-Req-RSCAFP) problem. As defined in the previous section, the TSN network scenario is modeled by a directed weighted graph \(G=(V,E)\), adopting a specified topology, being \(V\) the set of nodes, and \(E\) the set of edges. The nodes are the TSN switches inside the TFCs and TMSs. Each link \((i,j)\in E\), being \(i,j\in V\), is characterized by a delay \(D_{ij}\), which allows us to evaluate and optimize the delay performance of the transmissions under various conditions. Each link \((i,j)\in E\) is slotted with a hyperperiod \(S\) that emulates the TSN synchronous network. Moreover, let \(C_{ij}^{\mathrm{s}}\) be the capacity of the link slot \(s\) to allow communication on the network into a fixed length, repeating time cycles determined by the period of the service request. Let consider a service request \(R\) defined with the tuple (\(R_{src}\), \(R_{dst}\), \(R_{len}\), \(R_{prd}\), \(R_{delay}\)). Thus, this work defines an iterative procedure that uses the model One-RSCAFP at each request arrival determining a route with enough periodic slot capacity considering different background traffic levels. Next, having the optimal valid route, the final scheduling is determined using a simple heuristic. Figure 4: The proposed temporal division model based on a hyperperiod and several slots with a fixed size. To formulate the One-Req-RSCAFP problem, let us define a binary variable \(x_{ij}\) indicating if a link \((i,j)\) is part of the constrained route of the service request:  
\[x_{ij}=\left\{ \begin{array}{l}1\ \,\text{if the edge $(i,j)$ is used to transmit the service request}\\ 0\ \ ;\text{otherwise,}\end{array} \right. \tag{1}\]  
and let \(f_{ij}^{s}\) be a binary variable specifying if a slot \(s\) of the link \((i,j)\) is used for the transmission:  
\[f_{ij}^{s}=\left\{ \begin{array}{l}1\ \,\text{if periodic slots starting at $s$ of the edge $(i,j)$ are used to transmit the service request}\\ 0\ \,\text{otherwise.}\end{array} \right. \tag{2}\]  
With all of these considerations, the ILP for the One-Req-RSCAFP problem is:  
\[\text{min}\ \sum_{\forall(i,j)\in E}\sum_{\forall s\in S}f_{ij}^{s} \cdot D_{ij}\] (3) \[\text{s. t.:}\ \sum_{\forall(i,j)\in E}\sum_{\forall s\in S}f_{ij}^{s}- \sum_{\forall(j,i)\in E}\sum_{\forall s\in S}f_{ji}^{s}=1\ \ \ \ \text{if $i=R_{src},i\in V$}\] (4) \[\sum_{\forall(i,j)\in E}\sum_{\forall s\in S}f_{ij}^{s}- \sum_{\forall(j,i)\in E}\sum_{\forall s\in S}f_{ji}^{s}=0\ \ \ \ \forall i\in V|\
eq\{R_{src},R_{dst}\}\] (5) \[f_{ij}^{s}\cdot R_{len}\leq C_{ij}^{s}\which there is enough capacity, according to the periodicity of the request, at the same position as the first link or later \((s^{\prime}\geq s)\), i.e., \(f_{jk}^{s^{\prime}}=1\). This constraint is also nonlinear and, through linearization techniques, is equivalent to the following:  
\[f_{jk}^{s^{\prime}}\geq x_{jk}+f_{ij}^{s}-1 \tag{14}\]  
being \((i,j)\in E\) a link with initial node \(i\) different of the origin \(R_{src}\), \((j,k)\in E\) and \(s^{\prime}\geq s\) mod \(R_{prd}\). Constraint (9) ensures that a slot on an inactive link (i.e., not being part of the resulting path) is not occupied. In addition, constraint (10) guarantees that the total path delay does not exceed the maximum acceptable end-to-end delay of the request. Finally, all variables are defined as binary in constraints (11) and (12). The ILP requires a high computation time to obtain a solution, making its use in real time unfeasible.