  In this paper, we consider a cooperative device-todevice (D2D) communication
system, where the D2D transmitters (DTs) act as relays to assist the densified
cellular network users (CUs) for transmission quality of service (QoS)
improvement. The proposed system achieves a win-win situation, i.e. improving
the spectrum efficiency of the CUs that cannot meet their rate requirement
while providing spectrum access for D2D pairs. Unlike previous works, to reduce
the overhead, we design a novel two-timescale resource allocation scheme, in
which the pairing between CUs and D2D pairs is decided at a long timescale and
transmission time for CU and D2D pair is determined at a short timescale.
Specifically, to characterize the long-term payoff of each potential CU-D2D
pair, we investigate the optimal cooperation policy to decide the transmission
time based on the instantaneous channel state information (CSI). We prove that
the optimal policy is a threshold policy which can be achieved via binary
search. Since CUs and D2D pairs are self-interested, they are paired only when
they agree to cooperate mutually. Therefore, to study the cooperation behaviors
of CUs and D2D pairs, we formulate the pairing problem as a matching game,
based on the long-term payoff achieved by the optimal cooperation policy of
each possible pairing. Furthermore, unlike most previous matching models in D2D
networks, we allow transfer between CUs and D2D pairs to improve the
performance. To solve the pairing problem, a distributed algorithm is proposed,
which converges to an \epsilon-stable matching. We show that there is a
tradeoff between the optimality and the computational complexity of the
algorithm. We also analyze the algorithm in terms of the robustness to the
unilateral deviation of D2D pairs. Finally, the simulation results verify the
efficiency of the proposed matching algorithm.
