课程介绍
CS144: 什么,你学不会TCP?那就来自己写一个吧! - 胡津铭的文章 - 知乎
https://zhuanlan.zhihu.com/p/175998415
CS144 is an introductory course about computer networks. You will learn about the basic principles of computer networks, for example packet switching, layering, encapsulation and protocols; and you will learn how applications such as the world-wide-web, video streaming (e.g. Netfix and Hulu), video conferencing (e.g. Zoom and Skype) and BitTorrent use the network to communicate. You will spend quite a lot of time learning about the specifics of how the Internet works - which 1s of course by far the biggest computer network ever built. You will learn how applications communicate reliably over an unreliable Internet. And you will build portions of the Internet yourself! In fact, believe that in CS144 you build more parts of the Internet infrastructure than in any other undergraduate networking class anywhere. It’s really fun to see how the individual pieces work: You build an Internet router, and a reliable data delivery service, and then you use it to communicate with remote servers.
In addition to lectures, we will also have a few in-class guest lectures by outside speakers. All the guest lecturers are excellent speakers with many years of experience making networks work at huge scale. We will also have one Or more in-class exercises, which you will complete during the regular lecture time. These are designed to give you hands-on experience with tools that are useful for your labs.
参考资料
- huangrt01
- 康宇PL’s Blog
- Lexssama’s Blogs
- kiprey
- doraemonzzz
- ViXbob’s libsponge
- 吃着土豆坐地铁的博客
- Smith
- PKUFlyingPig
- 星遥见
- 阿苏EEer
- 阿苏EEer的笔记
- 性能优化
- TCP/IP State Transition Diagram
- TCP Finite State Machine
配置环境
wget https://web.stanford.edu/class/cs144/vm_howto/setup_dev_env.sh
chmod +x setup_dev_env.sh
./setup_dev_env
安装
sudo apt-get install doxygen clang-format
sudo apt install cmake
测试
git clone https://github.com/cs144/sponge
git checkout -b master origin/master
$ tree .
.
├── apps
│ ├── CMakeLists.txt
│ └── webget.cc
├── CMakeLists.txt
├── compile_commands.json -> build/compile_commands.json
├── doctests
│ ├── address_dt.cc
│ ├── address_example_1.cc
│ ├── address_example_2.cc
│ ├── address_example_3.cc
│ ├── CMakeLists.txt
│ ├── parser_dt.cc
│ ├── parser_example.cc
│ ├── socket_dt.cc
│ ├── socket_example_1.cc
│ ├── socket_example_2.cc
│ └── socket_example_3.cc
├── etc
│ ├── build_defs.cmake
│ ├── build_type.cmake
│ ├── cflags.cmake
│ ├── clang_format.cmake
│ ├── clang_tidy.cmake
│ ├── cppcheck.cmake
│ ├── cppreference-doxygen-web.tag.xml
│ ├── Doxyfile.in
│ ├── doxygen.cmake
│ ├── linux-man-doxygen-web.tag.xml
│ ├── rfc-doxygen-web.tag.xml
│ ├── sponge_doxygen.css
│ ├── sponge_small.png
│ ├── tests.cmake
│ └── tunconfig
├── libsponge
│ ├── byte_stream.cc
│ ├── byte_stream.hh
│ ├── CMakeLists.txt
│ └── util
│ ├── address.cc
│ ├── address.hh
│ ├── buffer.cc
│ ├── buffer.hh
│ ├── eventloop.cc
│ ├── eventloop.hh
│ ├── file_descriptor.cc
│ ├── file_descriptor.hh
│ ├── parser.cc
│ ├── parser.hh
│ ├── socket.cc
│ ├── socket.hh
│ ├── tun.cc
│ ├── tun.hh
│ ├── util.cc
│ └── util.hh
├── README.md
├── tests
│ ├── byte_stream_capacity.cc
│ ├── byte_stream_construction.cc
│ ├── byte_stream_many_writes.cc
│ ├── byte_stream_one_write.cc
│ ├── byte_stream_test_harness.cc
│ ├── byte_stream_test_harness.hh
│ ├── byte_stream_two_writes.cc
│ ├── CMakeLists.txt
│ ├── test_err_if.hh
│ ├── test_should_be.hh
│ └── webget_t.sh
└── writeups
└── lab0.md
7 directories, 62 files
doctests
是util
的一些使用样例etc
是配置文件libsponge
是实验中要完善的代码文件util
是实验提供的工具类tests
文件夹中是测试文件
mkdir build && cd build
cmake ..
make format
make -j4
出现以下报错
/home/ubuntu/cs144/sponge/libsponge/util/parser.cc:36:13: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
ret <<= 8;
^ ~
解决方法:
将 ret <<=8;
换成 ret = ret << 8
即可正常运行
$ make -j4
[ 3%] Building CXX object tests/CMakeFiles/spongechecks.dir/byte_stream_test_harness.cc.o
[ 6%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/address.cc.o
[ 10%] Building CXX object libsponge/CMakeFiles/sponge.dir/byte_stream.cc.o
[ 13%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/buffer.cc.o
[ 16%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/eventloop.cc.o
[ 20%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/file_descriptor.cc.o
[ 23%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/parser.cc.o
[ 26%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/socket.cc.o
[ 30%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/tun.cc.o
[ 33%] Linking CXX static library libspongechecks.a
[ 33%] Built target spongechecks
[ 36%] Building CXX object libsponge/CMakeFiles/sponge.dir/util/util.cc.o
[ 40%] Linking CXX static library libsponge.a
[ 40%] Built target sponge
[ 43%] Building CXX object apps/CMakeFiles/webget.dir/webget.cc.o
[ 46%] Building CXX object tests/CMakeFiles/byte_stream_construction.dir/byte_stream_construction.cc.o
[ 50%] Building CXX object tests/CMakeFiles/byte_stream_one_write.dir/byte_stream_one_write.cc.o
[ 53%] Building CXX object tests/CMakeFiles/byte_stream_two_writes.dir/byte_stream_two_writes.cc.o
[ 56%] Linking CXX executable webget
[ 60%] Linking CXX executable byte_stream_construction
[ 60%] Built target webget
[ 60%] Built target byte_stream_construction
[ 63%] Building CXX object tests/CMakeFiles/byte_stream_many_writes.dir/byte_stream_many_writes.cc.o
[ 66%] Linking CXX executable byte_stream_one_write
[ 70%] Building CXX object tests/CMakeFiles/byte_stream_capacity.dir/byte_stream_capacity.cc.o
[ 73%] Linking CXX executable byte_stream_two_writes
[ 73%] Built target byte_stream_one_write
[ 73%] Built target byte_stream_two_writes
[ 76%] Building CXX object doctests/CMakeFiles/parser_dt.dir/parser_dt.cc.o
[ 80%] Building CXX object doctests/CMakeFiles/address_dt.dir/address_dt.cc.o
[ 83%] Linking CXX executable address_dt
[ 86%] Linking CXX executable parser_dt
[ 86%] Built target address_dt
[ 90%] Building CXX object doctests/CMakeFiles/socket_dt.dir/socket_dt.cc.o
[ 90%] Built target parser_dt
[ 93%] Linking CXX executable byte_stream_many_writes
[ 93%] Built target byte_stream_many_writes
[ 96%] Linking CXX executable byte_stream_capacity
[ 96%] Built target byte_stream_capacity
[100%] Linking CXX executable socket_dt
[100%] Built target socket_dt