views:

317

answers:

4

I am looking for a utility which can generate UDP or TCP packets from the raw data which I provide to it in a file. Certainly I have to provide the parameters for generating those packets like below:

UDP port #, TCP IP address, which IP type (IPv4 or IPv6) etc

I can provide those parameters as command line or in some config file. But it should be able to generate the UDP or TCP packet out of it and give me that in some text file to view. I need this because I want to use that data as in put data to one of the ethernet driver.

+1  A: 

You appear to be looking for hping.

chaos
A: 

Effectively, it looks like what you are trying to do is wrap some raw data you already have in a file in UDP or TCP and IP headers and then get the 'wrapped' data output? Note that this will be problematic for TCP since its a two way protocol and the 'wrapped' stream would be dependant on the responses from the remote site (re transmissions, packet sizes, etc)

One quick and dirty way to accomplish this would be to transmit the data to a remote host (could be nonexistant for UDP, though you'd need a listening socket on the remote for TCP. You could transmit this data via netcat or netcat6 for IPv6. Then you can run tcpdump or wireshark on the same machine to capture the full wrapped stream to a file in PCAP format. This PCAP would have your raw data packetized (data inside UDP/TCP, IP, and Ethernet headers)

It sounds like for your application, you would want to strip out the ethernet headers before using the data.

A previous answer to this question recommended hping, which would probably give you more flexability at the expense of a longer learning curve to get the results you want.

bdk
A: 

The Nmap folk have built a netcat successor, called Ncat, which is included as part of Nmap 5.

Warren Young
A: 

Python also has low overhead to accomplish something along these lines.

http://www.amk.ca/python/howto/sockets/ has a good tutorial on how to get started.

Bob Breznak