# TCP packets Question

**URL:** <https://forum.suricata.io/t/tcp-packets-question/1359>\
**Category:** Rules\
**Tags:** rules\
**Created:** [May 11, 2021, 7:42am UTC](https://forum.suricata.io/t/tcp-packets-question/1359 "2021-05-11T07:42:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![w2n1ck](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/w2n1ck/32/692_2.png) [@w2n1ck](https://forum.suricata.io/u/w2n1ck)\
**Post date:** [May 11, 2021, 7:42am UTC](https://forum.suricata.io/t/tcp-packets-question/1359/1 "2021-05-11T07:42:10Z")

</div>

I want to detect TCP packets of the same size? How?

---

<div class="post-metadata">

**Author:** ![w2n1ck](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/w2n1ck/32/692_2.png) [@w2n1ck](https://forum.suricata.io/u/w2n1ck)\
**Post date:** [May 11, 2021, 7:43am UTC](https://forum.suricata.io/t/tcp-packets-question/1359/2 "2021-05-11T07:43:34Z")

</div>

I want to detect the number of times a TCP packet of the same size appears at a given time.

---

<div class="post-metadata">

**Author:** ![syoc](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@syoc](https://forum.suricata.io/u/syoc)\
**Post date:** [May 14, 2021, 8:19am UTC](https://forum.suricata.io/t/tcp-packets-question/1359/3 "2021-05-14T08:19:36Z")

</div>

For only one predefined packet size or for packets of any size where the packet size is seen again X times?  
Do you only care about detection inside one tcp stream? As in a packet with size X showing up in 10 different TCP streams should not be alerted on but a 10 packets with size X in one stream should?

---

<div class="post-metadata">

**Author:** ![w2n1ck](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/w2n1ck/32/692_2.png) [@w2n1ck](https://forum.suricata.io/u/w2n1ck)\
**Post date:** [May 18, 2021, 10:01am UTC](https://forum.suricata.io/t/tcp-packets-question/1359/4 "2021-05-18T10:01:44Z")

</div>

## For only one predefined packet size or for packets of any size where the packet size is seen again X times?

yes.

## Do you only care about detection inside one tcp stream? As in a packet with size X showing up in 10 different TCP streams should not be alerted on but a 10 packets with size X in one stream should?

different TCP streams. Don’t care Whether in the same TCP streams, Just the size and the times

---

<div class="post-metadata">

**Author:** ![syoc](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@syoc](https://forum.suricata.io/u/syoc)\
**Post date:** [May 19, 2021, 9:26am UTC](https://forum.suricata.io/t/tcp-packets-question/1359/5 "2021-05-19T09:26:21Z")

</div>

I do not think it can be done using the regular rule language if you are looking for repetition of arbitrary packet sizes. It might be doable using Lua. Fixed packet sizes should be solvable.
