Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Replacing NIC with own C programs.

    Iam assigned a task to develop a tool which will transfer files from one system to another connected using the ethernet but there wont be any interface card. I hav to write the C programs that will do the tasks of identifying ports n sockets,assigning addresses, appending headers and performs checksums. Right now Iam in complete darkness 'coz I dont know the next step. So plz help me if u hav any idea about this task and where i can get some material or working model. Thx

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Nottingham, England
    Well surely, for the sake of a tenner a card, it's easier and better to go buy a couple of nic's and use the regular TCP/IP stack?

    Or is this another homework question?
    Linux user #126863 - see

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    To inject your own datagrams, you have to manipulate the headers with the help of:
    struct ipheader {
    unsigned char ip_hl:4, ip_v:4;
    unsigned char ip_tos;
    unsigned short int ip_len;
    unsigned short int ip_id;
    unsigned short int ip_off;
    unsigned char ip_ttl;
    unsigned char ip_p;
    unsigned short int ip_sum;
    unsigned int ip_src;
    unsigned int ip_dst;


    struct tcpheader {
    unsigned short int th_sport;
    unsigned short int th_dport;
    unsigned int th_seq;
    unsigned int th_ack;
    unsigned char th_x2:4, th_off:4;
    unsigned char th_flags;
    unsigned short int th_win;
    unsigned short int th_sum;
    unsigned short int th_urp;

    and so on...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts