Best Method to Identify Socket Address from Packet

22 views
Skip to first unread message

Vikash Kathirvel

unread,
Jan 22, 2018, 10:18:11 AM1/22/18
to ns-3-users
For a TCP connection, given a packet, i need a way to get the address of the socket which sent the packet

Right now the best way i can think of is:

  1. Extract TCP header from Packet
  2. Get Source IP and Source Port from TCP header
  3. Create a temporary InetSocketAddress object using the Source IP and Source Port
  4. Use the ConvertTo function of the InetSocketAddress class to get the Address
Is there a better, more direct way of doing this?

Any help is appreciated, thanks.

Tommaso Pecorella

unread,
Jan 24, 2018, 11:15:30 PM1/24/18
to ns-3-users
socket->GetPeerName (Address &address);

T.
Reply all
Reply to author
Forward
0 new messages