インフラエンジニアにとって、障害解析等でパケットをキャプチャすることはよくあります。 特に通信のセッションに関連する不具合などはパケットをキャプチャして解析しないと、なかなか原因を特定することが難しいです。 ただ問題として、キャプチャしたpcapファイルのサイズがとても大きくてストレージを圧迫してしまうという点です。 特に長時間キャプチャするような場合、それだけでストレージを圧迫してしまうことも考えられます。 そのような場合に便利なツールが、今回紹介する「TrimPCAP」です。 パケット・トリミングの手法はいくつかありますが、一般的な方法はパケットごとに先頭から指定したサイズにトリミングして、ファイルサイズを削減する方法です。 今回紹介するTrimPCAPは、TCPやUDPのセッションごとにセッションの開始から指定したサイズのセッションまでを残し、それ以降のセッションを削除する方式のよう