0

I am using a Python script to post data from a 3G-connected device.

It uses the Requests library. When monitoring the bytes of each API call (request + response using this method), I am getting 645 bytes per call. A standard movement in my monitored system triggers approx. 20 calls, so I am getting around 13Kb of bandwidth usage per movement.

However, the actual usage is much higher: when monitored through vnstat or psutil (or the data from the sim-card provider), a standard movement is approx 100kb instead of 12-13kb (!). When the script is off - no data is used; so this is not linked to background tasks. Moreover, my script doesn't interact with the web in any other manner than these API requests... I cannot understand where this difference comes from.

Is there bandwidth usage in the Python Requests calls that I am missing?

Community
  • 1
  • 1
AugustinC
  • 1
  • 2

1 Answers1

0

If the API is using any protocols, it may consume the bytes. For example, connection through HTTP might take 'HEADER BYTES + CRLFCRLF' + BODY

In my opinion, the most reliable way to catch the byte is using pcap or wireshark to capture the network. Or if you're using the browser for testing, most of the browsers have its own network monitoring view for the programmers. (i.e. firefox ctrl + shirt + i)

If you're looking at the byte in more lower layer, each network layers (such as OSI 7) adds some headers and sometimes resending (if. tcp) the data for data correction.

Good Luck

Kwang-Chun Kang
  • 351
  • 3
  • 12