[Libwebsockets] libwebsocket vs regular-sockets performance

Edwin van den Oetelaar oetelaar.automatisering at gmail.com
Wed Nov 13 20:12:25 CET 2013


Websockets are not just streaming sockets like TCP they add an extra layer
and Framing.
Please read : http://tools.ietf.org/html/rfc6455

Quoting from the RFC:

o  adds a web origin-based security model for browsers

o  adds an addressing and protocol naming mechanism to support
      multiple services on one port and multiple host names on one IP
      address

o  layers a framing mechanism on top of TCP to get back to the IP
      packet mechanism that TCP is built on, but without length limits

o  includes an additional closing handshake in-band that is designed
      to work in the presence of proxies and other intermediaries

Have a good day,
Edwin van den Oetelaar


On Wed, Nov 13, 2013 at 8:03 PM, Hemant Kumar <andy.green at linaro.org> wrote:

>  Hi
>
> I am performing some benchmarking study for traffic flow in between
> libwebsocket client -server and regular tcp client-server. My tcp client is
> making writes  to blocking sockets.
> I am sending 1000 MB of char buffer. In case of regular tcp sockets, it
> takes Total time of 4 sec 525 ms 317 us 0 ns but in case of websockets, it
> takes total time of 8 sec 844 ms 365 us 832 ns.
> This experiment was conducted on same local machine so , in between
> network latency is not involved.
>
> I have couple of questions based on above observation:
> 1. I understand that websocket is doing some protocol specific operations
> when we call libwebsocket_write() , it does some operations ,calls
> lws_issue_raw() and then calls send().
> My callback is sending data in chunks of 64K , even 32 K also yields the
> same result.
> I want to understand, if websocket does HTTP processing only for handshake
> and after that, it is supposed to muck only pre-append and post-append
> buffer , when we send TEXT/BINARY data, then is the overhead of protocol
> specific operations  add on to increase the time of transfer of
> buffer data to almost double in comparison to normal socket case.
>
> 2. When I send websocket messages all filled with character lets say
> '5',and capture the same of wireshark, I do not see character 5 in payload
> of HTTP. Every time, I repeat the experiment it prints different character.
> When I send Binary data, (use LWS_BINARY) is it supposed to send just
> binary without any encoding and when I send LWS_TEXT, is it not supposed to
> send plane text. Is there some kind of encryption or encoding involved for
> every message sent? If so, is it base64 encoding ? Can I turn off these
> encoding of data and see what I send on wireshark capture?
>
> Thanks
> Hemant
>
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20131113/db9687f5/attachment-0001.html>


More information about the Libwebsockets mailing list