seq & ack_seq from struct tcphdr... how do I get it?

This is a discussion on seq & ack_seq from struct tcphdr... how do I get it? within the Networking/Device Communication forums, part of the General Programming Boards category; Hi! I've got a TCP packet off the network and have put it into the tcphdr struct, which is defined ...

  1. #1
    tin
    tin is offline
    Registered User
    Join Date
    Sep 2004
    Posts
    12

    seq & ack_seq from struct tcphdr... how do I get it?

    Hi!

    I've got a TCP packet off the network and have put it into the tcphdr struct, which is defined as follows in netinet/tcp.h.

    Code:
    struct tcphdr
      {
        u_int16_t source;
        u_int16_t dest;
        u_int32_t seq;
        u_int32_t ack_seq;
        u_int16_t res1:4;
        u_int16_t doff:4;
        u_int16_t fin:1;
        u_int16_t syn:1;
        u_int16_t rst:1;
        u_int16_t psh:1;
        u_int16_t ack:1;
        u_int16_t urg:1;
        u_int16_t res2:2;
        u_int16_t window;
        u_int16_t check;
        u_int16_t urg_ptr;
    };
    Getting the source and dest weren't much of an issue as I could use htons to get the port numbers. However, I couldn't get the right sequence and ack_sequence for it; I tried both htons and htonl. I'm using the ones displayed by Ethereal as reference and am trying to match those.

    No luck yet getting the seq and ack_seq out of the struct

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Ethereal by default does not show the correct ACK and SEQ numbers. Open up the preferences, and then select TCP from the Protocols submenu. Once there, unselect the checkbox that says "Relative sequence numbers". Now ethereal should display the sequence and acknowledgement numbers that are in the actual packets instead of always starting a connection at 1.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segfault with Linked List Program
    By kbrandt in forum C Programming
    Replies: 1
    Last Post: 06-23-2009, 08:13 AM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 04:25 AM
  3. Looking for a way to store listbox data
    By Welder in forum C Programming
    Replies: 20
    Last Post: 11-02-2007, 12:48 AM
  4. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 08:18 AM
  5. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 03:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21