One of the main reasons to use tshark is because it is easy to call from scripts. This section covers various tools that you can use on the command-line, as well as Wireshark’s Lua API.
Scripting with Wireshark's Lua API
Generate packets with your favorite programming language