Find the size of a certain code block
Depending on tool chain, you could use some non-standard extension to allocate the protocol stack code in a specific custom segment of code. On gcc-like compilers it would be something like __attribute__((section(&quot;.myseg&quot;))) in the C code. Other tool chains use #pragma etc. You also have to change the linker script to include this custom segment.
Then finally you can simply open up the linker-generated map file (often a text file called .map) to see how much of the segment that was used.
Keep in mind that you might have to do this for flash and RAM both.