## 3 System Design
### Fault Detection and Link Self-Healing  
Despite significant technical advancements in the protocol design level, there remains room for improvement in several areas. Specifically, fault recovery mechanisms in complex topologies require optimization, delay control for long-distance, cross-regional transmissions needs further enhancement, and service quality assurance mechanisms in heterogeneous device environments need strengthening. Our proposed chain-based architecture addresses these challenges by simplifying topological complexity and integrating the advantages of the SRT protocol, offering an effective technical solution. While the chain transmission topology offers simplicity and efficiency, its sequential nature means that the failure of any single node can potentially interrupt service for all downstream nodes. To address this critical challenge, this paper designs a robust fault recovery mechanism based on multi-layered detection and intelligent reconstruction [7]. The system employs a three-layered fault detection architecture to ensure rapid and accurate fault localization. Firstly, application-layer heartbeat detection is implemented, where each node sends periodic heartbeat signals to the coordination server via a WebSocket long connection. The heartbeat interval adapts dynamically:  
\[HearbeatInterval=BaselInterval\times(1+\alpha\times Network]itter) \tag{13}\]  
where \(BaselInterval\) is the base heartbeat interval, \(\alpha\) is an adjustment factor, and \(Network\)\(Jitter\) represents the network jitter metric. Secondly, transport-layer connection monitoring is continuously performed by the SRT protocol layer, which assesses link health through various metrics:  
\[HealthScore=w_{1}\times(1-LossRate)+w_{2}\times\frac{1}{RTT_{norm}}+w_{3}\times \frac{1}{Jitter_{norm}} \tag{14}\]where \(w_{1},w_{2},w_{3}\) are weighting coefficients, and \(RTT_{norm}\) and \(Jitter_{norm}\) are normalized RTT and jitter values. Finally, data stream integrity detection within the SRT protocol combines Selective Repeat ARQ with a latency-threshold-based discarding mechanism. Its core process involves each receiver maintaining a receive window, where incoming packets are arranged by sequence number. If a sequence number gap is detected (i.e., \(Seq_{i+1}>Seq_{i}+1\)), it is identified as a packet loss, and a NAK (Negative ACKnowledgement) request is immediately sent to the sender for retransmission of the missing packet. Upon receiving a NAK, the sender only retransmits the specified sequence number, avoiding full-window retransmissions and enhancing efficiency. Concurrently, to ensure real-time performance, SRT assigns a send timestamp \(T_{send}\) to each data packet. The receiver calculates the difference between the current time \(T_{now}\) and \(T_{send}\). If the waiting time \(T_{wait}\) for a lost packet to be retransmitted exceeds the system's maximum allowed latency threshold \(L_{max}\), the system proactively discards that packet, no longer awaiting retransmission, to prevent stale data from affecting subsequent smooth playback. The algorithm pseudo-code for this mechanism is as follows (Algorithm 2):  
```
1:for each packet \(pkt\) in the receive window do
2:if\(pkt\) is lost then
3: Send NAK(\(pkt.seq\)) to request retransmission
4:\(T_{wait}\gets T_{now}-pkt.T_{send}\)
5:if\(T_{wait}>L_{max}\)then
6: Proactively discard \(pkt\), no longer waiting for retransmission
7:endif
8:endif
9:endfor
```  
**Algorithm 2** SRT Packet Loss Detection and Proactive Discarding Algorithm  
The key calculation for packet waiting time is \(T_{wait}=T_{now}-T_{send}\), and the criterion for proactive discarding is  
\[\text{If }T_{wait}>L_{max}\text{, then discard the packet} \tag{15}\]  
where \(L_{max}\) is the maximum latency tolerance threshold configured in the system (e.g., 120 ms, 200 ms).