I have to do a webservice in node.js (server web with express). This service is used from an Android application. My question is how can I count the packet (IP datagram) that Android application send to webservice?
Thank you.
You can try counting the data events in your http server code. Express is probably handling this for you using some body parser middleware, but you can use a custom written one that counts the data events. It's won't be an exact number since node may split headers and body into two events when they were a single packet on the wire. Also you'll only get the view from the server, but you already said that's ok.
Another option for more control is to use the node-pcap bindings at https://github.com/mranney/node_pcap. They allow for low-level wireshark-style monitoring of a network interface. You'll just have to filter and process that data in your JavaScript code. The process doing the actually capturing will likely need to run as root unless you set up your system to not require it.