如何检查连接中是否有 IP 标头或 TCP/UDP 标头?

发布于 2024-12-19 13:21:33 字数 189 浏览 4 评论 0原文

我有一个防火墙来检测所有连接。 当我从 A 到 B 建立连接时,我们会收到许多在 A 和 B 之间发送的数据包。如果我们从 B 到 A 建立连接,我们也会收到相同的 A->B 结果。

我不知道如何检查每个数据包是否属于 A 创建或 B 创建的连接。

我已经捕获了IP标头、TCP/UDP标头,但我不知道可以检查它的字段是什么。

I've a firewall to detect all connections.
When I've a connection from A to B, we receive many packet sending between A and B.and if we make a connect from B to A, we also receive the result is the same A->B.

I don't know how to check each packet is belong the connection that A created or B created.

I've captured IP header, TCP/UDP header, but I don't know what's the field that cans check it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉鱼一梦 2024-12-26 13:21:33

序列号字段就是您所需要的。

struct tcphdr {
    unsigned short  th_sport;   /* source port */
    unsigned short  th_dport;   /* destination port */
    tcp_seq th_seq;         /* sequence number */
    tcp_seq th_ack;         /* acknowledgement number */
...
};
    packet A -> B

    A [th_seq=1] -> B
    B [th_seq=2, th_ack=1] -> A
    A [th_seq=3, th_ack=2] -> B

The sequence number field is what you need.

struct tcphdr {
    unsigned short  th_sport;   /* source port */
    unsigned short  th_dport;   /* destination port */
    tcp_seq th_seq;         /* sequence number */
    tcp_seq th_ack;         /* acknowledgement number */
...
};
    packet A -> B

    A [th_seq=1] -> B
    B [th_seq=2, th_ack=1] -> A
    A [th_seq=3, th_ack=2] -> B
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文