2010년 12월 20일 월요일

트래픽 흐름에 따라 사운드를 출력해 보자!

재미있는 유틸리티 하나를 소개해 본다. 일전에 트래픽 흐름 상태를 키보드의 LED 표시를 통해
깜빡 거리는 것을 소개한적 있다. 이와 같이 조금은 재미있는 형태의 프로그램이라 보면 된다.

키보드 LED 정보를 이용한 블로그 글은 다음을 참고한다.


오늘 소개하고자 하는것은, 트래픽 흐름의 형태에 따라 사운드를 출력시키는 것이다. 트래픽 종류에 따라
지정된 사운드가 스피커를 통해 흘러나온다. 이름하여 Tcpsound 이다. 파일은 아래 URL 에서 받을 수 있다.

http://www.ioplex.com/~miallen/tcpsound/

컴파일 하기 위해서는 libsdl 와 libmba 라이브러리가 필요하다. libmba 는 아래 경로를 참고한다.


APT 패키지 사용자는 sdl 패키지를 아래와 같이 설치할 수 있다.

# apt-cache search libsdl-sound
libsdl-sound1.2-dev - Development files for SDL_sound
libsdl-sound1.2 - Decoder of several sound file formats for SDL
# apt-get install libsdl-sound1.2-dev

이후 다운받은 tcpsound 패키지의 압축을 풀고 'make' 를 해 주면 된다.
컴파일 된 tcpsound 를 실행하면 아래와 같은 메시지가 발생된다.

$ ./tcpsound
searchpath: /usr/share/sounds:/usr/local/share/sounds
proto  src   dst wav path
src/sound.c:64:path_search: No such file or directory: generic.wav
  src/sound.c:154:sound_load_cfg: Rule will be ignored.
src/sound.c:64:path_search: No such file or directory: sonar.wav
  src/sound.c:154:sound_load_cfg: Rule will be ignored.
src/sound.c:64:path_search: No such file or directory: warning.wav
  src/sound.c:154:sound_load_cfg: Rule will be ignored.
src/sound.c:64:path_search: No such file or directory: pop.wav
  src/sound.c:154:sound_load_cfg: Rule will be ignored.
src/sound.c:64:path_search: No such file or directory: info.wav
  src/sound.c:154:sound_load_cfg: Rule will be ignored.
src/sound.c:64:path_search: No such file or directory: cuckoo.wav
  src/sound.c:154:sound_load_cfg: Rule will be ignored.

사운드 파일을 찾지 못해서 발생하는 것이다. 이럴 경우 따로 파일의 경로를 지정해 주거나 또는, make install 하게 되면 적절한 위치에 다 복사가 된다.

# make install
./mktool -i -m 0755 tcpsound /usr/local/bin
./mktool -i wavs/*.wav /usr/local/share/sounds
./mktool -i docs/man/*.1.gz /usr/local/man/man1

installation successful

tcpsound 를 실행하면 각 프로토콜 또는 포트번호 별로 지정된 사운드가 있는 것을 알 수 있다.

# tcpsound
searchpath: /usr/share/sounds:/usr/local/share/sounds
proto  src   dst wav path
ARP      0     0 /usr/local/share/sounds/generic.wav
ICMP     0     0 /usr/local/share/sounds/sonar.wav
IP      53    53 /usr/local/share/sounds/warning.wav
IP       0    80 /usr/local/share/sounds/pop.wav
IP      80     0 /usr/local/share/sounds/info.wav
IP     137   137 /usr/local/share/sounds/cuckoo.wav
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
02:55:06.019559 IP 204.152.191.39.80 > 192.168.15.11.38248: . 2697887135:2697888583(1448) ack 4005699112 win 88 <nop,nop,timestamp 1513910257 322740>
02:55:06.044274 IP 204.152.191.39.80 > 192.168.15.11.38248: . 1448:2896(1448) ack 1 win 88 <nop,nop,timestamp 1513910257 322740>

실행되면 스피커에서 뽁,뽀,뽁 과 같은 사운드가 발생되는 들을 수 있다. 이외 -r 옵션을 이용하면
원격지로 로그인하여 실행도 가능하다. 원격지 로그인은 SSH 접속으로 이루어진다.

이 tcpsound 를 보면 그냥 단순히 재미있는 프로그램이기도 하지만, 특별한 목적으로 만들어 사용하는 것도
나름 의미가 있을것 같다. 특정한 포트를 임의의 사운드 파일로 지정하여,
트래픽이 발생될 경우 알람음 형태로 이용이 가능할 수도 있다. 평소에 접근이 이루어지지 않는 포트인데
외부에서 접근이 이뤄지면 음성으로 알려준다면, 나름 좋은 아이디어 아닐까.
특히나 관제 및 서비스 운영 팀 같은데서는 유용하게 이용될 수도 있을것 같다.

참고로, tcpdump 를 기본으로 이용하므로 tcpdump 가 설치되어 있어야 한다.


댓글 1개:

  1. ㅋㅋㅋㅋㅋ 재밌는프로그램이네요^^

    어쩌면 사운드의 주파수를 이용해서 다양한 분석도 할수 있겠네요 ㅎㅎ

    답글삭제