[Libwebsockets] libwebsocket vs regular-sockets performance

Hemant Kumar hkumar at arubanetworks.com
Wed Nov 13 21:23:36 CET 2013


Thanks!! Edwin.
I read the RFC part regarding masking data from client to server and that a random key is generated out of possible 32 bit values to mask the data. The same is not applicable from server to client data.
I don't have any active connection extension, so going through the code of libwebsocket_write(), I still do not expect overhead of 4 ms just because we are masking and framing the data everytime we send. Can you please further clarify on the mechanism for client packet send when libwebsocket_write() which can add extra overhead. The handshake mechanism is done only at the beginning and from the capture data , it doesn't seems heavy either.

Regards
Hemant
________________________________
From: Andy Green [extracats at googlemail.com] on behalf of Edwin van den Oetelaar [andy.green at linaro.org]
Sent: Wednesday, November 13, 2013 11:12 AM
To: Hemant Kumar
Cc: libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] libwebsocket vs regular-sockets performance

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<mailto: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<mailto: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/67cb8188/attachment-0001.html>


More information about the Libwebsockets mailing list