Design an ipstack in C++
I want to implement an IP stack in C++ as a training project for me to the Linux and networking world. I have some knowledge of how the Linux IP stack works, but, as I said I want to implement something in C++ which has a good design rather then focusing on performance.
Does anyone know where I c开发者_Python百科an find written design for IP stacks written in C++ (some UML + sequence diagram)?
I would have thought that very little UML design for TCP/IP stacks would exist, but a search did find a few references. However, none of these appear to be very extensive, and none that I would really recommend.
If you can find source code for an IP stack in an OO language, you should be able to extract useful classes and start to create your own models.
Obviously writing working source code is the ultimate end game, but if you are wanting to learn about network protocols, there is nothing like reading the RFCs, or a good book (such as Comer and Stevens) and creating your own models from scratch. Taking someone else's UML and creating code would seem to defeat the purpose of the exercise which is to learn about the network protocols - how will you know how good the models are without understanding the RFCs?
There is a great book by Moy called "OSPF Complete Implementation" which has C++ code, but also a few class diagrams throughout that model interfaces and LSAs very well.
I'm not sure if either of these is a good example, but you could always look at the source code for the Linux and FreeBSD IP stacks.
I'd recommend picking up a copy of Internetworking with TCP/IP, Volume II: Design, Implementation, and Internals, by Douglas E. Comer and David L. Stevens. It presents the source code to a TCP/IP implementation and goes through it with a lot of commentary.
"TCP/IP Illustrated, Volumes 1-3" are the authoritative work on the subject. I recall, the original BSD stack was implemented based on volume 2. Volume 1 explains the protocols in detail. The RFC standard documents are also quite accessible to the average programmer, and you will need them if you want a modern, compliant implementation because those books are old. There have been many additions and changes to the standards over the years, IPv6 being one of the big ones.
The other thing you may need to consider is the Ethernet protocol that (usually) underlies the IP layer. There are books but I haven't read enough of any of them to recommend one. The standards are freely available from the IEEE. http://standards.ieee.org/getieee802/802.11.html
精彩评论