establish a connection using TCP and capture the incoming packets

This is a discussion on establish a connection using TCP and capture the incoming packets within the Networking/Device Communication forums, part of the General Programming Boards category; hello .. i have to write a program in C++,to establish a TCP connection to internet and then sniff the ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    9

    establish a connection using TCP and capture the incoming packets

    hello ..

    i have to write a program in C++,to establish a TCP connection to internet and then sniff the packets using UDP..study those packets in details..i mean demarcate the packets...

    the OS on which i work is windows 98,and i work with Turbo C compiler.

    so,how do i start off with such kind of programming??

    th

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    I recommend Beej's Guide to Network Programming

    http://www.ecst.csuchico.edu/~beej/guide/net/

    I also recommend a newer compiler - like the freely available and hugely popular Dev-C++ from Bloodshed.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    134
    Since you are planning to develop this program on Windows Platform you need to Learn Winsock programming. Also, you definitely need little advanced compiler (and preferebly an advanced OS ). Anyway just check out the link below. It will give you a good heads-up.

    Winsock Programmer's FAQ

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    9
    thank you for links u send me..it really helped.

    but for now ,i m looking forward to write a simple code in C or C++ ,just to extract the data
    coming in while i m online,as the byte stream...as in i have written a simple C program,using inportb() and outportb(),but it does not work.could u suggest me some better way of doing it,but in C or C++ only

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    It's not going to happen with that fossil compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Is this your dial-up connection to your ISP via a modem on a COM port?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Sep 2005
    Posts
    9
    yes!! its a dial up connection

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Well if you're in windows, then I think the only way you'll get to sniff the COM port is by
    a) Using some tools
    http://www.softpedia.com/get/Network...-Monitor.shtml
    http://www.sysinternals.com/Utilities/Portmon.html
    b) Writing some win32 hook functions (no I don't know how to do this).

    Also, since you're actually trying to interpret an IP link, perhaps ethereal will do it for you as well. Note I don't know this will work since I've only ever used ethereal on proper networks.
    http://www.ethereal.com/

    None of this stands a chance of working with your crusty old compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Also, since you're actually trying to interpret an IP link, perhaps ethereal will do it for you as well.
    I don't believe ethereal works on dialup or ISDN connections.

    shraddha, I think you need to do a better job explaining exactly what it is you are trying to accomplish. I'm still not sure whether you are trying to sniff packets from a connection, or simply create your own connection to some server.

  10. #10
    Registered User
    Join Date
    Sep 2005
    Posts
    9
    i m just trying to sniff packets from a connection..

  11. #11
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    Quote Originally Posted by shraddha
    ... establish a TCP connection to internet and then sniff the packets using UDP...
    please explain what do you mean by sniffing using UDP???
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  12. #12
    Arron
    Join Date
    Jul 2005
    Posts
    17
    "establish a TCP connection to internet and then sniff the packets using UDP"

    You wan't a TCP session with internet. That's clear
    What's the next one ? Sniff the packets using UDP ??
    Once u establish a connection (TCP), how will it accept UDP pacets for you to sniff ?

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

    Sniffing

    When you sniff for packets, you get all kinds TCP, UDP, ICMP and others. Perhaps you want to capture the TCP packets that you're sending. You can use ethereal for that if you don't want to write code.

    If you do want to write C code for packet capture, take a look at the Pcap library. It makes life a lot easier for network sniffing.

Popular pages Recent additions subscribe to a feed

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