Python Forum
How to extract MSS (maximum size segment) from a pcap file ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to extract MSS (maximum size segment) from a pcap file ?
#1
I want to extract the MSS (Maximum Size Segment)from a pcap file but I got only 0 while I have Not NULL values in this field:

def is_tcp_options(packet):
    if packet.haslayer(TCP):
        if packet[TCP].options:
            return True
    return False


def get_tcp_options(packet, option=None):
    if is_tcp_options(packet):
        for opt in packet[TCP].options:
            if opt[0] == option:
                return opt
    return None


def get_tcp_options_s(s, s_ip, c_ip, opt):
    sOptions = []
    cOptions = []
    for p in s:
        if p.haslayer(TCP) and p.haslayer(IP):
            if (p[IP].src == s_ip):
                o = get_tcp_options(p, opt)
                if o:
                    sOptions.append(o[1])
            if (p[IP].src == c_ip):
                o = get_tcp_options(p, opt)
                if o:
                    cOptions.append(o[1])
    return sOptions, cOptions
Then I call the last function in my main.py file.

Any Idea about why I got only 0 as value ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I write formatted (i.e. bold, italic, change font size, etc.) text to a file? JohnJSal 12 28,310 Feb-13-2025, 04:48 AM
Last Post: tomhansky
  JSON File - extract only the data in a nested array for CSV file shwfgd 2 1,115 Aug-26-2024, 10:14 PM
Last Post: shwfgd
  Extract and rename a file from an Archive tester_V 4 3,903 Jul-08-2024, 07:54 AM
Last Post: tester_V
  Converted EXE file size is too large Rajasekaran 0 2,691 Mar-30-2023, 11:50 AM
Last Post: Rajasekaran
  Extract file only (without a directory it is in) from ZIPIP tester_V 1 4,192 Jan-23-2023, 04:56 AM
Last Post: deanhystad
  Python code a Max7219/7221 7 segment driver Aggie64 11 6,381 Dec-01-2022, 02:24 AM
Last Post: Larz60+
  How to extract specific data from .SRC (note pad file) Shinny_Shin 2 2,224 Jul-27-2022, 12:31 PM
Last Post: Larz60+
  check if a file exist on the internet and get the size kucingkembar 6 3,439 Apr-16-2022, 05:09 PM
Last Post: kucingkembar
  Extract parts of a log-file and put it in a dataframe hasiro 4 10,328 Apr-08-2022, 01:18 PM
Last Post: hasiro
  Extract a string between 2 words from a text file OscarBoots 2 2,789 Nov-02-2021, 08:50 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020