Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jan 2005 21:33:01 -0800 (PST)
From:      neha agrawal <nehavrce@yahoo.co.in>
To:        freebsd-net@freebsd.org
Subject:   Replaying a TCP connection
Message-ID:  <20050105053301.85548.qmail@web8404.mail.in.yahoo.com>

next in thread | raw e-mail | index | archive | help
--0-860778746-1104903181=:84496
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Content-Id: 
Content-Disposition: inline

hello!

        i want to implement smtp protocol on the same
machine.i have a libpcap trace file..in which i have
captured mail traffic..(single session).and i want to
develop a program which can read this trace file..and
communicate with the smtp server...
    first packet is Sync packet in trace file..so i
want to send it to smtp server...and then i want my
progrem to handle the reply sent by server..(say it
sent Syn-Ack) anf then my prgm should reply
accordingly..
       for doing this i am using PF_PACKET , SOCK_RAW
and using sendto function...i am sending the
packet..im able to see it through tcpdump...but
theserver is not replying...why??i am wrking with
linux Redhat 9 kernel 2.4.20-8
     
       (...if u r familiar with flowreplay tool..i
want to do something similar ...but mine is single
session..so less complicated...)

    attching source code...

 do let me know..if i am on correct track...
                                          thnks
                                           Neha


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
--0-860778746-1104903181=:84496
Content-Type: application/octet-stream; name="tcp1.c"
Content-Transfer-Encoding: base64
Content-Description: tcp1.c
Content-Disposition: attachment; filename="tcp1.c"

Lyp0aCBhIEZJTiBmbGFnIGFuZCBwYXNzIGl0IHRocm91Z2ggYSByYXcgc29j
a2V0LgogKiAKICogVGhhbWVyIEFsLUhlcmJpc2ggc2hhZG93c0B3aGl0ZWZh
bmcuY29tCiAqLwoKI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3Rk
aW8uaD4KCiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9z
b2NrZXQuaD4KCiNpbmNsdWRlIDxuZXRpbmV0L2luLmg+CiNpb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CgxKTsKICB9CiAgCiAgZXhpdCgwKTsKfQo=

--0-860778746-1104903181=:84496--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050105053301.85548.qmail>