1. 网络编程概要
1. 網絡分層
以太網幀 IP分組 TCP分段 應用層消息
2. 網絡編程的坑
1. TCP收到不完整的數據。TCP連接斷開的時機不對。close太早,容易出現reset連接重置;在阻塞編程中可以使用so_linger選項,在非阻塞編程中使用應用層協(xié)議處理。 2. 發(fā)送一個C struct到對端,使用pack選項,導致第三方庫奔潰 3. TCP的自連接。localhost:54321 <--> localhost:54321。客戶端和自己連接
3. TCP/IP over 1Gb
實驗1: atom --> e6400 atom: dd if=/dev/zero bs=1MB count=1000 | nc e6400 5001 e6400: nc -l 5001 > /dev/null注意: 在ubuntu默認使用的是nc-freebsd版本,要安裝traditional版本實驗2:本機使用文件進行測試 atom: nc -l 5001 > /dev/null atom: time nc localhost 5001 < 1G_file實驗3: 使用pv -W顯示速度 atom: nc -l 5001 | pv -W > /dev/null atom: dd if=/dev/zero bs=1MB count=1000 | nc localhost 5001實驗結果: 1. 118MB/s between atom and {e640, e350} 2. 580MB/s on atom, dd | nc, nc -l > /dev/null 3. 1074MB/s on atom, nc < file, nc -l > /dev/null
轉載于:https://www.cnblogs.com/tanghe1219/p/10652637.html
總結
- 上一篇: [转帖]迎战AMD 7nm 64核EPY
- 下一篇: python3 requests 库