Energy-Aware Cross-Layer Offloading in Fog-RANs Using Network Coded Device Cooperation

This paper studies a Fog Radio Access Network (F-RAN) architecture that utilises the increasing storage and device-to-device communication capacities of users’ smart devices (referred to as F-UEs) in order to reduce the time that the central processing unit (referred to as BBU) has to spend to serve these F-UEs and thus, increases the system’s capacity. Indeed, these F-UEs can employ these capacities in cooperatively serving each other’s file requests, as long as the F-UEs have the files in their storage, rather than always receiving them through the BBU. In addition, network coding (NC) can be employed to minimize the communications among the F-UEs and from the BBU to further offload the BBU resources and reduce the energy consumed in F-UEs’ cooperation. This paper develops an algorithm for scheduling the file encoding and transmissions both among half-duplex F-UEs and from the BBU to minimise the consumed time-frequency resources from the BBU given constraints on the energy consumed by each F-UE for their cooperation to help preserve their battery life. The influence of the energy constraint on BBU offloading is investigated and the performance of the system under a variety of settings is evaluated through extensive simulations. The benefit of using NC is shown and the ability of the F-UEs to transmit with different power levels is also studied and shown to considerably impact the number of cooperating F-UEs and the BBU offloading.


I. INTRODUCTION A. MOTIVATION
The ever increasing demand for popular online content like video and audio puts a strain on the network as more network bandwidth and infrastructure is needed to serve all user requests. According to Deloitte [2], the end users prefer mobile devices as the medium for consuming online media. These consumer trends define the technical challenges today. The traditional user-server approach where a user sends a request to the server and the server then streams the content to the user cannot scale to accommodate the current online media consumption and provide the expected quality, mainly The associate editor coordinating the review of this manuscript and approving it for publication was Pietro Savazzi . due to bandwidth limitations. Thus, a new architecture is required.
A promising solution to these challenges is Fog Radio Access Network (F-RAN), which aims to bring the data content physically closer to the end users, thus, reducing the download time. In order to achieve this, the F-RAN's central baseband processing unit (BBU) caches popular files on either enhanced remote radio heads (eRRHs) that are installed closely to the end users, or directly on the user devices (denoted by F-UEs).
The work in this paper considers the case when the BBU caches some popular files on the F-UEs during off-peak times. The reason for this is not just to save equipment and installations costs, but also to take advantage of F-UEs' prior downloads. Due to the F-UEs' cooperative and storage capabilities of previously downloaded popular files, they naturally become sources of content. In other words, we take advantage of the F-UEs primary purpose, downloading content, and reuse this content in order to minimise the BBU bandwidth. Thus, these F-UEs can collaborate with each other during peak times to retrieve their requested files from one another within a very short time period, with hopes to fully relieving the BBU from their delivery. This increases the system's capacity and allows the BBU to serve the increasing number of end devices. Yet, due to the quality of experience requirements of next generation networks, requests that are not immediately honoured by the F-UEs must still be served from the BBU. By ''immediately'', we mean within the minimum duration in which a group of half-duplex devices can collaborate to help each other, namely two transmission phases. In such scenarios, the decisions on which entity will serve which request(s) in each of the two phases must be done so as to minimally involve the BBU and consume the least amount of its time-frequency radio resources.
This work also considers the fact that this collaborative approach to achieve BBU offloading comes at the cost of using F-UEs' resources that, otherwise, could be saved to prolong their working hours and capacity. While providing some incentive mechanisms to motivate the F-UEs to contribute is important [3], [4], this paper addresses the reality that these devices will most probably impose limits on the energy they will spare for this collaboration, and studies how these energy limits will influence the offloading the BBU's physical resources.
In order to improve the network throughput, preserve BBU bandwidth, and abide by F-UEs' energy constraints, all F-UEs are allowed to use Network Coding (NC). Originally introduced in [5], NC takes advantage of the files already known to the F-UEs by mixing (i.e., encoding) some of the F-UEs' requested files and sending them together instead of the traditional method of using multiple uncoded unicast transmissions. This allows each transmitting device to target more than one receiver. We use this property of the NC to maximize the service from the F-UEs and minimise the used BBU resources. In this work, we use Opportunistic Network Coding (ONC) because it is computationally inexpensive and allows the F-UEs to decode their required files as soon as the encoded packet is received, making it available for use momentarily.
B. RELATED WORK 1) NETWORK CODING (NC) In general, Network Coding (NC) allows the nodes not simply to route packets but instead, to compute and transmit functions of those packets. The NC has been shown to increase the throughput of the network [6], improve the latency [7] and the quality of service. A popular type of NC used in wireless networks is Opportunistic Network Coding (ONC). The ONC-enabled transmitter performs a mathematical operation (e.g. XOR) over two or more packets and sends the encoded packet to multiple receivers [8], [9] in one transmission (instead of several unicast transmissions). The instantly decodable NC (IDNC) is a very useful and wellknown subclass of ONC which we use in this work.
As the name suggests, IDNC encodes packets in a way that allows the receivers to instantly decode their requested packets by simply performing an XOR operation [10]. Our work takes advantage from utilising IDNC in the following ways. By benefiting several receivers with one transmission, the IDNC allows us to maximize the number of served F-UEs with each transmission. Moreover, the IDNC has been shown to reduce the completion time of delivering a group of packets [10]. This property ensures that if the BBU needs to serve some F-UEs, it will do so in minimum time. In conclusion, maximizing the number of receiving F-UEs increases their cooperation capabilities which ultimately, decreases the BBU's working time and increases the system's capacity.

2) COLLABORATIVE DATA EXCHANGE
The area of Collaborative Data Exchange (CDE) studies different scenarios where the smart end devices collaborate with each other to retrieve some files. Although this body of work seems to be very close to our scenario, the objectives are quite different. In [11], [12], the aim is to develop algorithms that decrease the decoding delay or completion time of the system, whereas our algorithm aims to organise the communication between the F-UEs in a way that shortens the BBU's completion time serving these F-UEs, while preserving the F-UEs consumed energy below their specified thresholds. Moreover, in [13]- [15] all the receivers require all files (a broadcast scenario) or a subset of them [11], [12] (a multicast scenario), whereas in this work the F-UEs require to immediately (with very low latency) receive only one popular file, at least once every two transmission phases.
Since in the F-RAN, the F-UEs are capable of communicating with each other, the area of CDE is very relevant to this problem. However, the main difference between the CDE-related works and this paper is that they study the communications between the F-UEs regardless of the ways they affect the BBU. Furthermore, it is assumed in the system model of this paper that more than one F-UE can be selected to transmit in any of the two possible transmission phases, which further complicates the scheduling of F-UE transmissions given their half-duplex nature.

3) F-RANs AND BBU OFFLOADING
To achieve F-RAN's full potential, the BBU must cache popular files smartly so that metrics like connectivity, energy consumption, delay and BBU offloading are optimised [16]- [19]. Although the authors in [20] did not utilize NC transmissions, they showed that significant amount of offloading can be achieved even when the energy cost of the collaborative F-UEs is kept low. It is also worth mentioning that a significant body of work like [21]- [23] explores the computation offloading and resource allocation in the mobile edge. However, in those papers the devices have some tasks to be computed as opposed to receiving files. Thus, the offloading has a different objective. A number of papers have proposed algorithms for downloading a file through content helpers [24]- [26] or relaying mobile devices [27] with the aim of BBU offloading, minimising energy consumption, or maximising success rate. However, those papers did not consider NC nor device collaboration, but rather employed simple file broadcasts to or between F-UEs. The work in [28] considered the offloading of the BBU's physical resources using network coded transmission from eRRHs. It thus differs from this work as it did not explore file delivery cooperation between half-duplex devices nor energy considerations. Although the work in [29] considers the same system model of this paper (referred to as device-based F-RAN), the developed upper-layer algorithms in [29] minimised the number of fronthaul channels that the BBU must use in order to complete the service of all F-UEs requests. In this paper, we show that minimising this metric does not guarantee the minimum BBU involvement in terms of actual physical resources. Indeed, the BBU can transmit coded packets on fewer channels (good channel offloading) but with low download rates (due to the poor physical channels from the BBU to the served F-UEs), which may consume more BBU resources as opposed to serving requests of other F-UEs using slightly more transmissions (i.e., more frequency channels) but significantly higher download rates on each of them.

C. OUR CONTRIBUTIONS
The aim of this paper can be summarised in the following question: ''What is the optimal schedule of network coded transmissions from half-duplex F-UEs that can maximise the BBU's physical offloading while delivering all requested files from all F-UEs within two transmission phases and conforming with the F-UEs' energy constraints?'' To answer this question, the paper achieves the following main contributions: 1) The problem of physical BBU offloading in a device-based F-RAN is formulated as a constrained joint independent set subtraction and chromatic number identification problem over an NC graph, and its NP-hardness is proved. 2) To reduce the computational complexity, a greedy vertex search algorithm on an extended half-duplex ONC graph is proposed. This graph shows all possible conflicts in the system while complying to all energy constraints. 3) Extensive simulations have been performed to both exhibit the merits of our proposed solution in offloading the BBU's physical resources and study how this offloading is influenced by the energy limits that are imposed by the F-UEs in order to preserve their batteries.

D. PAPER ORGANIZATION
The rest of the paper is organised as follows. The system model and parameters are introduced in Section II.
In Section III, the problem is formulated for the general case where each F-UE is under a different energy constraint. The problem is shown to be NP-hard, thus Section IV introduces the proposed heuristic algorithm. Simulation results and discussion are presented in Section V. Finally, Section VI concludes the paper.

II. SYSTEM MODEL
This paper studies a type of F-RAN architecture that uses the F-UEs as caches. As shown in Fig. 1 It is reasonable to assume that the signal fading on the channels between the F-UEs follow the Rician distribution, as they typically have strong line-of-sight components to one another. On the other hand, the signal fading on the channels between the BBU and each F-UE will follow the Rayleigh distribution to properly represent the dense scattering of these signals before reaching the F-UEs. As shown in Fig. 1, the quality of the channels between the BBU and each F-UE is represented by rate r u i defined as [28]: where B is the channel bandwidth, P t is the transmit power of the transmitting device, h i is the complex channel gain from the BBU to the F-UE u i , and σ 2 is the additive white Gaussian noise (AWGN) power. The rate between two F-UEs u i and u j is noted as r i,j . For a successful transmission to F-UE u i , the BBU should not send with a rate exceeding the rate r u i . To ensure this, if a transmitter is simultaneously sending to two or more F-UEs, it must choose the lowest rate. Thus, the transmitter would need (F s )/(min u i ∈S r u i ) seconds to send an encoded (combined) file to the set S of targeted receivers, where F s is the size of the file in Mbits (equal size files is assumed). Thus, the rate determines the duration of the transmission t which also means that it influences the amount of energy E u i that the transmitter has to use. We define E u i as the energy an F-UE u i uses for a single transmission and E m as the maximum energy each F-UE is allowed to spend on a single transmission. Although the F-UEs use energy for functions like coding, decoding, being in idle state, etc., our energy constraint is related to the energy used solely for transmissions. The XOR operation used for coding/decoding is computationally inexpensive, and the necessary amount of energy is negligible. Realistically, the F-UEs are assumed to be half-duplex (they can either transmit or receive at a given time). This assumption together with the aim to keep high quality of experience necessitate the delivery of the requested files in at most two transmission phases (one transmission epoch), t ∈ {1, 2}. Scheduling transmissions on these two phases enables the opportunity for F-UEs' to collaborate with each other while still receiving their requests (from another F-UE or the BBU). It is assumed that some of the F-UEs cannot transmit directly to each other, however, the BBU can reach all F-UEs. All F-UEs in the system can use network coded transmissions and combine several files to serve more F-UEs with fewer transmissions. They thus need to ensure that each served F-UE by a coded file can immediately decode its requested file from it. Therefore, the ONC concept is suitable for this purpose as it not only ensures the immediate usability of the received information but also, is computationally inexpensive.
It is assumed that the BBU has huge processing capabilities, all the information about the channels' quality, and the Has H u i and Wants W u i sets of all F-UEs. Thus, it is the unit that computes the optimal transmission schedule between the F-UEs and itself for the two transmission phases. It then uses control channels to instruct the F-UEs of their roles (transmitter or receiver) in each of the two transmission phases, the files they have to transmit, and the devices they have to target or tune to. The F-UEs can send on one channel at a time, whereas the BBU can utilise multiple channels, where all channels are assumed to be orthogonal. The sum of the times consumed by the BBU across all the channels involved in delivering requests to the F-UEs is defined as the consumed time of the BBU.

III. PROBLEM FORMULATION
The aim of this paper is to find the best schedule for transmitting/receiving F-UEs, files, and possibly the BBU in two transmission phases so as to minimise the consumed time the BBU needs to serve the remaining F-UEs while obeying the F-UEs energy constraints. In this section, we first look at an example that shows the nature of the problem and the potential benefit an efficient solution can bring. Then, we formulate the problem and discuss the effect of the transmit power on the performance. Having energy constraints would help the F-UE devices have longer battery life and potentially convince more F-UEs to participate in cooperative file delivery.

A. MOTIVATING EXAMPLE
The network used for this example is shown in Fig. 1. The BBU has the whole library of 8 files (each file is 12Mbits) and has already cached some of them on the F-UEs' caches. The BBU knows the channel rate r u i to each F-UE and the rates between all F-UEs r i,j . For simplicity, only some of the rates between the F-UEs are shown in Fig. 1.
The optimal solution for this example results in 3 seconds of BBU consumed time on one BBU channel. However, in order to illustrate the problem's nature and the benefit the smart scheduling on the physical layer could bring, two other possible solutions are listed here. Solution 1: In the first transmission phase, u 2 sends f 3 to u 1 , u 3 sends f 2 to u 4 and u 5 sends f 8 to u 6 ; in the second transmission phase, u 4 transmits file f 6 to u 5 , the BBU sends f 4 and f 5 to u 2 and u 3 in one coded transmission in the form of f 4 ⊕ f 5 .
Solution 2: In the first transmission phase, u 2 sends f 3 to u 1 , u 4 sends f 6 to u 5 ; in the second transmission phase, u 5 sends f 4 to u 2 and the BBU sends f 5 to u 3 , f 2 to u 4 and f 8 to u 6 in three different transmissions.
Thus, Solution 1 requires only one BBU channel and Solution 2 requires three BBU channels. According to the offloading strategy in our previous work [29], [30], Solution 1 is the better solution because it minimises the number of the utilised BBU channels. Yet, this solution may not minimise the actual physical time that the BBU spends (whether on one or more multiple channels) to serve the F-UEs. Therefore, the download rates need to be also considered to properly assess the actual BBU offloading. As explained in Section II, having the file size F s and the rate r u i between the BBU and the receiving F-UE, allows us to easily calculate the duration of the transmission. In Solution 1, the BBU would spend (12Mbits)/(min{1Mbits, 4Mbits}) = 12 seconds for the single transmission, whereas, in Solution 2, the BBU would need (12Mbits)/(4Mbits) + (12Mbits)/(4Mbits) + (12Mbits)/(6Mbits) = 8 seconds 1 for the three transmissions. Despite utilising more channels, the BBU sends over better ones in Solution 2 and thus, its resources are occupied for less total time.
Let us now put a limit on the energy that the serving F-UEs are allowed to use for one transmission. For simplicity, we assume that the energy constraint is the same for all F-UEs and set it to 0.5J . Also, we assume all F-UEs transmit with power P t = 0.1W . The duration of each transmission can be calculated just like in the first part of this example. Then, we know the energy E for a particular transmission can be calculated as [31]: and we can compare it to the threshold of 0.5J . Let us examine again the two solutions and calculate the required energy for each of the cooperative transmissions. Solution 1: In the first transmission phase, u 2 sends f 3 to u 1 . The channel rate r 1,2 between u 1 and u 2 is 4, thus E u 2 = P t · t = 0.1 × (12/4) = 0.3J . Doing similar calculations reveals that the transmission between u 3 and u 4 takes 0.4J , between u 5 and u 6 requires 0.6J , and between u 4 and u 5 needs 0.2J . Only u 5 exceeds the energy limit and consequently, this transmission is not allowed. The BBU has to serve u 6 and use t BBU = (12/6) = 2 seconds (the channel rate between the BBU and u 6 is 6). As mentioned before, the BBU also has to serve u 2 and u 3 in one coded transmission that uses 12 seconds. The total time that the BBU spends for this solution is thus 14 seconds. Solution 2: In the first transmission phase, u 2 sends f 3 to u 1 , which requires 0.3J of energy from u 2 . The transmission from u 4 to u 5 requires 0.2J and from u 5 to u 2 requires 1.2J (the channel rate is 1). As the last transmission exceeds the energy limit, the BBU has to serve u 2 . Luckily, the u 2 's request can be coded together with the u 3 's request and send in 12 seconds. As mentioned before, the BBU also has to serve u 4 (in 3 seconds) and u 6 (in 2 seconds). Thus, Solution 2 requires the BBU to spend 12 + 3 + 2 = 17 seconds. Consequently, in this case, Solution 1 would be the preferred one.
In conclusion, the introduction of F-UEs' energy constraints can prevent some transmissions and restrain the cooperative capabilities of the F-UEs. Therefore, we need to find the optimal solution of the system given the F-UEs' energy constraints and channel conditions.

B. ENERGY-CONSTRAINED COOPERATIVE D2D TRANSMISSIONS
We extend the NC conflict graph G [32], [33] to model the energy-aware cross-layer BBU offloading problem. Each vertex v i,k of the graph represents a user u i that requires a file f k . It is well-known that the conditions for connecting two vertices v i,k and v i ,k by an edge are: 1) the requested files k and k are different, and 2) at least one of the F-UEs i or i does not know the file requested by the other F-UE (i.e., f k = f k AND either f k / ∈ H u i OR f k / ∈ H u i ). If both conditions are satisfied and thus, there is an edge between the vertices, the coded packet identified by the vertices would not be immediately decodable by at least one of these F-UEs. This means that each edge indicates a conflict between the vertices it connects. Consequently, each independent set (IS) 2 in the graph shows that the files indicated by the vertices can be encoded together and served in one transmission by an F-UE or the BBU.  In this work, our aim is to ensure that each serving F-UE does not exceed its energy threshold for a single transmission. The well-known relationship between energy, transmit power and duration of the transmission is given in Eq. (2). As explained in Section II, if the transmitted file size F s and the rate r u i between the BBU and u i are known, t can be simply calculated as: (F s /r u i ) (the same argument is valid for the rates between the F-UEs r i,j ). In this paper, we assume that the file size F s is constant and that the BBU has knowledge about the F-UEs' transmit powers and the rates on all channels. By performing simple calculations, the BBU can determine if a transmitting F-UE to any other given F-UE will exceed its energy constraint. While guaranteeing this constraint, we should find the transmission schedule among F-UEs that will result in the shortest time from the BBU to serve the remaining F-UEs' requests.
In the traditional NC graph, the ISs I is the set of F-UEs transmitting (serving ISs) in the transmission phase t, is the set of receiving devices in transmission phase t, and U R,(t) is the cardinality of the set, where R represents receiving F-UEs. Moreover, )) represents the F-UEs served by the IS I u T ,(t) i . The first constraint means that each F-UE can transmit only in one of the transmission phases because it must receive its requested packet during the other transmission phase (within the considered time epoch). The second constraint caters for the half-duplex nature of the F-UEs and thus, ensures that each F-UE can either transmit or receive in one transmission phase, but cannot do both simultaneously. We denote a partitioning in Q as Q and let S(Q) be the set of ISs in Q. Thus, the problem can be formulated as: all the files identified in that IS because these are the files the serving F-UE must transmit to the F-UEs indicated by the IS. The min function ensures that all F-UEs are able to receive the file successfully because the minimum F-UE rate r u j is selected in each IS. The last condition guarantees that the energy each F-UE uses for a single transmission E u i should not be more than the maximum allowed energy E m . In essence, the problem formulation in ((4)) says that we need to find the transmission schedule between the F-UEs that will result in the least amount of consumed time spent by the BBU while guaranteeing the fulfilment of each F-UE's energy constraint.
Finding the optimal solution of the problem in Eq. (4) involves two steps. In the first step, Eq. (3) describes the selection of the IS comprising F-UE vertices only for the two transmission phases and their removal from graph G. It is known from Eq. (4) that the optimal selection of such IS in this first step must leave a subgraph of BBU vertices which would result in the lowest consumed time from the BBU in the second step of the solution. This means that all possible ISs comprising of F-UEs vertices only, must be listed in the first step to find the one that achieves the best BBU outcome in the second step. This IS listing itself is known to be an NP-hard problem [34]. Moreover, as the IS consists of F-UE vertices representing transmissions for two phases, each of the feasible combinations of phase one and phase two vertices must be examined to check on which of them will result in the remaining BBU subgraph with the shortest consumed time. This is clearly a very complex combinatorial problem. Finally, in each of these combinatorial steps, all ISs in the BBU subgraph must be listed and their resulting consumed time must be computed, to be compared with that of the other combinations. This results in an internal NP-hard IS listing in each of these combinatorial steps. The above description clearly shows that finding the optimal solution for this problem is NP-hard.
Furthermore, if equal channel rates are assumed for all F-UEs, the problem can be reduced to the one studied in [30] where the BBU offloading is done in terms of minimizing the used channels, rather than minimizing the physical resources. The problem in that work has been proven to be NP-hard and is a special case of the problem studied here.

C. EFFECT OF POWER LEVEL ON THE PERFORMANCE
Before starting to develop a solution to the formulated problem, we first discuss here some trivial but important observations. In Fig. (3), we show the relationship between the transmit power P t and the duration of the transmission t. As mentioned before:   Fig. (3).
The logarithmic relationship between P t and t and the linear relationship between P t and E shows that the P t term is the main contributor in the equation. As shown in Table 1, 3 the parameters used in Eq. (5) result in a relatively small change in t. Thus, a unit change in P t induces almost the same change in E (for our realistically chosen parameters). The nearly linear relationship between P t and E becomes even stronger when P t increases because t saturates. For example, when the P t = 10W , the duration of the transmission is 1.08 second and thus, the energy for the transmission is 10.8J. When the objective is to only minimise the BBU consumed time with no energy constraint on the F-UEs, we have shown in [1] that we need to find the optimal (in terms of minimising the BBU transmission time) cooperation between the F-UEs. However, when an energy constraint is set, the F-UEs' collaboration abilities are suppressed. For example, if the energy constraint is very strict and the F-UEs use high transmit power P t , they will easily exceed the constraint and not be allowed to collaborate, which will result in more BBU transmission time (i.e., less offloading). The main factor for the F-UEs to reach the energy limit is the transmit power P t they are using. Thus, in order to achieve best collaboration and minimum BBU time, the F-UEs should use minimum P t . Though this will slow down the transmissions between the F-UEs, the transmission rate degradation is logarithmic.

IV. PROPOSED HEURISTIC ALGORITHM A. EXTENDED NC GRAPH
The proposed algorithm 4 is classified as a greedy weighted vertex search similar to the algorithms in works like [10] and [37]. As shown in Section III, the vertices of the traditional NC graph show only the file each F-UE requests. As explained in [1], it is not convenient to perform vertex search on this graph because the vertices need to also show information about the possible transmitter that will serve the request and the transmission phase in which the communication should happen. Thus, in this paper, we use the extended NC graph that was first introduced in [30]. However, here we further extend the graph to cater for the addition of the energy constraint that influences the creation of the vertices. As shown in Fig. 4, every vertex acquires an additional index (the second one) that represents the used transmit power level. This value is needed for the calculation of the energy that the transmitter will have to spend. If the calculated energy is more than the allowed one, the communication is not allowed and the vertex is deleted.
In this paper, the graph creates two vertices v ipjkl (for transmission phase l = 1 and l = 2) for each F-UE u i that 1) possesses in its Has sets file f k that is requested by u j and 2) needs less energy than E m for transmitting to u j . The design of the graph should well match our two-phased, multi-transmitter, and energy-constrained system, where all requirements and constraints are embedded and every possible conflict represented as an edge between every two conflicting vertices. The conflicts in the system can be categorized as follows: • Coding Conflict: occurs if two F-UEs u i and u j receive a coded packet that contains more than one file which is not known to at least one receiving F-UE making it undecodable for that F-UE. This can mathematically be expressed as: i = i and j = j and k = k and l = l but (f k / ∈ H u i or f k / ∈ H u i ). • Transmission Conflict: occurs if a receiving F-UE is served by more than one transmitting F-UEs in the same transmission phase. This can be written as: i = i and j = j and l = l .
• Half-Duplex Conflict: occurs if an F-UE is scheduled to transmit and receive in the same transmission phase. This conflict is written as: l = l but (i = j or j = i ).
• Temporal Conflict: occurs if the same F-UE is scheduled to transmit or receive in both transmission phases. This conflict can be expressed as: (i = i and l = l ) OR (j = j and l = l ). Note that, initially, the coding conflicts between the vertices for which the BBU is the transmitter will be removed from the graph. Otherwise, any IS-based solution might be incomplete in the sense that it will allow only one transmission from the BBU. However, the BBU is capable of using multiple channels to serve the conflicting requests of F-UEs that were not served by other F-UEs in the two phases. Not including the conflicts between the BBU's vertices thus, allows the inclusion of all such vertices representing non-served requests by F-UEs in any IS. Designed in this way, a maximum IS shows a complete energy-abiding transmission scheme to serve all requested packets by coded transmissions from a subset or all the F-UEs and the BBU 5 in both transmission phases. The question is how to find the IS that, after re-adding the coding conflicts between the BBU vertices, will result in the minimum total transmission time from the BBU. . This extended NC graph shows only some of the F-UEs' and BBU vertices for the example architecture in Fig. 1. Fig. 5 shows the extended NC graph for the motivating example in Section III-A. For clarity, Fig. 5 only depicts some of the F-UEs' vertices and some of the BBU vertices. 6 It was shown earlier that the transmissions from u 5 to both u 2 and u 6 exceed the energy limit and thus, those vertices were not created in the graph. Because the extended graph consists of both the F-UEs' and BBU's vertices, each maximal IS gives a complete transmission scheme (solution) and describes the role of each device in each of the transmission phases. The blue vertices correspond to Solution 1 (after the introduction of the energy limit). It should be noted that at this stage, the BBU vertices are not subjected to the coding conflict. Once the final solution is chosen, in this case Solution 1 (the blue vertices), the coding conflict is applied on the BBU vertices. In this particular case, the BBU can transmit an instantly decodable packet to both u 2 and u 3 . However, if Solution 2 was chosen, the coding conflict would induce edges between the BBU verices indicating that the BBU must transmit the uncoded packets on separate channels.

C. PROPOSED CROSS-LAYER HEURISTIC ALGORITHM
The proposed heuristic uses the extended NC graph to greedily search for the vertices that form a maximum IS including either no BBU vertices at all if possible or BBU vertices that result in the shortest BBU transmission time. The latter case is equivalent to a search for the maximum IS with the maximum number of F-UE vertices that serve the F-UEs having the lowest channel rates to the BBU. The general strategies employed in the proposed heuristic algorithm to achieve this goal can be summarized as follows: 1) Create the extended NC graph that includes only the vertices that do not result in energy constraint violation. 2) Find the IS that contains the maximum number of vertices v ipjkl with worst channels from the BBU to u j (the F-UE requesting the file) and whose u i (the transmitting node) is an F-UE. 3) If some requests remain after finding this IS, the BBU will serve them while minimising the amount of consumed time spent in serving those. 4) Whenever the impact on offloading is similar, the algorithm should try to choose F-UE transmissions that are shorter in time to improve the QoS of the receiving F-UEs and further reduce the energy consumption of the transmitting ones. The proposed algorithm starts by building the graph according to Section IV-A. Each F-UE u j is assigned a rate r u j that represents the channel conditions between the receiving F-UE u j and the BBU. Moreover, each F-UE is assigned a second rate r u ij representing the channel conditions between the transmitting F-UE u i and the receiving F-UE u j . Calculating the channel rates between the cooperative F-UEs allows the algorithm to calculate the time needed in Eq. (5) to check if any of the possible transmissions violates the energy limit. The first strategy can thus be fulfilled by not creating any vertices that violate this limit.
To implement the second strategy, a weighted vertex selection approach will be employed. For each of the created vertices, a preliminary weight can be calculated according to the following equation: Clearly, the weight of vertex v ipjkl has a larger value if the channel between the BBU and u j is bad. This means that the rate from the BBU to user u j is low and thus a transmission from the BBU to this user will consume a long time from the former. Since our aim is to find the solution (i.e., the IS) with the maximum number of maximum weighted F-UE vertices reflecting the above property, we need to introduce more tights of the non-adjacent vertices of vertex v ipjkl into its weights. If we rely only on the weights in Eq. (6), we may select one F-UE vertex that is really bad in terms of channel but is not adjacent to any other bad-channel F-UE vertices. This will either conclude the IS search quickly or will add good-channel F-UE vertices to this IS, leaving a large number of F-UE vertices with very bad-channels to the BBU to be served by the BBU, clearly resulting in very poor performance. That is why we re-weight the vertices to avoid picking the vertex in the above example, and alternatively pick sequentially the ones that are not only bad in terms of channel quality to the BBU but are also nonadjacent with many bad F-UE vertices. This could be done as follows: where N (v ipjkl ) represents the set of vertices that are not adjacent to v ipjkl . Designing the weights this way means that a vertex will accumulate a large weight if it both has a bad channel to the BBU and is not connected (non-adjacent) to many vertices with bad channels to the BBU. Thus, the final solution will contain large number of vertices with slow transmission channels from the BBU. All the vertices in this IS will be served cooperatively by other F-UEs. The algorithm operates in an iterative manner, adding to the solution IS at each iteration the maximum weight vertex that both represents a transmitting F-UE and is non-adjacent to all others previously selected vertices in the IS. To improve the QoS for F-UEs and shorten their transmission times (thus fulfilling the fourth strategy), if two or more vertices have the same highest weight in a particular iteration, the algorithm chooses the vertex with the best channel rate between the transmitting and receiving F-UEs. At the end of this process, the IS only contains vertices representing transmitting F-UEs. If the number of these vertices is the same as the number of requests, the solution is complete and the algorithms stops. This solution will definitely be the best possible scenario as it involves no BBU transmissions at all.
On the other hand, if the number of vertices in the IS is smaller than the number of all F-UE requests, this means that some requests have not been served, and thus the BBU has to serve them. Given the design of the graph, all these requests will be represented by all the remaining non-adjacent BBU vertices in the graph to all the vertices of the chosen IS. The algorithm then adds the coding conflicts to this sub-graph of BBU vertices and employs the algorithm in [28] to partition the BBU subgraph in the smallest number of ISs. As such, the third aforementioned strategy will be fulfilled and the algorithm operation is completed.
The pseudo code of all the aforementioned steps is presented in Algorithm 1.

D. COMPLEXITY ANALYSIS 1) VERTEX GENERATION
The extended NC graph creates a vertex for each requested file that is also in an F-UE's or BBU's cache. Each device is able to transmit the file with one of its allowed power levels p. 7 Thus, the total number of the created vertices depends on the number of the F-UEs in the system, the number of files in each F-UE's Has set and the number of transmitting power levels p. Consider the case when none of the transmissions exceed the energy constraint. If each F-UE has cached all files and all files are wanted, then the induced number of vertices would be 2p(U − 1)U . Moreover, the BBU will induce 2pU vertices making the total number of vertices using Eq. (5), check if v ipjkl is allowed to exist inG. 5: end if 6: Construct G using v ipjkl and the 4 conflicts. 7: Compute w ijkl according to Eq. (7). 8: Initialize k * = ∅ and numCount = 0. 9: for each v ipjkl ∈ G non-conflicting with k * and i = B: do 10: Select v * ipjkl = arg max v ipjkl ∈G w ipjkl 11: Set k * ← k * ∪ v * i,j,k,l 12: numCount = numCount + 1 13: if several v * ipjkl with equal w ipjkl then 14: Select 2p(U − 1)U + 2pU . Thus, the complexity of building the graph's vertices in the worst-case scenario of having no energy constraint violation cases is of order O(U 2 ).

2) ADDING CONFLICT EDGES
The process of adding conflict edges to the graph consists of testing all conflict conditions for each pair of vertices. As shown in [29], checking all vertices against the conflict

5) OVERALL COMPLEXITY
Given the above components, the overall worst-case complexity of the algorithm is O( It is worth mentioning that depending on the presence and strictness of the F-UEs' energy constraints, some of the vertices will not be allowed to exist in the graph and will not participate in building the edges. Therefore, the actual complexity of the algorithm will be much lower than the above worst-case complexity.

V. SIMULATION RESULTS
The simulation results presented in this section quantify the offloading gains achieved by the proposed cross-layer offloading approach in this paper in comparison to the upperlayer network coding schemes in [29], [30]. They also illustrate the benefit of utilizing NC and the impact of changing the energy constraints and transmission power levels on the consumed BBU time and the duration of the cooperative F-UE transmissions. It is assumed that there are 50 files in the BBU library and each F-UE knows 10 of them. During offpeak times, the BBU randomly caches 10 of those 50 popular files on the F-UEs' caches. We assume that the BBU has a large number of orthogonal channels to allocate to the F-UEs so there is no interference between them. Also, the F-UEs are realistically assumed not to be able to communicate with all other F-UEs at a time. For simplicity, we assume that all F-UEs have to comply to the same energy constraint. As mentioned in Section 3, the channels between the BBU and each of the F-UEs follow a Rayleigh distribution, whereas the channels between each pair of cooperating F-UEs follow a Rician distribution. We assume equal packet size of 12 MB, 8 a bandwidth of 200 kHz per channel [35], and a noise power spectral density of −174dBm/Hz [36].

A. COMPARISON WITH UPPER-LAYER OFFLOADING
Here, our algorithm is compared to the upper layer algorithm proposed in [30]. The upper layer algorithm aims to reduce the number of orthogonal channels used by the BBU without considering the physical channel conditions. As it can be seen on Fig. 6, the upper-layer algorithm performs worse compared to the no energy constraint case and even to most of the cases where there is a constraint on the energy that the F-UEs are allowed to use for the collaborative transmissions. Because the upper layer algorithm does not consider the channel rates, the BBU spends more time transmitting. The upper layer catches up with the cross layer performance only at a large number of cooperating users which is not  a typical scenario. The increased number of F-UEs means an increased number of potential transmitters, which allows the BBU to utilise only a small number of channels and improve its performance even if the the channel rates are low. Figures 6 and 7 suggests that the two strategies should work together but for different number of F-UEs. Figures 7 and 8 examine the effect that the energy constraint has on the BBU consumed time for transmit powers of 0.1W and 0.7W, respectively. Clearly, stringing the energy constraint decreases the F-UEs' cooperative capabilities because more F-UEs are likely to exceed the energy limit when sending to one another. This results in an increased consumed time  from the BBU as shown in both figures. The figures show that, when there is an energy constraint in place, the BBU's consumed time increases with the number of F-UEs but with a slower slope as more and more F-UEs are invovled in the system which increases the collaboration opportunities between the F-UEs.

B. EFFECT OF ENERGY CONSTRAINTS AND POWER LEVELS
As stated above, the main difference between Fig. 7 and Fig. 8 is that the F-UE transmit power P t is increased from 0.1W to 0.7W. By comparing each pair of corresponding energy-constrained curves (i.e., curves for the same energy constraint) between both figures, the impact of this power increase is clearly exhibited by an increase in the consumed time from the BBU (less offloading of physical resources). To further clarify this fact, Fig. 9 highlights the values of the energy-constrained curves of both Figures 7 and 8 (plus an added energy constraint level of 0.5) for the case of 10 F-UEs. We can clearly notice from this focused figure the aforementioned effect of increased BBU consumed time when the F-UEs transmit power is increased. This effect can be easily interpreted from Eq. (1) and (5). Indeed, both equations show that a linear increase in P t is accompanied by a logarithmic increase in the bit rate, and thus a logarithmic reduction in the transmission time. The combination of these two factors is a sub-linear increase in the consumed energy in each F-UE transmission. Consequently, the increase in P t causes more F-UEs to exceed their energy constraint and reduce their capacities to serve any other F-UEs, thus resulting in more BBU consumed time spent on serving more unserved F-UEs. For example, at energy constraint of 0.4J and 30 F-UEs, the BBU spends only 8 sec (Fig. 7) when P t = 0.1W , whereas it needs about 25 sec to serve the F-UEs when P t = 0.7W .
Please note that the energy constraints of 0.4J and 0.1J in Fig. (8) exhibit the same BBU consumed time results because they both cannot be fulfilled by any of the F-UEs when P t = 0.7W , and thus all communication is accommodated by the BBU. This is not the case when P t = 0.1W where some F-UEs can still collaborate at the same energy constraint levels (as illustrated in Fig. 10). Another interesting observation from Fig. 9 is that, when P t = 0.1W , relaxing the energy constraint beyond 0.4J does not contribute much to BBU offloading. This suggests that with a correctly chosen energy limit (in this case 0.4J), we can achieve a good BBU offloading and at the same time prolong the F-UEs' battery life.  Fig. 10 confirms that the percentage of cooperating F-UEs decreases with the increase of the transmit power. When P t = 0.1W the F-UEs achieve very similar level of cooperation for both energy constraints which results in similar BBU offloading for those cases as it can be seen in Fig. 9. On the other hand, when P t = 0.7J the F-UEs' cooperation is very different for the two considered energy constraints: no cooperation for E m = 0.4J and some cooperation for the more relaxed constraint of E m = 0.7J . The reason for this drastic difference is the significant contribution of the transmit power P t in the energy equation (5), which leads to many F-UEs surpassing the energy threshold. It can also be noted that the increase in the transmit power, P t has a more significant impact when there are very few F-UEs. For example, when U = 5 and E m = 0.7J , the difference between the cooperation for the two transmit power levels is about 30%. The gap decreases with the increase of the F-UEs and for U = 30, it reaches about 10%. This closing gap can be explained as follows. No matter how many F-UEs there are in the system, they are all subject to the same energy threshold and roughly the same percentage of F-UEs for the different cases pass the constraint. However, the larger number of F-UEs in the system gives the potential transmitting F-UEs more opportunities to serve. On the other hand, when there are few F-UEs in the network, the potential transmitters that pass the energy limit might be hindered by obstacles like not being able to physically communicate with the receiving F-UEs (due to not being in the coverage area of the transmitting F-UE) or no F-UE requesting a file in the potential transmitter's Has set.  In the case of P t = 0.1W , the F-UEs are able to cooperate better but slower and this results in longer average transmission times for the F-UEs and shorter transmission time for the BBU (the BBU's transmit power does not change). However, when the transmit power increases to 0.7W, the F-UEs have limited cooperative capabilities which increases the BBU's working time. This figure shows that in times when the BBU is busy (i.e. peak times), a better offloading of the BBU can be achieved by decreasing the transmit power of the F-UEs  while still meeting the same energy constraint. For example, for 30 F-UEs an offloading of about 10 sec can be achieved by decreasing the F-UEs' P t from 0.7W to 0.1W.
The last two figures examine the effect that NC has on the transmission time. In Fig. 12, the number of the F-UEs is 10 and each of the F-UEs knows 10 files meaning that the size of the Has sets is also constant. As the number of files increases, expectedly the network coded opportunities decrease. This has a similar effect as keeping the number of files F constant but decreasing the number of F-UEs U in the system. The decrease in the number of NC opportunities is due to the fact that having more files in the system decreases the probability of an F-UE wanting a file that is known by another F-UE that also has the first F-UE's wanted file in its Has set. Although the number of the network coded opportunities diminishes, Fig. 13 shows that employing NC when possible is still beneficial. The figure depicts the percentage of reduction in the transmission time among the F-UEs and BBU which is calculated as (t noNC − t NC )/t noNC , where t NC is the average time the devices spend on NC transmissions and t noNC is also the average time the devices spend on the same transmissions but if NC was not allowed. In other words, tNC and tnoNC represent the same transmission time but with and without NC respectively. The figure quantifies the benefit of utilizing NC and shows in percentage how much time is spared by the F-UEs thanks to using NC compared to the traditional uncoded transmissions.

VI. CONCLUSION
In this paper, we developed an energy-constrained and cross-layer network coding device cooperation algorithm for F-RANs aiming to minimise the BBU's consumed physical resources in delivering cached popular files. Our algorithm ensures this minimization of the BBU's consumed physical time while complying with any energy limitations enforced on the devices. We investigate the change on the BBU load under a variety of circumstances and discuss what factors influence the system's performance. Our simulations show the superior performance of our proposed cross-layer network coding approach compared to its conventional upper-layer counterpart in minimising the BBU's consumed physical resources. They also show that having a strict energy constraint and high F-UE transmit power will increase the BBU's consumed time. We finally illustrate the different levels of BBU offloading that can be achieved with different parameters and constraints. Finally, we showed the value of using network coded transmissions in the system.