一个C ++开发人员应该了解网络编程? [英] Everything a c++ developer should know about network programming?

查看:224
本文介绍了一个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次握手,确认,延迟确认,nling,滑动窗口协议。

  • UDP多播...即使你从来没有想过你会使用这些功能,但是它们都会破坏你的应用程序的性能。它需要知道它为什么存在,所以你可以在设计系统时做出有根据的决定。

  • IP碎片和MTU的影响。

  • 二进制串行化和网络字节排序(即使你只是要使用Google proto缓冲区,很高兴理解为什么它们是高效的)。

  • Ascii序列化和消息框架( \r\\\
    \r\\\
    是什么意思在HTTP?)

  • O调度模型:Apache风格预分配,线程每连接,基于事件的单线程,基于事件的工作线程等。

  • 缓冲区溢出漏洞网络应用程序

  • 基于协议的设计,而不是基于API或基于库的设计

  • 异步VS同步协议。许多高性能系统是异步的。 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 \r\n\r\n mean in HTTP?)
  • 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,网络的协议。 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的用户没有组织或合同的负担,没有许可费。

  • Any program can communicate via HTTP, regardless of implementation language
  • Lightweight/embedded environments can pick and choose a subset of the protocol, rather than using the whole thing
  • It's possible to optimize a protocol handler for particular situations. It's not possible to optimize a library without sacrificing generality.
  • A variety of different implementations forces library providers to address bugs (rather than just blowing them off because, well, everyone uses the same library).
  • There is no organizational or contractual burden on users of HTTP, no licensing fees.

当您设计网络协议时,您可以构建自己的几个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 ++开发人员应该了解网络编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆