149-switch

本文介绍如何使用C语言通过深度优先策略遍历链表,详细阐述了算法思路并提供代码实现,帮助理解链表操作和深度优先搜索的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//149-switch
#include <stdio.h>
int main(void)
{
   
   
	int a,b;
	char c;
	int sum
freeswitch@localhost.localdomain> recv 1026 bytes from udp/[183.227.181.232]:1864 at 09:19:10.523919: ------------------------------------------------------------------------ INVITE sip:[email protected]:5080 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport Max-Forwards: 70 Contact: <sip:[email protected]:1864> To: "18996228654"<sip:[email protected]:5080> From: "03512332064"<sip:[email protected]:5080>;tag=842b1e78 Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 INVITE Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO Content-Type: application/sdp User-Agent: eyeBeam release 1011d stamp 40820 Content-Length: 435 v=0 o=- 8 2 IN IP4 10.168.1.102 s=CounterPath eyeBeam 1.5 c=IN IP4 10.168.1.102 t=0 0 m=audio 15344 RTP/AVP 0 8 18 101 a=alt:1 3 : 0E+mq1nU hFt+pKdF 172.28.16.1 15344 a=alt:2 2 : 65/yrvXK tFeCv5wr 172.17.144.1 15344 a=alt:3 1 : dKt7HfUt 78IDBaMu 10.168.1.102 15344 a=fmtp:18 annexb=no a=fmtp:101 0-15 a=rtpmap:18 G729/8000 a=rtpmap:101 telephone-event/8000 a=sendrecv a=x-rtp-session-id:02EC42FF7A2C4B7B91C41D4000CC93D6 2025-07-19 09:19:10.517138 100.00% [NOTICE] switch_channel.c:1142 New Channel sofia/external/[email protected]:5080 [4bd59857-2eb6-4470-987d-446b63d19f14] 2025-07-19 09:19:10.517138 100.00% [INFO] sofia.c:10460 sofia/external/[email protected]:5080 receiving invite from 183.227.181.232:1864 version: 1.10.12-release git a88d069 2024-08-02 21:02:27Z 64bit call-id: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. 2025-07-19 09:19:10.517138 100.00% [INFO] mod_dialplan_xml.c:639 Processing 03512332064 <03512332064>->18996228654 in context public send 448 bytes to udp/[183.227.181.232]:1864 at 09:19:10.526257: ------------------------------------------------------------------------ SIP/2.0 100 Trying Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport=1864;received=183.227.181.232 From: "03512332064"<sip:[email protected]:5080>;tag=842b1e78 To: "18996228654"<sip:[email protected]:5080> Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 INVITE User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Content-Length: 0 EXECUTE [depth=0] sofia/external/[email protected]:5080 set(outside_call=true) EXECUTE [depth=0] sofia/external/[email protected]:5080 export(RFC2822_DATE=Sat, 19 Jul 2025 09:19:10 +0800) EXECUTE [depth=0] sofia/external/[email protected]:5080 log(INFO Calling outbound number: 18996228654) 2025-07-19 09:19:10.517138 100.00% [INFO] mod_dptools.c:1865 Calling outbound number: 18996228654 EXECUTE [depth=0] sofia/external/[email protected]:5080 bridge(sofia/gateway/121_40_149_63_6086/18996228654) 2025-07-19 09:19:10.517138 100.00% [NOTICE] switch_channel.c:1142 New Channel sofia/external/18996228654 [35bf0415-4fe3-4206-8d41-eda1d8e43604] 2025-07-19 09:19:10.517138 100.00% [INFO] sofia_glue.c:1659 sofia/external/18996228654 sending invite call-id: (null) send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:10.529992: ------------------------------------------------------------------------ INVITE sip:[email protected].149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:[email protected]>;tag=pa6eaSDe6Xyej To: <sip:[email protected].149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149[email protected]:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:[email protected]>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:11.530080: ------------------------------------------------------------------------ INVITE sip:[email protected].149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:[email protected]>;tag=pa6eaSDe6Xyej To: <sip:[email protected].149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149[email protected]:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:[email protected]>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:13.530314: ------------------------------------------------------------------------ INVITE sip:[email protected].149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:[email protected]>;tag=pa6eaSDe6Xyej To: <sip:[email protected].149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149[email protected]:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:[email protected]>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:17.530507: ------------------------------------------------------------------------ INVITE sip:[email protected].149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:[email protected]>;tag=pa6eaSDe6Xyej To: <sip:[email protected].149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149[email protected]:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:[email protected]>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:25.531945: ------------------------------------------------------------------------ INVITE sip:[email protected].149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:[email protected]>;tag=pa6eaSDe6Xyej To: <sip:[email protected].149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149[email protected]:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:[email protected]>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 send 1145 bytes to udp/[121.40.149.63]:6086 at 09:19:41.532767: ------------------------------------------------------------------------ INVITE sip:[email protected].149.63:6086 SIP/2.0 Via: SIP/2.0/UDP 27.25.152.174:5080;rport;branch=z9hG4bKF27pv3mFS6p9g Max-Forwards: 69 From: "03512332064" <sip:[email protected]>;tag=pa6eaSDe6Xyej To: <sip:[email protected].149.63:6086> Call-ID: 3718d4b7-dee1-123e-558e-246e963b2e1c CSeq: 101890183 INVITE Contact: <sip:gw+121_40_149[email protected]:5080;transport=udp;gw=121_40_149_63_6086> User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Content-Type: application/sdp Content-Disposition: session Content-Length: 246 X-FS-Support: update_display,send_info Remote-Party-ID: "03512332064" <sip:[email protected]>;party=calling;screen=yes;privacy=off v=0 o=FreeSWITCH 1752856774 1752856775 IN IP4 27.25.152.174 s=FreeSWITCH c=IN IP4 27.25.152.174 t=0 0 m=audio 31176 RTP/AVP 0 8 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=ptime:20 2025-07-19 09:19:42.517142 100.00% [NOTICE] sofia.c:8736 Hangup sofia/external/18996228654 [CS_CONSUME_MEDIA] [RECOVERY_ON_TIMER_EXPIRE] 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1762 Session 6 (sofia/external/18996228654) Ended 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1766 Close Channel sofia/external/18996228654 [CS_DESTROY] 2025-07-19 09:19:42.537141 100.00% [INFO] mod_dptools.c:3635 Originate Failed. Cause: RECOVERY_ON_TIMER_EXPIRE 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_channel.c:5012 Hangup sofia/external/[email protected]:5080 [CS_EXECUTE] [RECOVERY_ON_TIMER_EXPIRE] send 845 bytes to udp/[183.227.181.232]:1864 at 09:19:42.544835: ------------------------------------------------------------------------ SIP/2.0 408 Request Timeout Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport=1864;received=183.227.181.232 Max-Forwards: 70 From: "03512332064"<sip:[email protected]:5080>;tag=842b1e78 To: "18996228654" <sip:[email protected]:5080>;tag=N1cp8Xva9m8Up Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 INVITE User-Agent: FreeSWITCH-mod_sofia/1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit Accept: application/sdp Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY Supported: timer, path, replaces Allow-Events: talk, hold, conference, refer Reason: Q.850;cause=102;text="RECOVERY_ON_TIMER_EXPIRE" Content-Length: 0 Remote-Party-ID: "18996228654" <sip:[email protected]>;party=calling;privacy=off;screen=no 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1762 Session 5 (sofia/external/[email protected]:5080) Ended 2025-07-19 09:19:42.537141 100.00% [NOTICE] switch_core_session.c:1766 Close Channel sofia/external/[email protected]:5080 [CS_DESTROY] recv 374 bytes from udp/[183.227.181.232]:1864 at 09:19:42.577655: ------------------------------------------------------------------------ ACK sip:[email protected]:5080 SIP/2.0 Via: SIP/2.0/UDP 10.168.1.102:59028;branch=z9hG4bK-d87543-b7678846ac1d547d-1--d87543-;rport To: "18996228654" <sip:[email protected]:5080>;tag=N1cp8Xva9m8Up From: "03512332064"<sip:[email protected]:5080>;tag=842b1e78 Call-ID: M2ZiZDEzZTk3ZTZmMDBmNDFkYTg1NDNhM2I5MDk4NWI. CSeq: 1 ACK Content-Length: 0
07-20
在排查 FreeSWITCH 中 SIP INVITE 请求超时导致呼叫失败的问题时,需要综合考虑网络环境、SIP 协议交互流程、FreeSWITCH 配置参数以及 UA(User Agent)行为等多个方面。以下是一些关键分析点和建议,帮助定位和解决 `RECOVERY_ON_TIMER_EXPIRE` 错误。 ### SIP INVITE 请求超时的常见原因 SIP 协议中,INVITE 请求用于建立会话。在 FreeSWITCH 中,如果 INVITE 请求未能在预期时间内收到响应(如 100 Trying、180 Ringing 或 200 OK),则会触发超时机制,并最终导致呼叫失败,错误信息为 `RECOVERY_ON_TIMER_EXPIRE`。这通常表示 INVITE 请求在传输层(如 UDP 或 TCP)上未能及时收到响应,可能的原因包括: 1. **网络延迟或丢包** - SIP 请求在传输过程中因网络延迟过高或丢包未能及时到达目标 UA。 - 建议使用 `tcpdump` 或 `Wireshark` 抓包分析网络通信情况,确认 INVITE 请求是否到达远端 UA,以及是否有响应返回。 - 检查防火墙或 NAT 设备是否拦截了 SIP 或 RTP 流量。 2. **SIP UA 未正确响应** - 远端 UA 没有正确处理 INVITE 请求,或未发送任何响应(如 100 Trying)。 - 检查 UA 的日志,确认其是否收到 INVITE 请求,并查看其响应行为。 - 可尝试使用 `sip debug` 命令在 FreeSWITCH 控制台中启用 SIP 调试模式,查看 INVITE 请求和响应的详细交互过程。 3. **FreeSWITCH 配置参数设置不当** - FreeSWITCH 中涉及 SIP 超时的配置参数包括: - `session-recovery`:控制会话恢复行为。 - `rtp-ip` 和 `rtp-port`:定义 RTP 流量的 IP 和端口。 - `rtp-timeout-sec`:定义 RTP 流在无数据传输时的超时时间。 - `rtp-hold-timeout-sec`:定义在保持状态下的 RTP 超时时间。 - `media-timeout`:定义媒体流未建立时的超时时间。 - 这些参数可以在 `sip_profiles` 配置文件中进行调整,以适应特定网络环境和业务需求。 4. **B2BUA 或 SBC 的 SIP 消息重构问题** - 在涉及 B2BUA(Back-to-Back User Agent)或 SBC(Session Border Controller)的场景中,消息可能被重构或转发延迟。 - 根据 RFC 7329 的规定,B2BUA 应当复制原始 INVITE 请求中的 `Call-ID`,以确保会话的连续性。如果 `Call-ID` 被修改,可能导致远端 UA 无法识别请求,从而不返回响应。 - 确保 B2BUA 或 SBC 正确处理 `Call-ID` 和 `CSeq` 等字段,避免因字段不一致导致超时。 5. **NAT 和防火墙问题** - 如果 UA 位于 NAT 后面,可能需要配置 STUN、TURN 或 ICE 来协助 NAT 穿透。 - 在 FreeSWITCH 中,可以通过设置 `rtp-port-min` 和 `rtp-port-max` 来定义 RTP 端口范围,并确保防火墙允许这些端口的流量通过。 6. **DNS 解析问题** - 如果 INVITE 请求的目标地址是域名,可能因 DNS 解析失败或延迟导致请求无法发送。 - 检查 DNS 配置,确保 FreeSWITCH 能够正确解析目标域名。 7. **SIP 协议栈问题** - FreeSWITCH 使用 Sofia-SIP 协议栈处理 SIP 消息。如果协议栈内部发生错误,可能导致 INVITE 请求未能正确发送或接收。 - 检查 FreeSWITCH 日志(如 `fs_cli` 中的 `console loglevel 7`),查看是否有协议栈相关的错误或警告信息。 ### 解决方案与调试建议 - **启用 SIP 调试** 在 FreeSWITCH 控制台中执行以下命令启用 SIP 调试: ```bash sip debug ``` 这将显示详细的 SIP 消息交互过程,帮助识别 INVITE 请求是否被发送、是否收到响应等。 - **调整超时参数** 如果网络延迟较高,可以适当增加以下参数的值,以延长超时时间: ```xml <param name="rtp-timeout-sec" value="30"/> <param name="media-timeout" value="30"/> ``` 这些参数可以在 `sip_profiles/internal.xml` 或 `sip_profiles/external.xml` 中进行配置。 - **检查防火墙/NAT 配置** 确保 SIP 和 RTP 端口(默认 SIP 端口为 5060,RTP 端口范围通常为 16384–32768)在防火墙中开放,并配置正确的 NAT 映射。 - **使用抓包工具分析流量** 使用 `tcpdump` 或 `Wireshark` 抓取 SIP 流量,确认 INVITE 请求是否到达目标 UA,并查看是否有响应返回: ```bash tcpdump -i eth0 -nn port 5060 -w sip_capture.pcap ``` - **测试 UA 的响应行为** 使用软电话(如 Zoiper、Linphone 或 eyeBeam)进行测试,确保 UA 能够正确响应 INVITE 请求,并发送 100 Trying 或 180 Ringing 等临时响应。 - **验证 B2BUA/SBC 的行为** 如果使用了 B2BUA 或 SBC,确保其正确复制 `Call-ID` 和 `CSeq`,并及时转发 INVITE 请求和响应。 ### 示例:FreeSWITCH SIP 调试日志片段 ```bash 2025-04-05 12:34:56.789510 [DEBUG] sofia.c:1010 sip_trace: Sending INVITE to sip:[email protected] 2025-04-05 12:34:56.790123 [DEBUG] nta.c:1234 nta_outgoing_tsend: Sending SIP message via UDP/192.168.1.1:5060 2025-04-05 12:34:56.790234 [DEBUG] tport.c:5678 tport_send: Sending message to 192.168.1.100:5060 2025-04-05 12:35:01.790543 [WARNING] sofia.c:1111 sofia_handle_sip_response: No response received for INVITE, timeout 2025-04-05 12:35:01.790654 [INFO] switch_core_session.c:2345 switch_core_session_hup: Session hanged up with RECOVERY_ON_TIMER_EXPIRE ``` ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

向上Claire

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值