검색어 mqtt에 대한 글을 날짜를 기준으로 정렬하여 표시합니다. 관련순 정렬 모든 글 표시
검색어 mqtt에 대한 글을 날짜를 기준으로 정렬하여 표시합니다. 관련순 정렬 모든 글 표시

2018년 4월 18일 수요일

Socket.io, MQTT 관련 대충 정리

아 짜증나.. 쓰던글 다 날라감..
대충 다시 씀.

web server에서 mobile app으로 push를 보내야할 필요가 있어 이것 저것 찾아봄.

Push를 구현하기 위해서는 다양한 기술들이 있고 다양하게 쓰이는 듯 함.
Long polling, Web socket, Socket.IO, Server side event, messaging queue 등..

notification를 위해 요구되는 사항들로는
- Web server에서의 mobile app으로 push
- 100자 미만의 메세지 포함 가능
- 수초 정도의 delay 상관없음.
- client는 c/c++ 기반 mobile app


----------------------------------------------------------------------------------
Socket.io
----------------------------------------------------------------------------------

Socket.io 관련해서 아주 좋은 글이 여기 있었음.

실시간 서비스 경험기(배달운영시스템), 우아한형제들 기술 블로그
: http://woowabros.github.io/woowabros/2017/09/12/realtime-service.html

너무 자세히 삽질하셨던 내용이 정리되어 이대로 따라가기만 해도 좋을 듯.
c/c++ 기반의 mobile app으로 server로 접속해야 하므로 client는 Socket.IO C++ client를 사용함.

Socket.IO C++ Client
: https://github.com/socketio/socket.io-client-cpp

일단 socket.io 서버에 접속하는 client는 c/c++ 기반의 app이므로
위 Socket.IO C++ Client를 사용해서 테스트 앱을 빌드 했음.

위 library는 Boost library를 사용하므로 windows에서 빌드해서 설치했음.
빌드하는데 시간이 상당히 소요되며 최신 boost library를 사용할 경우 일부 수정이 필요함.
하지만 mobile platform이 boost library를 가지고 있다면 빌드해서 사용할 필요는 없겠지만 필요하다면 boost.asio 및 관련 header와 library들을 추출해서 사용해야 할 듯 하다.

언급한 boost 컴파일을 위해 수정한 부분을 적어 두었는데.. 날라가서 기억을 못하겠음.


그리고 Socket.io 사용 시 connection이 어떻게 될지 궁금해서 일단 테스트를 해봄.
Node.js + Socket.IO C++ Client 로 laptop(i5-6200U@2.30GHz, 8G)에서 naive하게 테스트를 해봄.

Node.js에서는 connection & ping 수신 log만 찍고
Socket.IO C++ client에서는 300개 connection을 만들고 10초 마다 10자리 내의 문자열과 함께 ping을 보냄.

이상하게 client에서 300개 이상을 보내게 되면 boost에서 exception이 발생해서 테스트 앱에서 300개 정도로 connection을 제한하고 test app을 하나씩 증가시키며 테스트 해봄.

laptop의 resource 한계로 인해 대략 6300개 정도의 connection(client 21개)이 연결되고 ping을 받는 것을 확인하긴 하였지만 뭐 거의 의미 없는 테스트니.. 그냥 참고만.

글구 실제 6300개 connection과 ping을 받는 node.js 서버의 경우 동작에 무리가 있어 제대로 동작한다고는 보기는 어려웠음. client들을 종료할 때 disconnection callback 처리도 거의 1분 정도 소요 되었음.. 하지만 실제 cloud 기반의 server들을 붙여서 테스트 해야 할 것 같음.

그래도 Connection을 지속적으로 유지하며 disconnect 되었을 때 다시 연결한다는 점에서는 적절한 notification을 위해 사용하기에는 괜찮아 보임.
다만 socket.IO가 boost.asio를 사용하고 raw socket보다는 사용하기 무겁다는 것과 connection 수가 단점이 되지 않을까 생각됨.


---------------------------------------------------------------------------------
MQTT
---------------------------------------------------------------------------------


MQTT 관련 글들.

MQTT 설명
https://www.joinc.co.kr/w/man/12/MQTT/Tutorial
http://charlie0301.blogspot.kr/search?q=mqtt


MQTT 적용을 통한 중계시스템 개선, 우아한형제들 기술 블로그
: http://woowabros.github.io/experience/2017/08/11/ost_mqtt_broker.html

MQTT 프로토콜 분석과 테스트
http://www.hardcopyworld.com/ngine/aduino/index.php/archives/2562

mosquitto를 windows 설치하기 위해서는 좀 까다롭다.
아래 블로그 참조.
: http://blog.naver.com/PostView.nhn?blogId=cjc07&logNo=220441942108&parentCategoryNo=&categoryNo=&viewDate=&isShowPopularPosts=false&from=postView

단 openssl 설치 시 좀 예전 버전을 설치해야 함.
처음에 Win32OpenSSL_Light-1_1_0h를 설치하였으나 원하는 파일들이 없어서 Win32OpenSSL_Light-1_0_2o를 설치하여 찾음.


Eclipse Paho MQTT C client
: https://github.com/hallower/paho.mqtt.c

마찬가지 이유로 c/c++ 기반의 app이므로 Paho MQTT C client를 사용함.
빌드를 하다보니 openssl을 사용해야 하는것 같은데 그냥 환경 설정하기 귀찮아서 주석처리하여 빌드함.

근데 Paho MQTT C client를 사용해서 복수의 connection을 생성하여 connect할 때마다 기존 것들에서 connection lost가 발생함. connection, connection option들을 모두 각각 사용하여 각 connection들이 상관이 없을 텐데.
sync sample, async sample들을 각각 테스트 해봐도 2개 이상 connection을 생성하면 앞의 connection이 connection lost 발생.. 원인을 모르겠음. 이것저것 바꿔보고 했지만 소용이 없었음.

그래서 Mosquitto와 함께 빌드된 mosquitto_sub를 windows shell script로 여러개를 실행하도록 하였는데 600개 정도를 만들다가 mosquitto server가 죽어버린다.
windows에서 connection 제약이 1024개 정도 된다고 하던데 그 이유는 아닌것 같고 심지어 subscribe 하는 간격을 1초 마다 시도해도 600개를 넘어서지 못한다.

하지만 600개를 만들면서 cpu 사용이나 메모리는 상당히 낮은 편이다. subscribe client의 footprint가 작아서 그런지 모르겠지만..

찾다 보니 mosquitto에서 1024개 이상 센싱 데이터를 처리할 경우 에러가 발생했다는 논문 문구가 있었음.
출처 : http://www.engineeringcode.net/1045


혹시나 몰라 test.mosquitto.org를 대상으로 subscribe를 시도해봤는데 하나의 IP에서 10개 정도의 connection을 제한하는 것처럼 보인다. 11개 이상을 subscribe할 경우 서버에서 연결을 거부한다.


그래서 mosca로 테스트 해봄.
: https://github.com/mcollina/mosca

mosca로 테스트 해보니 5300개 정도 subscribe하니 cpu, memory가 거의 full이 되어 더이상 subscribe, publish가 어렵다. 그래도 mosquitto보다는 훨씬 잘 동작하는 것 같음.
그리고 mosca를 standalone broker로 실행하여 테스트 한것이고 node.js와 함께 실행한 것은 아님.

MQTT는 별도의 broker를 준비해야한다는 점이 좀 단점이지만 pub-sub 구조의 형태 인점이 notification을 전달하기 위해 사용하기는 편리할것으로 보임.



그리고 이건 혹시나 나중에 사용할 지 몰라 남겨둠.

@echo off
echo ==============================
echo subscribe test
echo ==============================
echo.

for /L %%i in (1,1,1000) do call :sss %%i

pause>nul

:sss
  echo %~1
  START /B mosquitto_sub.exe -t csk
  
  set /a sum=%~1%%10
  if %sum% equ 0 (
echo "sleep"
ping 127.0.0.1 -n 2 > nul
  )


2014년 7월 26일 토요일

공개키 암호 방식, SSL/TLS, Open SSL

[고대? 암호화 방식들]

http://en.wikipedia.org/wiki/Scytale
http://en.wikipedia.org/wiki/Caesar_cipher





[공개키 암호 방식 설명 link 모음]
http://charlie0301.blogspot.kr/2014/07/link-public-key-infrastructure.html

: 디지털 서명 & 메시지 암호화
http://technet.microsoft.com/ko-kr/library/aa998077

* 공개키, 개인키 암호화 방식을 통해 메세지가 송신자에게서 전달된 것임을 확인하는 디지털 서명과 메세지를 암호화, 복호화 하기 위해 서로간 세션키를 전달하는 것이 기본 내용.

* 공개키 암호화/복호화 시 계산의 복잡성으로 다소 큰 비용이 발생하여
   임시 세션키를 사용하여 메세지를 암호화 하고 세션키를 공개키로 암호화 하여 비용 절감.



[X.509]
http://en.wikipedia.org/wiki/X.509
Public Key Infrastructure (PKI)와 Privilege Management Infrastructure (PMI)의 ITU의 표준으로 public key certificates에 대해서도 언급하고 있음.

* 즉 인증서는 공개키와 키의 정보를 함께 포함하고 있음.

$ openssl x509 -in freesoft-certificate.pem -noout -text
Certificate:
   Data:
       Version: 1 (0x0)
       Serial Number: 7829 (0x1e95)
       Signature Algorithm: md5WithRSAEncryption
       Issuer: C=ZA, ST=Western Cape, L=Cape Town, O=Thawte Consulting cc,
               OU=Certification Services Division,
               CN=Thawte Server CA/emailAddress=server-certs@thawte.com
       Validity   
           Not Before: Jul  9 16:04:02 1998 GMT
           Not After : Jul  9 16:04:02 1999 GMT
       Subject: C=US, ST=Maryland, L=Pasadena, O=Brent Baccala,
                OU=FreeSoft, CN=www.freesoft.org/emailAddress=baccala@freesoft.org
       Subject Public Key Info:
           Public Key Algorithm: rsaEncryption
           RSA Public Key: (1024 bit)
               Modulus (1024 bit):
                   00:b4:31:98:0a:c4:bc:62:c1:88:aa:dc:b0:c8:bb:
                   33:35:19:d5:0c:64:b9:3d:41:b2:96:fc:f3:31:e1:
                   66:36:d0:8e:56:12:44:ba:75:eb:e8:1c:9c:5b:66:
                   70:33:52:14:c9:ec:4f:91:51:70:39:de:53:85:17:
                   16:94:6e:ee:f4:d5:6f:d5:ca:b3:47:5e:1b:0c:7b:
                   c5:cc:2b:6b:c1:90:c3:16:31:0d:bf:7a:c7:47:77:
                   8f:a0:21:c7:4c:d0:16:65:00:c1:0f:d7:b8:80:e3:
                   d2:75:6b:c1:ea:9e:5c:5c:ea:7d:c1:a1:10:bc:b8:
                   e8:35:1c:9e:27:52:7e:41:8f
               Exponent: 65537 (0x10001)
   Signature Algorithm: md5WithRSAEncryption
       93:5f:8f:5f:c5:af:bf:0a:ab:a5:6d:fb:24:5f:b6:59:5d:9d:
       92:2e:4a:1b:8b:ac:7d:99:17:5d:cd:19:f6:ad:ef:63:2f:92:
       ab:2f:4b:cf:0a:13:90:ee:2c:0e:43:03:be:f6:ea:8e:9c:67:
       d0:a2:40:03:f7:ef:6a:15:09:79:a9:46:ed:b7:16:1b:41:72:
       0d:19:aa:ad:dd:9a:df:ab:97:50:65:f5:5e:85:a6:ef:19:d1:
       5a:de:9d:ea:63:cd:cb:cc:6d:5d:01:85:b5:6d:c8:f3:d9:f7:
       8f:0e:fc:ba:1f:34:e9:96:6e:6c:cf:f2:ef:9b:bf:de:b5:22:
       68:9f

http://technet.microsoft.com/en-us/library/cc737264(v=ws.10).aspx





[Secure Scokets Layer(SSL)/Transport Layer Security(TLS)]

http://en.wikipedia.org/wiki/Transport_Layer_Security
http://ko.wikipedia.org/wiki/%ED%8A%B8%EB%9E%9C%EC%8A%A4%ED%8F%AC%ED%8A%B8_%EB%A0%88%EC%9D%B4%EC%96%B4_%EB%B3%B4%EC%95%88

인터넷 상에서 server, client간 communication 보안을 위해 설계된 protocol으로
암호화된 연결 및 데이터 무결성을 확보해 줌.

SSL specification은 1994, 1995, 1996년에 Nescape Communications에 의해 개발되었고 TLS는 IETF(Internet Engineering Task Force)에 의해 SSL을 기반하여 정의 됨.

: Authentication flow
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0CD8QFjAD&url=http%3A%2F%2Fmarcof.tistory.com%2Fattachment%2Fcfile25.uf%40144CA5344DDE672A3331AD.ppt&ei=Bq_DU6HINcLClAW6hoGoDg&usg=AFQjCNFQ3mOybIaplRiShYaYpWdqogYg-A&sig2=Ghmtl1v8oEE-rEk8hlrZkw&bvm=bv.70810081,d.dGI


- 앞장 1,2번을 통해 server, client 서로 random data를 주고 받음
- 서버는 4번을 통해 자신이 가지고 있는 인증서를 전달(CA의 개인키로 암호화 된)
 : client는 일반적으로 CA의 공개키를 가지고 있다.
- Client는 Server, client random data를 사용하여 Master Secret을 생성
- 생성된 Master Secret를 서버 공개키를 사용하여 암호화 후 전달(8번)
- Server, Client는 Master Secret를 사용하여 임시키(Session Key)를 생성함.
- 이후 Server, Client는 Session Key를 사용하여 - 데이터를 암호화/복호화 함. (대칭키 암호화 방식)

* client는 일반적인 서버를 인증하는 CA의 공개키(public key)를 가지고 있고, 서버는 CA로 부터 CA의 개인키(private key)로 암호화된 서버의 인증서를 가지고 있음.
 => 즉 client는 가지고 있는 CA의 공개키로 서버로 부터 받은 인증서를 복호화 하여 서버를 검증 함.

* server, client는 random data를 서로 공유하고 server, client에서 사용할 임시키(Session key)를 만들기 위한 Master Secret를  client에서 생성하여 전달함.
 : random data기반하여 clent가 master secret를 생성하는 공식은 다른 자료 참고


[SSL 관련 참조 링크]

SSL과 인증서
http://opentutorials.org/course/228/4894

암호화 역사 (KISA)
http://seed.kisa.or.kr/iwt/ko/intro/EgovHistory.do



[OpenSSL]

OpenSSL (Wikipedia)
http://en.wikipedia.org/wiki/OpenSSL

OpenSSL 설치 및 사용
http://www.solanara.net/solanara/openssl

OpenSSL 인증서 생성
http://www.embedded101.com/Blogs/PaoloPatierno/tabid/106/entryid/366/MQTT-over-SSL-TLS-with-the-M2Mqtt-library-and-the-Mosquitto-broker.aspx
http://golmong.tistory.com/112


- SSL/TLS protocol을 open-source 기반으로 구현한 software library
- Eric Andrew Young, Tim Hudson이 만든 SSLeay library를 기반으로 1998년 시작되었음.
- License : Dual licensed (Apache License 1.0 + BSD License)

- 지원하는 알고리즘들
 . Ciphers
  > AES, Blowfish, Camellia, SEED, CAST-128, DES, IDEA, RC2, RC4, RC5, Triple DES, GOST 28147-89[7]
 . Cryptographic hash functions
  > MD5, MD4, MD2, SHA-1, SHA-2, RIPEMD-160, MDC-2, GOST R 34.11-94
 . Public-key cryptography
  > RSA, DSA, Diffie–Hellman key exchange, Elliptic curve, GOST R 34.10-2001

- 그외
. libReSSL : Heartbleed 이슈로 OpenBSD 쪽에서 OpenSsl 1.0.1g에서 fork 하여 개발, 불필요 부분 대거 삭제
. BoringSSL : 2014년 Google이 OpenSSL와 libReSSL 개발자와 협력하기 위해 OpenSSL을 fork함.

2014년 7월 14일 월요일

Tizen상에서 MQTT client 컴파일 하기 (with OpenSSL library)

Tizen 상에서 MQTT client들 중에서 C/C++ API들을 제공하는 solution 들을 테스트 하려 함.

대표적인 것은 Eclipse Paho와 libmosquitto 이며  (http://mqtt.org/wiki/doku.php/libraries)
대략 봤을 때는 두 solution들의 feature는 거의 유사하지만
코드 상으로는 libmosquitto가 다소 simple한 것 같아보임
(libmosquitto LOC 대략 7264, Paho LOC 대략 18395)..
(하지만 Paho도 simple한 것은 사실, 하지만 워낙 MQTT protocol 자체가 simple 하니...)

MQTT client를 테스트 해보려면
. 위 client library를 컴파일 해야 하고
. library 컴파일에 필요한 OpenSSL library를 컴파일 해야 하고
. application을 만들어 sample code를 포팅해야 함.



[MQTT client library compile]

1. Paho, libmosquitto를 tizen shared library로 컴파일 하기 위해서는
tizen sdk > File > New > Tizen Native Project > Library > Shared Library 프로젝트를 생성한다.


2. library 파일들을 inc, src 폴더로 복사한다.
 . Paho : sample 을 제외한 library 파일들을 복사
 . libmosquitto : python, js 파일들을 제외하고 복사

3. project setting
 . SSL/TLS 지원을 위해 preprocessor, include path 설정
  : Project properties > C/C++ Build > Settings > C++ Compiler/C Compiler > Preprocessor/Symbols
    >  Paho project : "OPEN_SSL", libmosquitto : "WITH_TLS" 설정
  : Project properties > C/C++ Build > Settings > C++ Compiler/C Compiler > Includes 에 OpenSSL source의 include path 설정 (아래)



[OpenSSL library compile]

Paho, libmosquitto에서 SSL/TLS 설정을 사용하고자 할 경우
Tizen에서 돌아가야할 OpenSSL의 libssl.so, libcrypto.so 가 필요함.
Tizen platform내의 OpenSSL shared library를 사용할 수 있겠지만
방법을 모르는 관계로 so를 만들어서 app과 함께 deploy해서 사용할 생각임.

일단 OpenSSL 최신버전을 다운 받을 수 있겠지만 Tizen용으로 빌드를 해야 하기에 git repository에 있는 것을 다운받아 컴파일 하자.
참고
 - Tizen GBS : https://source.tizen.org/ko/documentation/reference/git-build-system
 - GBS 빌드 방법 (by 서주영님)
    . source code download : http://seoz.egloos.com/3896390
    . GBS 설정 : http://seoz.egloos.com/3900549
 - cocos2d-x 포팅 후기 (by 이재홍님) : http://pyrasis.com/cocos2d-x/2013/05/19/cocos2d-x-tizen-port-post-mortem/


1. gerrit 등록 및 GBS 설정
 . gbs.conf는 는 tizen 홈피에 있는 것을 받아서 계정 정보(id, password) 추가
 . buildconf 주석'#' 처리
 . 서주영님 게시물 GBS 설정 3번 항목에 따라 URL 수정

2. OpenSSL repository clone
 . 일단 framework/security/openssl 를 다운 받았음... 사실 OpenSSL repository는 framework, platform 두개가 있는데 차이를 모르겠고 platform은 dependency가 있어 그냥 framework을 다운 받음.

3. 빌드 (gbs build -A armv7l)

빌드된 결과물은 rpm으로 나오겠지만 일단 so만 필요하므로
.gbs.conf 의 buildroot 경로에서 빌드 결과물 중 libssl.so, libcrypto.so 를
밑의 폴더에서  tizen app의 lib 폴더로 복사

~/GBS-ROOT-profile.tizen/local/BUILD-ROOTS/scratch.armv7l.0/home/abuild/rpmbuild/BUILD/openssl-1.0.0f

* 빌드 option 참고 (위쪽 서주영님 포스팅 발췌)

만약 빌드가 잘 안 되거나 GBS 설정 파일의 url을 바꾼 경우라면 아래와 같이 --clean 옵션을 이용하여 빌드를 하시기 바랍니다.

gbs build -A i586 --clean

만약 다운로드 받은 타이젠 소스코드를 수정하셨다면 아래와 같이 --include-all 옵션을 주어야 합니다.
GBS는 git에 커밋(commit)이 된 소스코드를 이용하여 빌드를 하기 때문에 소스코드를 수정했다면 git에 커밋을 해야 GBS로 빌드할 수 있습니다.
만약 커밋을 하지 않고 소스코드를 빌드하고 싶다면 --include-all 옵션을 주어야 합니다.

gbs build -A i586 --include-all

빌드 시 아키텍처를 선택하지 않았다면 기본적으로 i586으로 빌드가 되며 arm으로 빌드를 하려면 -A 옵션과 함께 armv7l을 인자로 주어야 합니다. (마지막의 l은 L의 소문자입니다.)

$ gbs build -A armv7l


[MQTT sample client app compile & run]

일단 MQTT client sample application을 만들어야 하므로
간단한 Tizen Form-based Application project를 만들어서
client 소스코드를 복사한다.

Paho의 경우 src/samples 내 pubsync.c, MQTTAsync_publish.c, MQTTAsync_subscribe.c 를 사용하고 mosquitto는 소스코드의 client 폴더 내 pub, sub sample를 사용

. 확장자를 cpp로 바꾸고
. main 함수의 이름을 바꾸고 header를 만들어 expose (단 naming mangling 방지를 위해 extern C 사용)
. sample들이 loop을 사용하므로 Tizen thread를 만들어 별도 thread에서 돌아가게 해야 함.
. application event handler에서 thread를 생성해서 실행하도록 코드 작성


그리고 application에서 위에서 만든 libpaho.so, libmosquitto.so 를 사용해야 하므로
application project에서 library project를 reference 하고 include path, library path & library 설정이 필요함 이 부분은 아래 링크에서 잘 설명 되어 있음.

- 오픈소스를 활용한 Tizen 용 web server 포팅 : http://tizenschools.com/?p=40
 . library들이 함께 사용하는 library들 - libdl, libssl, libcrypto

- 또한 SSL/TLS 를 사용하고자 할 경우 CA의 인증서가 필요하므로 이를 App과 함께 배포하고자 shared/data에 복사하고 mosquitto_tls_set, mosquitto_tls_opts_set 설정 함.
 * app과 자동배포가 안되는지 app에서 shared/data에 인증서가 없다. 그냥 public space에 인증서를 sdb pull로 밀어 넣고 해당 path로 접근하게 함.

2014년 6월 25일 수요일

Messaging 관련 사항들(history, protocol, mobile messenger APIs) 정리

http://en.wikipedia.org/wiki/Instant_messaging

wikipedia에서는 여러 내용이 있고 간략한 history는 아래 그림에서 볼 수 있음.

http://www.technologyblogged.com/round-ups/the-beginning-middle-present-and-future-of-instant-messaging
History of Instant Messaging Timeline - Technology Blogged Exclusive.

[Standards for Instant Messaging]


여러 messenger이 난립했던 관계로 아래와 같은 표준화 노력이 있었다고 함.



[XMPP : Extensible Messaging and Presence Protocol]

: http://en.wikipedia.org/wiki/Extensible_Messaging_and_Presence_Protocol
http://charlie0301.blogspot.kr/2013/04/xmpp-smack-openfire.html

open standard로서 좀 사용되는 protocol이며 개발입장에서는 관련 open source server/client가 꽤 존재함.

- XMPP based chat clients
 : http://en.wikipedia.org/wiki/List_of_XMPP_client_software#XMPP-related_features

ClientTransports[a]File transfer
(XEP-0096)[b]
Multi-user chatJingleEncryption
File transfer[b]Voice callsVideo callsOpenPGPOTR
AdiumYesYesYesNoNoNoNo[42]Yes
BitlBeeYesYesYesNoNoNoNoYes
Bombus[43]NoYesYesNoNoNoNoNo
climmNoYesNoNoNoNoNoYes
Coccinella[44]YesYesYesNoYesNoNoNo
Empathy,[45] KDE Telepathy[c]NoYesYesYesYesYesNoYes/No[d][e]
Gajim[46]YesYesYesYesYes/No[f]Yes/No[f]YesYes/No[f]
Google TalkNoNoNoYesPartial[g]Partial[g][h]NoNo
iCallYesYesNoYesYesYesNoYes
iChatNoYesPartial[i]NoNoNoNoNo
JitsiNoYesYesYesYesYesNoYes
KaduNoYesNoNoNoNoNoNo
KopeteYesYesYesNoNoNoYesYes
MCabber[47]NoNoYesYesNoNoYesYes
NimbuzzYesYesYesYesYesYesNoNo
Pidgin[48]YesYesYesNoYes/No[f]Yes/No[f]YesYes
PsiYesYesYesYesYesNoYesYes
Tkabber[49]YesYesYesNoNoNoYesYes
TrillianNoYesYes/No[j]NoNoNoNoYes/No[k]
  1. Jump up^ Transport support means the ability to set up transports. Once transport is set up, any client can use it to manage contacts and communicate with them.
  2. Jump up to:a b The difference between XEP-0096 (legacy) and XEP-0234 (Jingle) file transfer is that the latter works behind NAT (e.g., from home and corporate networks).
  3. Jump up^ Both Empathy and KDE Telepathy are based on Telepathy framework and share same properties in regard of XMPP features support.
  4. Jump up^ "Bug report - Empathy should support OTR encryption"Gnome Bugzilla. Retrieved 17 August 2013.
  5. Jump up^ "Bug 16891 - (OTR) Telepathy should support OTR encryption"freedesktop.org Bugzilla. Retrieved 25 May 2014.
  6. Jump up to:a b c d e Feature unavailable on Windows.
  7. Jump up to:a b Incompatible with XEPs.
  8. Jump up^ Feature unavailable in standalone client.
  9. Jump up^ Multi-user chats can be joined but not started
  10. Jump up^ Feature available on Windows only.
  11. Jump up^ Feature available on Windows only, not actively supported, not stable.

[Pidgin messenger]

https://pidgin.im/
- 여러 messaging service, protocol을 지원하는 Open source 기반 통합 메신저
- 기본적으로 아래에서 명시된 것을 제외하고도 3rd party 개발자 기반 plugin을 지원하여 타 chatting protocol, service들을 더 지원하고 있음.
- 그외 plugin들이 풍부하여 security, notifications, profile/status update, interface, account/logs 등의 부가 기능들을 제공하고 있음.

- 기본 지원 chat networks
  • AIM
  • Bonjour
  • Gadu-Gadu
  • Google Talk
  • Groupwise
  • ICQ
  • IRC
  • MSN
  • MXit
  • MySpaceIM
  • SILC
  • SIMPLE
  • Sametime
  • XMPP
  • Yahoo!
  • Zephyr
- 3rd party plugins
: Whatsapp, Facebook IM, Line과 NateOn도 지원하고 있음.

Protocol NameWebsiteShort Description
BelugaGoBeluga mobile group messaging
CampfireGoProtocol plugin for Basecamp's Campfire IM
Classic Battle.netGoBlizzard's gaming network: notably for StarCraft, Diablo II, and WarCraft III
F-ListGoF-List rollplaying community
Facebook IMGoFacebook social network
GammuGoSend SMS through your phone via usb/serial/bluetooth/irda
GroupMeGoGroupMe group messaging
Heroes of NewerthGoOnline video game
LINE by NaverGoMobile SMS replacement
Mail.ru Agent (mrim-prpl)GoRussian network
Mail.ru Agent (pidgin-mra)GoRussian network
MicroblogGoTwitter/Identica/Laconica updates
MightyTextGoSend SMS through your Android phone via MightyText
msn-pecanGoAlternative MSN access
msn-xmppGoAlternative MSN with xmpp/oauth access
MXitGoMXit IM
NateOnGo orGoKorean network (see More Info for details and Windows builds)
NetNexusGonetnexus.com's chatrooms
NetsoulGoFrench network
NingGoNing-based social networks
OkCupidGoOkCupid.com dating website
OmegleGoomegle.com's web-based random chat
QQ (libqq-pidgin)GoQQ protocol support
QQ (pidgin-lwqq)GoQQ protocol support (Based on WebQQ)
RediffbolGoIndian network
Skype IMGoOnly with Skypeclient
SIPEGoMicrosoft Office Communicator, Reuters Messaging
SmsWiFiGoWrite SMS over your Android smartphone in Pidgin
Steam IM (mobile)GoSteam Friends gaming network
Steam IM (native)GoSteam Friends gaming network
Tlen.plGoPolish network
TorChatGop2p instant messaging through Tor hidden service tunnels
ToxGosecure instant messaging via Tox protocol
Twitter ProtocolGoAccess Twitter (and status.net / identi.ca) feeds like chat rooms
WhatsAppGoWhatsApp IM protocol
WinMX Peer NetworkGoFile sharing network
XfireGoGaming network

- API : https://developer.pidgin.im/doxygen/
 . Pidgin GUI, core library들로 구성,  C API style

 . 구성
  : libpurple : Pdigin 프로그램의 core
  : Pidgin : GTK+ 기반 frontend이며 libpurple을 사용
  : Finch : Ncurses 기반 frontend이며 libgnt를 사용


- libpurple APIs
 : 다양한 모듈, 기능에 대해서 API들을 제공하고 있음. 아래는 주요 category들

 . account
 . buddy list
 . connection
 . conversation
 . file transfer
 . notify : 모든 notify(message, email, search result, user info, close 등)를 확인하는 API들
 . privacy : buddy list에서 사용자를 허용/거부 설정 API들
 . room list
 . plugin

- Plugin
 . C Plugin How-To : https://developer.pidgin.im/wiki/CHowTo

 . 아래는 기본적인 Pidgin C Plugin 예제
  : https://developer.pidgin.im/wiki/CHowTo/BasicPluginHowto

#define PURPLE_PLUGINS

#include <glib.h>

#include "notify.h"
#include "plugin.h"
#include "version.h"

static gboolean
plugin_load(PurplePlugin *plugin) {
    purple_notify_message(plugin, PURPLE_NOTIFY_MSG_INFO, "Hello World!",
                        "This is the Hello World! plugin :)", NULL, NULL, NULL);

    return TRUE;
}

static PurplePluginInfo info = {
    PURPLE_PLUGIN_MAGIC,
    PURPLE_MAJOR_VERSION,
    PURPLE_MINOR_VERSION,
    PURPLE_PLUGIN_STANDARD,
    NULL,
    0,
    NULL,
    PURPLE_PRIORITY_DEFAULT,

    "core-hello_world",
    "Hello World!",
    "1.1",

    "Hello World Plugin",          
    "Hello World Plugin",          
    "My Name <email@helloworld.tld>",                          
    "http://helloworld.tld",     
    
    plugin_load,                   
    NULL,                          
    NULL,                          
                                   
    NULL,                          
    NULL,                          
    NULL,                        
    NULL,                   
    NULL,                          
    NULL,                          
    NULL,                          
    NULL                           
};                               
    
static void                        
init_plugin(PurplePlugin *plugin)
{                                  
}

PURPLE_INIT_PLUGIN(hello_world, init_plugin, info)

기본적인 plugin data를 저장하는 strcuture는 다음과 같다.
기존적인 plugin 정보들과 load, unload, destroy callback과 extra info, action들에 대한 정보를 등록함.

00078 struct _PurplePluginInfo
00079 {
00080     unsigned int magic;
00081     unsigned int major_version;
00082     unsigned int minor_version;
00083     PurplePluginType type;
00084     char *ui_requirement;
00085     unsigned long flags;
00086     GList *dependencies;
00087     PurplePluginPriority priority;
00088
00089     char *id;
00090     char *name;
00091     char *version;
00092     char *summary;
00093     char *description;
00094     char *author;
00095     char *homepage;
00096
00101     gboolean (*load)(PurplePlugin *plugin);
00102     gboolean (*unload)(PurplePlugin *plugin);
00103     void (*destroy)(PurplePlugin *plugin);
00104
00105     void *ui_info;
00106     void *extra_info;
00107     PurplePluginUiInfo *prefs_info;
00122     GList *(*actions)(PurplePlugin *plugin, gpointer context);
00123
00124     void (*_purple_reserved1)(void);
00125     void (*_purple_reserved2)(void);
00126     void (*_purple_reserved3)(void);
00127     void (*_purple_reserved4)(void);
00128 };

그리고 init function과 plugin information을 아래 macro를 사용하여 등록

#define PURPLE_INIT_PLUGIN(pluginname,
initfunc,
plugininfo
)
Value:
gboolean _FUNC_NAME(pluginname)(void);\
    gboolean _FUNC_NAME(pluginname)(void) { \
        PurplePlugin *plugin = purple_plugin_new(TRUE, NULL); \
        plugin->info = &(plugininfo); \
        initfunc((plugin)); \
        purple_plugin_load((plugin)); \
        return purple_plugin_register(plugin); \
    }
Definition at line 222 of file plugin.h.
#define PURPLE_PLUGIN_ACTIONS(plugin,
context
)
Value:
(PURPLE_PLUGIN_HAS_ACTIONS(plugin)? \
    (plugin)->info->actions(plugin, context): NULL)
Definition at line 212 of file plugin.h.
자세한건 만들어 봐야지 알 수 있겠다. 다 보려면 한도 끝도 없겠고..

[MQTT (MQ Telemetry Transport) protocol]


http://bcho.tistory.com/864
: MQTT 간략 정리, 관련 solutoin도 정리

http://helloworld.naver.com/helloworld/1846
: 간략한 소개, 특징, FB app에서 사용됨을 알려줌.

http://public.dhe.ibm.com/software/kr/ik2012/mqtt.pdf
: MQTT 설명, 당위성과 자사 솔루션 소개

http://charlie0301.blogspot.kr/search?q=mqtt


MQTT software solutions
http://mqtt.org/wiki/doku.php/software

. paho - http://www.eclipse.org/paho/



[Mobile Messenger]


Global messenger market share
http://www.1mtb.com/whatsapp-leads-the-global-mobile-messenger-wars-with-44-pc-market-share/

WhatsApp Leads The Global Mobile Messenger Wars With 44 PC Market Share WhatsApp Leads The Global Smartphone Messenger Wars With 44 Percent Market Share


[WhatsApp mobile messenger]

- protocol : customized version of XMPP (http://en.wikipedia.org/wiki/WhatsApp)
- 공식적인 official 3rd party API는 없는 것으로 보이나 기반 protocol이 XMPP이기 때문인지 unofficial한 API library가 존재함.(아래)
- 하지만 unofficial API library, client들은 DCMA로 부터 중단 요청을 받아 일부는 중단되었음.
 (https://raw.githubusercontent.com/github/dmca/master/2014-02-12-WhatsApp.md)

- API는 아니지만 WhatApp app을 통해서 메세지를 보낼 수 있는 방법은 다음과 같음
 : Android - http://www.whatsapp.com/faq/en/android/28000012
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
 : iPhone - http://www.whatsapp.com/faq/en/iphone/23559013
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
    [[UIApplication sharedApplication] openURL: whatsappURL];
}

[OpenWhatsApp - 3rd party (unofficial) client source code]
http://openwhatsapp.org/
- 라이센스 : GPLv2 license
- 구성 :
 . UI (QML 기반)
 . backend
 . communication core : python library "Yowsup"
   > communication between frontend and s[Whatsapp mobile messenger]erver
   > authentication
   > image send, receive

[Yowsup library - 3rd party (unofficial) python library]
https://github.com/tgalal/yowsup
Wiki : https://github.com/tgalal/yowsup/wiki
Library documentation : https://github.com/tgalal/yowsup/wiki/Yowsup-Library-Documentation

- Requirements
 . python 2.6+
 . python-dateutil
 . yousup-cli requires argparse for python < 2.7

- License : MIT

- Features
 . Registration
 . Text send/ receive
 . Media send/receive (images, videos, audio, location, contact cards)
 . Groups(create, leave, join, update picture, updating subject)
 . Fetch user profile picture
 . Fetch user status
 . Set profile picture
 . Set group icon
 . Set status and others

이거 원 python을 모르니..

- Authentication

authentication mechanism은 WhatsApp 1.2 protocol (WAUTH-1)을 사용.
username (전화번호), password를 입력 하고 auth가 성공적으로 끝나면 auth_success에서 보는 것과 같이 library에 "ready" method를 전달하여 메세지를 받고 parsing하도록 해야 함.

def onAuthSuccess(username):
    print "Logged in with %s" % s
    # make a call to method ready to be able to receive messages
    methodsInterface.call("ready")


y = YowsupConnectionManager()
signalsInterface = y.getSignalsInterface()
methodsInterface = y.getMethodsInterface()
signalsInterface.registerListener("auth_success", onAuthSuccess)
methodsInterface.call("auth_login", ("username", "password"))

- Message send

Whatsapp 이 XMPP 기반 프로토콜이므로 JID를 사용하고 foramt은 전화번호@s.whatsapp.net 이다.
message 전송은 "message_send" 를 통해 전달하고 sent와 delivered의 차이점은 잘 모르겠지만 아마도 library에서 메세지를 서버에 전달했을 때와 서버에서 메세지를 수신자에게 전달 했음을 알리는 것으로 추측.. 암튼 해당 상황의 listener를 등록하여 메세지가 delivered 상태 일때 아래 sample code와 같이 library를 통해서 ack을 전달해야 한다.

def onMessageSent(jid, messageId):
    print "Message was sent successfully to %s" % jid

def onMessageDelivered(jid, messageId):
    print "Message was delivered successfully to %s" %jid
    methodsInterface.call("delivered_ack", (jid, messageId))

signalsInterface.registerListener("receipt_messageSent", onMessageSent)
signalsInterface.registerListener("receipt_messageDelivered", onMessageDelivered)

methodsInterface.call("message_send", ("identifier@s.whatsapp.net", "Hello World!"))

- Message receiving

아래 예제에서는 message 수신 시 "message_id"를 library로 전달하는 코드지만 설명에서는 "message_received" signal을 받으면 listener에서 "message_ack"를 호출해야 한다고 하고 있음. 안그러면 (xmpp 설정, 아마도) 로그인할 때 마다 메세지를 받게 된다.
methodsInterface.call("message_id", ("identifier@s.whatsapp.net", messageId)

- Keep Alive

whatsapp은 3분 마다 "ping"을 전달하여 connection을 유지하므로 listener를 등록해서 "ping" request에 대해서 response하던가 아니면 setAutoPong()를 사용하여 자동적으로 처리 하게 할 수 있다.
To Listen and respond to pings:
def onPing(pingId):
    methodsInterface.call("pong", (pingId,))

signalsInterface.registerListener("ping", onPing)
To tell Yowsup to automatically respond to pings and keep connection alive
y = YowsupConnectionManager()
y.setAutoPong(True)


- Signals
https://github.com/tgalal/yowsup/wiki/Yowsup-Library-Documentation#full-list-of-signals

관심있는 것만 정리하면

 . Messages
message_received(int messageId,str jid,str content,long timestamp,bool receiptRequested)
group_messageReceived(int messageId, str jid, str author, str messageContent, long timestamp, bool wantsReceipt, str pushName):
pushName(int messageId,str jid,str author,str content,long timestamp,bool receiptRequested, str pushName)
 . Groups
group_gotInfo(str jid,str owner,str subject,str subjectOwner,long subjectTimestamp,long creationTimestamp)
group_setSubjectSuccess(str jid)
group_subjectReceived(int messageId,str jid,str author,str subject,long timestamp,bool receiptRequested)
group_addParticipantsSuccess(str jid)
group_removeParticipantsSuccess(str jid)
group_createSuccess(str jid,str groupJid)
group_createFail(int errorCode)
group_endSuccess(str jid)
group_gotPicture(str jid,str filePath)
group_infoError(int errorCode)
group_gotParticipants(str jid,list jids)
group_setPictureSuccess(str jid)
group_setPictureError(str jid,int errorCode)
. Profile
profile_setStatusSuccess(str jid,int messageId)
profile_setPictureSuccess()
profile_setPictureError(int errorCode)
. Contacts
contact_gotProfilePictureId(str jid,long pictureId)
contact_typing(str jid)
contact_paused(str jid)
contact_gotProfilePicture(str jid,str filePath)
 . Media
image_received(int messageId,str jid,str preview,str url,int size,bool receiptRequested)
video_received(int messageId,str jid,str preview,str url,int size,bool receiptRequested)
audio_received(int messageId,str jid,str url,int size,bool receiptRequested)
location_received(int messageId,str jid,str name,str preview,float latitude,float longitude,bool receiptRequested)
vcard_received(int messageId,str jid,str name,str data,bool receiptRequested)
group_imageReceived(int messageId,str jid,str author,str preview,str url,int size,bool receiptRequested)
group_videoReceived(int messageId,str jid,str author,str preview,str url,int size,bool receiptRequested)
group_audioReceived(int messageId,str jid,str author,str url,int size,bool receiptRequested)
group_locationReceived(int messageId,str jid,str author,str name,str preview,float latitude,float longitude,bool receiptRequested)
group_vcardReceived(int messageId,str jid,str author,str name,str data,bool receiptRequested)

- Methods
https://github.com/tgalal/yowsup/wiki/Yowsup-Library-Documentation#full-list-of-methods

역시 관심 있는 것들만

 . Media
message_imageSend(str jid,str url,str name,int size,str preview)
message_videoSend(str jid,str url,str name,int size,str preview)
message_audioSend(str jid,str url,str name,int size)
message_locationSend(str jid,float latitude,float longitude,str preview)
message_vcardSend(str jid,str data,str name)
. Groups
group_getInfo(str jid)
group_getPicture(str jid)
group_create(str subject)
group_addParticipants(str jid,str participants)
group_removeParticipants(str jid,str participants)
group_setPicture(str jid,str filePath)
group_end(str jid)
group_setSubject(str jid,str subject)
group_getParticipants(str jid)
. Contacts
contact_getProfilePicture(str jid)
picture_getIds(list jids)
. Profile
profile_getPicture()
profile_setStatus(str status)
profile_setPicture(str filePath)


[WeChat mobile messenger]

- protocol : ? (TCP based..)
WeChat API : http://developers.wechat.com/
 . Install guide : http://developers.wechat.com/wechatapi/installguide

- Android, iOS 버전을 제공함.
- Overview에서 소개된 시나리오는 WeChat app을 통해 message, content를 공유하는 시나리오인 것으로 보임.
 : http://developers.wechat.com/wechatapi/messages-moments#title-Images


. Sharing via WeChat Message



. Share on WeChat Moments


- 공개된 API들은 auth, message/content(image, music, video, url, file) send 정도의 API들이 있는 것으로 보이고 위 시나리오들을 충족하기 위한 minimum API들인것으로 보인다.

- Text sending

여러 예제(image, music, video, links)들이 있지만 간단한 text 전송을 살펴 보면
아래와 같이 간단하다. 아무래도 (API를 좀 더 들여봐야 겠지만) WeChat app들과 연동되게 되어 있는 것으로 보이고 그래서 API들도 제한적으로 보인다.

text를 담을 WXTextObject 생성
//Init a WXTextObject object
WXTextObject textObj = new WXTextObject();
textObj.text = text;

WXMediaMessage를 생성하여 위의 text object assign
//Init a WXMediaMessage object with WXTextObject
WXMediaMessage msg = newWXMediaMessage();
msg.mediaObject = textObj;
//the title is useless when send a text
//msg.title = "Will be ignored";
msg.description = text;

WeChat contacts들에 share 하기
//Construct a req
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("text");
req.message = msg;
req.scene = SendMessageToWX.Req.WXSceneSession;
//Using API to send data to WeChat
api.sendReq(req);

WeChat moments로 share 하기
//Construct a req
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("text");
req.message = msg;
req.scene = SendMessageToWX.Req.WXSceneTimeline;
//Using API to send data to WeChat
api.sendReq(req);


[Telegram mobile messenger]

Telegram 소개
http://zunonia.wordpress.com/2014/03/04/%EC%83%88%EB%A1%AD%EA%B2%8C-%EB%96%A0%EC%98%A4%EB%A5%B4%EA%B3%A0-%EC%9E%88%EB%8A%94-%EB%AA%A8%EB%B0%94%EC%9D%BC-%EB%A9%94%EC%8B%A0%EC%A0%80-telegram/

특징

API - https://core.telegram.org/api
Protocol - MTProto, https://core.telegram.org/mtproto

- method list
 . Auth, user info, contacts, message send/recv, secret chat, file transfer 등의 API들 존재
 . 아.. 좀 어렵다. API도 그렇고 protocol은 더 상당하고..


[Line]

기업을 위한 API를 제공한다는 기사가 있었음.
아마도 계약된 3rd party를 위한 closed API로 보임.
 : http://thenextweb.com/asia/2012/07/03/asian-mobile-messaging-service-line-embraces-apps-and-opens-the-api-for-its-45m-user-strong-platform/

iOS에서 app을 통해서 메세지를 전달하는 방법은 다음의 링크를
: http://blog.naver.com/PostView.nhn?blogId=apocalypsegm&logNo=130171221611&redirect=Dlog&widgetTypeCall=true
http://www.prnewswire.com/news-releases/nhn-japan-to-launch-lines-new-platform-service-line-channel-161178635.htmlhttp://www.prnewswire.com/news-releases/nhn-japan-to-launch-lines-new-platform-service-line-channel-161178635.html
아래는 개인적으로 packet capture를 통해 확인한 프로토콜.
참고만 해야 할듯. 계속 사용할 수 있는지 불분명한지라..

1 - http://carpedm20.blogspot.kr/2013/09/line-reverse-engineering.html
2 - http://carpedm20.blogspot.kr/2013/09/line-protocol-analysis-2.html
3 - http://carpedm20.blogspot.kr/2013/09/line-protocol-analysis-3-session-key.html
4 - http://carpedm20.blogspot.kr/2013/09/line-protocol-analysis-4-registration.html

기타로 Line Channel 이라는 개념이 2012년 함께 발표 되었음.
game, app, music, coupon등을 제공하는 platform의 개념으로 Line을 만들어 가겠다는 의미이고
기술적인 관점에서는 해당 content들은 HTML5 based web app이나 linked native app으로
Line app을 통해 제공된다고 함.
http://www.serkantoto.com/2012/07/03/line-channel-nhn/
http://www.prnewswire.com/news-releases/nhn-japan-to-launch-lines-new-platform-service-line-channel-161178635.html

[KakaoTalk]

- 공개된 API - https://developers.kakao.com/

 . 카카오톡 프로필 요청,  카카오링크 전송 API를 제공 중임.
  : 프로파일에서 제공되는 정보는 nickname, image URL, thumbnail URL, 국가 정보
  : 카카오링크의 형식 : 텍스트, 이미지, 링크(웹, 앱), 버튼(웹, 앱)


- 추가로 Line과 마찬가지로 사용자가 packet capture하여 확인한 프로토콜. 겁나빠른 황소(LOCO) 프로젝트의 결과물의 protocol이라고 함.

https://www.bpak.org/blog/2012/12/kakaotalk-loco-%ED%94%84%EB%A1%9C%ED%86%A0%EC%BD%9C-%EB%B6%84%EC%84%9D-1/
https://www.bpak.org/blog/2012/12/kakaotalk-loco-%ED%94%84%EB%A1%9C%ED%86%A0%EC%BD%9C-%EB%B6%84%EC%84%9D-2/
http://www.bpak.org/blog/2012/12/kakaotalk-loco-%ED%94%84%EB%A1%9C%ED%86%A0%EC%BD%9C-%EB%B6%84%EC%84%9D-3/
https://www.bpak.org/blog/2012/12/kakaotalk-loco-%ED%94%84%EB%A1%9C%ED%86%A0%EC%BD%9C-%EB%B6%84%EC%84%9D-4/