Python Forum
How to extract MSS (maximum size segment) from a pcap file ? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to extract MSS (maximum size segment) from a pcap file ? (/thread-27958.html)



How to extract MSS (maximum size segment) from a pcap file ? - salwa17 - Jun-29-2020

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 ?