est
est

Reputation: 11845

how to get IP ID, SEQ id, ACK id in python tcp socket?

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?

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

Answers (1)

Brian White
Brian White

Reputation: 8716

Internal TCP state is generally not made available to application programs.

Your options are:

  • modify the kernel to allow access to this via getsockopt()
  • use a user-space TCP library that is implemented on top of raw IP datagrams (perhaps ioremap though I've never used it)
  • find some way to do what you want without this information

Personally, I recommend the last.

Upvotes: 1

Related Questions