All Projects → Trinkle23897 → router

Trinkle23897 / router

Licence: MIT license
造路由器 (清华大学 网络原理课程 2018-2019秋)

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to router

LiteNetwork
A simple and fast .NET networking library compatible with .NET Standard 2, .NET 5, 6 and 7.
Stars: ✭ 66 (+26.92%)
Mutual labels:  socket
tcp-net
Build tcp applications in a stable and elegant way
Stars: ✭ 42 (-19.23%)
Mutual labels:  socket
AndroidNetworkProgramming
Android网络编程实战总结,涉及HTTP、TCP、UDP常用协议。
Stars: ✭ 34 (-34.62%)
Mutual labels:  socket
khudro
Khudro is a very light weight web-server built with C.
Stars: ✭ 19 (-63.46%)
Mutual labels:  socket
angular-chat
Angular v.9, Node.js, Nest.js v.6, Mongoose, Socket.io, Passport, Angular Universal SSR (in progress...)
Stars: ✭ 35 (-32.69%)
Mutual labels:  socket
cAndroid
cAndroid is tool for control your PC by Android phone
Stars: ✭ 23 (-55.77%)
Mutual labels:  socket
gen-cisco
🧨 Generates Cisco scripts based on YAML files
Stars: ✭ 29 (-44.23%)
Mutual labels:  rip
fastcli
CLI tool powered by Nornir 3.0 for network automation fast configuration. Support BGP, OSPF, EIGRP, RIP auto-configuration.
Stars: ✭ 38 (-26.92%)
Mutual labels:  rip
socketwrapper
Async/Sync networking library including UDP, TCP and TLS/TCP socket classes written in C++ 17.
Stars: ✭ 33 (-36.54%)
Mutual labels:  socket
FTP
FTP客户端,服务端
Stars: ✭ 34 (-34.62%)
Mutual labels:  socket
socket.io-client-core
High-Performance Socket.IO client in C#
Stars: ✭ 70 (+34.62%)
Mutual labels:  socket
TinyChat
💬 Extra small chat client with GUI
Stars: ✭ 15 (-71.15%)
Mutual labels:  socket
Moxo-Tech
Android智慧互动课堂(课堂辅助软件),包含client和server
Stars: ✭ 25 (-51.92%)
Mutual labels:  socket
RRQMSocket
TouchSocket是.Net(包括 C# 、VB.Net、F#)的一个整合性的、超轻量级的网络通信框架。包含了 tcp、udp、ssl、http、websocket、rpc、jsonrpc、webapi、xmlrpc等一系列的通信模块。一键式解决 TCP 黏分包问题,udp大数据包分片组合问题等。使用协议模板,可快速实现「固定包头」、「固定长度」、「区间字符」等一系列的数据报文解析。
Stars: ✭ 286 (+450%)
Mutual labels:  socket
tcp-multiplexer
A TCP service multiplexer in Python
Stars: ✭ 32 (-38.46%)
Mutual labels:  socket
node-bitstamp
bitstamp REST and WS API Node.js client 💵
Stars: ✭ 58 (+11.54%)
Mutual labels:  socket
KingNetwork
KingNetwork is an open source library to facilitate the creation and communication of clients and servers via TCP, UDP, WebSocket and RUDP sockets.
Stars: ✭ 78 (+50%)
Mutual labels:  socket
sockerl
Sockerl is an advanced Erlang/Elixir socket framework for TCP protocols and provides fast, useful and easy-to-use API for implementing servers, clients and client connection pools.
Stars: ✭ 26 (-50%)
Mutual labels:  socket
Socket
The Hoa\Socket library.
Stars: ✭ 61 (+17.31%)
Mutual labels:  socket
vue3-chat
2021👨‍🎓Vue2/3全家桶 + Koa+Socket+Vant3前后端分离移动端聊天应用。vue+node全栈入门项目
Stars: ✭ 46 (-11.54%)
Mutual labels:  socket

router

For exp3, use the following command to generate rip executable file:

g++ rip.cpp -orip -O2 -lpthread -DRIP_MAIN

# RUN:
./rip

The rip output log may seem like this:

get 192.168.  4.  1	iface enp7s0
get 172. 16.  9.  1	iface vmnet1
get 172. 16.181.  1	iface vmnet8
get 192.168.  3.  2	iface enx000ec6aa5f42
-----------------------------------------------------
   |        Network       |   Nexthop Addr  | Metric 
-----------------------------------------------------
 C | 192.168.  4.  1 / 24 |   0.  0.  0.  0 |    1
 C |   3.  0.  0.  0 / 24 |   0.  0.  0.  0 |   16
 C | 172. 16.  9.  1 / 24 |   0.  0.  0.  0 |    1
 C | 172. 16.181.  1 / 24 |   0.  0.  0.  0 |    1
 C | 192.168.  3.  2 / 24 |   0.  0.  0.  0 |    1
-----------------------------------------------------
send to 192.168.  4.  1 succeed! packet len: 64
send to 172. 16.  9.  1 succeed! packet len: 64
send to 172. 16.181.  1 succeed! packet len: 64
send to 192.168.  3.  2 succeed! packet len: 64
receive len: 64	cmd: 2	ver: 2	from 192.168.3.1
get 192.168.  4.  1	iface enp7s0
get 172. 16.  9.  1	iface vmnet1
get 172. 16.181.  1	iface vmnet8
get 192.168.  3.  2	iface enx000ec6aa5f42
-----------------------------------------------------
   |        Network       |   Nexthop Addr  | Metric 
-----------------------------------------------------
 C | 192.168.  4.  1 / 24 |   0.  0.  0.  0 |    1
 C |   3.  0.  0.  0 / 24 |   0.  0.  0.  0 |   16
 C | 172. 16.  9.  1 / 24 |   0.  0.  0.  0 |    1
 C | 172. 16.181.  1 / 24 |   0.  0.  0.  0 |    1
 C | 192.168.  3.  2 / 24 |   0.  0.  0.  0 |    1
 R | 192.168.  1.  0 / 24 | 192.168.  3.  1 |    2
 R | 192.168.198.  0 / 24 | 192.168.  3.  1 |    3
 R | 192.168. 10.  0 / 24 | 192.168.  3.  1 |    3
-----------------------------------------------------
--- 192.168.  1.  0/24 192.168.  3.  1
--- 192.168.198.  0/24 192.168.  3.  1
--- 192.168. 10.  0/24 192.168.  3.  1
send to 192.168.  4.  1 succeed! packet len: 124
send to 172. 16.  9.  1 succeed! packet len: 124
send to 172. 16.181.  1 succeed! packet len: 124
send to 192.168.  3.  2 succeed! packet len: 64
--- 192.168.  1.  0/24 192.168.  3.  1
--- 192.168.198.  0/24 192.168.  3.  1
--- 192.168. 10.  0/24 192.168.  3.  1
receive len: 24	cmd: 1	ver: 2	from 192.168.4.2
send to 192.168.  4.  1 succeed! packet len: 144
--- 192.168.  1.  0/24 192.168.  3.  1
--- 192.168.198.  0/24 192.168.  3.  1
--- 192.168. 10.  0/24 192.168.  3.  1
get 192.168.  4.  1	iface enp7s0
get 172. 16.  9.  1	iface vmnet1
get 172. 16.181.  1	iface vmnet8
get 192.168.  3.  2	iface enx000ec6aa5f42

For exp4, just type mv lookuproute_simple.cpp.bak lookuproute.cpp; make -j and run sudo ./main.

由于为了后续性能,把输出的部分给注释掉了。

Additional exp

编译:直接 make -j

就写了个哈希边表,每次从/32查到/1,看看有没有对应的路由表项

可以理解为我开了32个数组,但是存的时候存得紧凑了点

该算法代码位于 lookuproute.cpp 中,不到30行(后面常数优化了一波,循环展开,做到差不多和4位trie一样快了,代码翻了一倍)

事实上是/32到/13存hash,/12到/1直接数组存下来

如果要单独测试性能的话:

mv test.cpp.bak test.cpp
g++ test.cpp lookuproute.cpp -oa -O2
# insert 1000 and query 10^7
time ./a 10000000

本机i7-8750H差不多0.27s,找了个i7-7700HQ大概0.45s

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].