Reputation: 11845
Python socket in linux (bsd socket)
import socket
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('www.google.com', 80))
s.send('GET / HTTP/1.1\r\n\r\n')
s.recv(1024)
Is it possible to get IP ID, SEQ id, ACK id for the curren s
object?
AF_PACKET
to capture raw incoming & outgoing packets, but feels a really ugly hack. An althernative way to asking the question is how to label the packet stream tuple (srcip, srcport, dstip, dstport, proto_num) to inode/fd on Linux?
Is this possible at all? Maybe using netlink
? I am sure there's a seq/ack id to inode table somewhere at kernel which could be exposed.
Under Ubuntu 12.04 LTS + python 2.7 with root of course.
Upvotes: 3
Views: 2332
Reputation: 8716
Internal TCP state is generally not made available to application programs.
Your options are:
getsockopt()
Personally, I recommend the last.
Upvotes: 1