New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More โ†’
Socket
Sign inDemoInstall
Socket

github.com/kumkeehyun/ttcp

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/kumkeehyun/ttcp

  • v0.0.0-20220413142050-10788eaaa690
  • Source
  • Go
  • Socket score

Version published
Created
Source

ttcp

cilium/ebpf/examples/tcprtt์—๋‹ค๊ฐ€ BPF_MAP_TYPE_HASH๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ srcAddr์„ ํ•„ํ„ฐ๋งํ•˜๋„๋ก ์ˆ˜์ •ํ•จ. ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—๋Š” Http API๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ํ•„ํ„ฐ๋งํ•  IP๋ฅผ ์ถ”๊ฐ€, ์‚ญ์ œ, ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ.

Getting Startd

๋„์ปค๋งŒ ์ค€๋น„ํ•˜๋ฉด ๋จ. Clone github.com/KumKeeHyun/ttcp

# 1. ebpf-builder๋ฅผ ํ†ตํ•ด bpf ํ”„๋กœ๊ทธ๋žจ ์ปดํŒŒ์ผ. bpf_bpfel.go, bpf_bpfel.o ์ƒ์„ฑ.
# 2. ๋„์ปค ์ด๋ฏธ์ง€ ๋นŒ๋“œ. kbzjung359/ttcp ์ด๋ฏธ์ง€ ์ƒ์„ฑ
make build

Running ttcp

Docker hub์— kbzjugn359/ttcp:v0.0.0 ์ด๋ฏธ์ง€๋ฅผ ์˜ฌ๋ ค๋‘ . ๋”ฐ๋กœ ๋นŒ๋“œํ•˜์ง€ ์•Š์•„๋„ ๋จ.

sudo docker run --rm --privileged \
	-p 8090:8090 \
	kbzjugn359/ttcp:v0.0.0`

Http API๋ฅผ ํ†ตํ•ด ํ•„ํ„ฐ๋งํ•  IP ํ…Œ์ด๋ธ”(BPF_MAP) ์กฐ์ž‘.

# ํ…Œ์ด๋ธ”์— ๋“ฑ๋ก๋œ IP ์กฐํšŒ
curl -L http://localhost:8090 -XGET

# ํ…Œ์ด๋ธ”์— ํ•„ํ„ฐ๋งํ•  ์ƒˆ๋กœ์šด IP ์ถ”๊ฐ€
curl -L http://localhost:8090 -XPUT -d 192.168.0.1

# ํ…Œ์ด๋ธ”์— ํ•„ํ„ฐ๋งํ•˜์ง€ ์•Š์„ IP ์ œ๊ฑฐ
curl -L http://localhost:8090 -XDELETE -d 192.168.0.1

example

ํ˜ธ์ŠคํŠธ์˜ network namespace์™€ ๋„์ปค ์ปจํ…Œ์ด๋„ˆ์˜ network namespace์—์„œ ๊ฐ๊ฐ http ์š”์ฒญ์„ ๋ณด๋‚ด๋ณด๋Š” ์‹œ๋‚˜๋ฆฌ์˜ค์ž„.

ttcp ์ปจํ…Œ์ด๋„ˆ๋Š” 172.17.0.2์—์„œ ์‹คํ–‰๋˜๊ณ  ์žˆ์Œ. ์›๋ž˜๋Œ€๋กœ๋ผ๋ฉด ๋‹ค๋ฅธ ๋„ค์ž„์ŠคํŽ˜์ด์Šค์˜ TCP ์š”์ฒญ์„ ๋ณด์ง€ ๋ชปํ•˜์ง€๋งŒ BPF๋ฅผ ํ†ตํ•ด ์ปค๋„์—์„œ TCP ์š”์ฒญ์„ ๊ฐ์‹œํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํ˜ธ์ŠคํŠธ์˜ 10.178.0.5 ์š”์ฒญ๋„ ๊ฐ์‹œํ•  ์ˆ˜ ์žˆ์Œ. ๋ฌผ๋ก  ๋‹ค๋ฅธ ์ปจํ…Œ์ด๋„ˆ์ธ 172.17.0.3 ์š”์ฒญ๋„ ๊ฐ์‹œํ•  ์ˆ˜ ์žˆ์Œ.

  1. ttcp ์‹คํ–‰
  2. Src Addr IP ํ•„ํ„ฐ๋ง ํ…Œ์ด๋ธ”์— ํ˜ธ์ŠคํŠธ IP์ธ 10.178.0.5 ์ถ”๊ฐ€
  3. ํ˜ธ์ŠคํŠธ์—์„œ curl ์š”์ฒญ -> ttcp์— ์š”์ฒญ์ด ์ฐํž˜
  4. ํ…Œ์ด๋ธ”์— ํ˜ธ์ŠคํŠธ IP ์ œ๊ฑฐ
  5. ํ˜ธ์ŠคํŠธ์—์„œ curl ์š”์ฒญ -> ttcp์—์„œ ๋”์ด์ƒ ํ˜ธ์ŠคํŠธ์˜ IP์˜ ์š”์ฒญ์„ ์ถ”์ ํ•˜์ง€ ์•Š์Œ
  6. ์ปจํ…Œ์ด๋„ˆ์—์„œ curl ์š”์ฒญ -> ttcp์—์„œ ์ปจํ…Œ์ด๋„ˆ์˜ IP์˜ ์š”์ฒญ์„ ์ถ”์ ํ•˜์ง€ ์•Š์Œ
  7. ํ…Œ์ด๋ธ”์— ์ปจํ…Œ์ด๋„ˆ IP ์ถ”๊ฐ€
  8. ์ปจํ…Œ์ด๋„ˆ์—์„œ curl ์š”์ฒญ -> tcp์— ์š”์ฒญ์ด ์ฐํž˜
                                                            |   2022/04/09 06:05:35 Src addr        Port   -> Dest addr       Port   RTT   
$ curl -L http://localhost:8090 -XPUT -d 10.178.0.5         |                  
$ curl google.com                                           |   2022/04/09 06:06:02 10.178.0.5      47090  -> 172.217.161.206 80     0     
$ curl -L http://localhost:8090 -XDELETE -d 10.178.0.5      |
$ curl google.com                                           |   nothing
$ sudo docker run --rm alpine/curl:3.14 google.com          |   nothing
$ curl -L http://localhost:8090 -XPUT -d 172.17.0.3         |
$ sudo docker run --rm alpine/curl:3.14 google.com          |   2022/04/09 06:10:24 172.17.0.3      40878  -> 172.217.25.174  80     0

FAQs

Package last updated on 13 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc