CS144 环境配置

CS144课程是关于计算机网络的入门课,学生将学习网络原理,如分组交换、分层、封装和协议,并亲手构建互联网的部分基础设施,包括路由器和可靠数据传递服务。课程包含嘉宾讲座、课堂练习,提供实践经验,如使用Doxygen和CMake进行代码管理和文档生成。
摘要由CSDN通过智能技术生成

课程介绍

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.

参考资料

配置环境

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
  • doctestsutil 的一些使用样例
  • 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

调试方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值