Skip to content

How to get source and destination Ip from TCP packet #307

@prashantkalkar

Description

@prashantkalkar

Hi,
I am trying to capture tcp traffic (similar to what tcpdump captures). From the tcp packet I am trying to get the source and destination port and source and destination IP addresses.
Here is how I am getting the tcpPacket

TcpPacket tcpPacket = pcapHandle.getNextPacketEx().get(TcpPacket.class);

But I can't see any method to obtain source and destination IPs. I tried looking into the tcp headers. I also tried looking into the payload like this.

tcpPacket.getPayload().get(IpV4Packet.class)
But this just provide null as payload is of type UnknownPacket.

Is there any way to get the IP information for TCP traffic?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions