Everything a c++ developer should know about network programming?(C++ 开发人员应该了解的有关网络编程的所有信息?)
问题描述
所以我正在使用 Boost::Asio(或者如果你愿意的话,也可以只使用 Asio)进行大量高性能网络编程,并且对 TCP 和 UDP 协议的基本知识有相当扎实的掌握.不过我想知道,因为尽管我有知识,但我仍然不认为自己是网络专家,什么是构建网络程序员应该知道的基本知识的好方法,特别是对于那些试图提高基于大型网络的性能的人应用?
So I am doing a lot of high performance network programming using Boost::Asio (or just Asio if you will), and have a pretty solid grasp of the essentials of both TCP and UDP protocols. I am wondering though, because I still don't consider myself an expert in networking despite my knowledge, what is a good way to frame the essentials of what networking programmers should know, especially for those trying to push the performance of their large networking based applications?
有一篇关于程序员以及他们应该了解的关于内存的好文章(见下文),所以我想知道是否有人为网络整理了类似的东西.
There is a great essay on programmers and what they should know about memory (see below), so I'm wondering if someone has put together something similar for networking.
每个程序员都应该了解的内存知识
推荐答案
你应该知道的一些要点:
Some bullet points off the top of my head of things you should know:
- TCP 工作原理和原理... 3 次握手、确认、延迟 ack、nagling、滑动窗口协议.这些功能中的每一项都有具体的原因......如果处理不当,它们都会破坏您的应用程序的性能.
- UDP 多播...即使您从未想过会使用它,您也需要知道它存在的原因,以便在设计系统时做出明智的决策.
- IP 碎片化,以及 MTU 的影响.
- 二进制序列化和网络字节排序(即使您只是要使用 Google proto 缓冲区,也很高兴了解为什么它们是高效的).
- Ascii 序列化和消息框架(
- 不同的 I/O 调度模型:Apache 风格的预分叉、每个连接的线程、基于事件的单线程、基于事件的工作线程等.
- 缓冲区溢出漏洞对联网应用的影响
- 基于协议的设计,而不是基于 API 或库的设计
- 异步与同步协议.许多高性能系统是异步的.除非您使用流水线,否则 HTTP 是同步的,即使那样,对可能的操作也有很多限制……例如,没有无序响应.
- How and why TCP works... 3-way handshakes, acknowledgement, delayed ack, nagling, sliding window protocol. There's a concrete reason for every one of those features... and they can all destroy your application's performance if handled improperly.
- UDP multicast... even if you never think you'll use it, you need to know why it exists so you can make educated decisions when designing systems.
- IP fragmentation, and the impact of MTU.
- Binary serialization and network byte ordering (even if you're just going to use Google proto buffers, it's nice to understand why they are efficient).
- Ascii serialization and message framing (what does
- Different I/O dispatch models: Apache-style preforking, thread-per-connection, event-based single-threaded, event-based with worker threads, etc.
- The impact of buffer-overflow vulnerabilities in a networked app
- Protocol-based design, as opposed to API- or library-based design
- asynchronous vs synchronous protocols. Many high-performance systems are asynchronous. HTTP is synchronous unless you use pipelining, and even then, there are many restrictions on what is possible... no out-of-order responses, for example.
更新:基于协议的设计是什么意思?
Update: What does protocol-based design mean?
以 HTTP 为例,它是 Web 的协议.Apache、IIS、Lighttpd、Firefox、Opera、WebKit 等……所有这些软件都使用 HTTP.很可能他们都没有共享代码来这样做.当然,不利的一面是由于代码的净量而增加了错误的可能性.有很多好处:
Consider HTTP, the protocol of the web. Apache, IIS, Lighttpd, Firefox, Opera, WebKit, etc... All of these pieces of software speak HTTP. It's quite possible that none of them are sharing the code to do so. The downside, of course, is the increased likelihood of bugs due to the net volume of code. There are numerous upsides:
- 任何程序都可以通过 HTTP 进行通信,无论实现语言如何
- 轻量级/嵌入式环境可以挑选协议的一个子集,而不是使用整个协议
- 可以针对特定情况优化协议处理程序.在不牺牲通用性的情况下优化库是不可能的.
- 各种不同的实现迫使库提供者解决错误(而不是仅仅因为每个人都使用同一个库而将它们吹走).
- HTTP 用户没有组织或合同负担,也没有许可费用.
当您设计网络协议时,您可以自己构建多个 API,每个 API 都针对特定用例量身定制.或者你可以建立一个,这取决于你.联网的软件组件可以相互独立升级.基本上,您听到的所有关于 Java/C# 接口和 C++ 抽象类的优点,但都应用在网络层而不是编程语言层.
When you design a network protocol, you can build yourself several APIs, each tailored towards specific use-cases. Or you can build one, it's up to you. Networked software components can be upgraded independent of each other. Basically, everything you hear that's good about Java/C# Interfaces and C++ abstract classes, but applied at the network layer rather than the programming language layer.
这篇关于C++ 开发人员应该了解的有关网络编程的所有信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 开发人员应该了解的有关网络编程的所有信息?
基础教程推荐
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 从 std::cin 读取密码 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01