SIP 与直接 TCP 套接字
我正在为 Android 实现一个实时多用户语音传输应用程序。 我读过,作为标准 - RTP 数据包被封装到 SIP 中,然后发送到目的地。这样做有什么好处呢?
我的想法是使用服务器,只是为了接收来自节点和打开套接字的控制消息。所有这些节点将位于 1 组中。然后,我发送出每个节点的 IP 地址,以便单个发送者可以将其数据包直接组播到目的地。
这里有致命的缺陷吗? (我不关心功耗) SIP 如何做得更好?或者是吗?
谢谢
I am implementing a real time - multi user voice transfer application for Android.
I have read that, as a standard - RTP packets are encapsulated into SIP and then sent to destination(s). What is the advantage of doing so?
my idea was to use a server, just to receive control messages from nodes and open sockets. All these nodes would be in 1 group. THen, I send out the IP addresses of each of these nodes, so that a single sender can multicast its packets directly to the destination.
is there a fatal flaw here? ( iam not concerned about the power consumption)
How does SIP do better? or does it ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SIP 或会话启动协议是专门为解决您要解决的问题而设计的协议。一般来说,你应该重用(而不是重新发明轮子)的原因是因为其他人已经研究了同样的问题,并且作为一个集体团体可能比你作为个人提出了更好的解决方案。当然这并不总是正确的,但一般来说它是成立的!
如果您想了解 SIP,您可以研究 RFC 3261 规范,或者从如果您想快速了解,请使用维基百科条目。
话虽这么说,如果您不需要完整且经过仔细测试的协议的开销,您可以推出自己的协议,但请确保当您做出决定时,您知道自己要放弃什么,并且有充分的理由这样做。
SIP 是一种通常在 TCP 上运行的信令协议(尽管不是必需的),如果您仔细观察它,您会发现它在许多方面与 HTTP 非常相似。就像 HTTP 一样,它可以传输大量的有效负载,并且通过文本标头来传输,就像 HTTP 可用于传输 HTML、XML、纯文本或任何任意二进制有效负载一样。
SIP or Session Initiation Protocol is a protocol that was designed specifically to address the problem you're trying to solve. Generally, the reason you should reuse (rather than reinvent the wheel) is because other people have studied the same problem and presumably have come up with a better solution as a collective group than you could as an individual. Of course that's not always true, but generally speaking it holds!
If you want to learn about SIP you could study the RFC 3261 specification, or start with the Wikipedia entry if you want a quick overview.
That being said, if you don't need the overhead of a complete and carefully tested protocol you could roll your own but make sure that when you're making that decision you know what you're foregoing and have a good reason to do so.
SIP is a signaling protocol that usually runs over TCP (although not required) and if you look at it closely you will see it is very similar to HTTP in many respects. Just like HTTP it can transport a great deal of payloads and it does so with text headers, much like HTTP can be used to transport HTML, XML, plain text or any arbitrary binary payload.
在最简单的系统中,您可以仅使用基于 UDP 的 RTP 的语音数据包。
但是您无法关闭音频,并且必须事先知道 IP 地址、端口号、编解码器类型及其特性。
从过于简单的角度来看,SIP 是一种:
1. 从 URL 中查找另一个端点的 IP 地址。 (可能需要 STUN、TURN、ICE 等)
2. 就使用哪个编解码器及其选项达成一致
SIP 的功能远不止于此,您可能希望根据您编写的内容研究 SIP 的会议功能。
您可以编写自己的信令协议,如果这是用于学校项目,那么效果就很好。
但如果您正在做一个商业项目,请记住,电话技术的内涵远不止表面看上去的那么简单。最初的 SIP 规范经过了很大的修改,现在是一个仍在修改和添加的 RFC 集群。我建议您利用这项工作,而不是重新发明其他人所犯的错误。
In the most simple system, you could just use Voice packets over RTP over UDP.
But you'd have no way to turn audio off, and would have to know IP addresses, port numbers, they type of codec and its characteristics beforehand.
In an overly simple view, SIP is a way to:
1. find the ip address of another endpoint from a URL. (May need STUN, TURN, ICE, etc)
2. agree on which codec to use and its options
There's a lot more to SIP than that, you may want to investigate SIP's conferencing features based on what you wrote.
You may write your own signaling protocol, and if this is for a school project, that will work just fine.
But if you are doing a commercial project, bear in mind that there is a lot more to telephony than meets the eye. The original SIP spec was greatly revised and is now a cluster of RFCs which are still being modified and added to. I recommend that you take advantage of this work rather than possibly reinventing the mistakes others have made.