Manufacturing UDP packets, how in the heck?
I was just wondering how I would go about making a UDP packet and sending it out, I know C and C++ well and I know unix well enough to learn how if need be. Can anyone help me out here, I am trying to learn about computers and heres something I don't know about. Heck I would like to know how to make a packet period, not just UDP.
thanks |
A "packet" is kind of a loose term for a set of data. About the easiest way to create a "packet" is to create a struct. To send it out via UDP, you should look into sockets.
Just to give you an idea of where to start looking, here's a quick pseudo-code example: Code:
typedef struct _packet |
did you mean create your own packets including the headers?
|
yes I meant creating your own packets including the headers. Where would I find documentation for all the functions that where called in that code. I get the feeling that when it comes to alot of that stuff its one of those situations in programing where it would take to long to go into all the function calls and you just have to take them ob faith.
|
also, does anyone know the equivelant unix functions. Thanks
|
To find info on the functions I used above use:
man socket man 2 bind man sendto man inet_addr man htons That should give you some information to get started with socket programming... |
I know it may be taboo to recommend Microsoft references here, but you can also take a look at the Winsock documentation at MSDN. Winsock is derived from Berkley sockets, so it is pretty close to the same calls you would use on Unix. Not everything is exactly the same, but it's usually easy enough to figure out the differences.
|
good stuff, and those are standardized so that when send a packet to a windows machine from unix it will know what to do correct?
|
ok nother quick question while this thread is open how do you start a chargen service in lunix or unix? open a new one on say port 15000 or something like that.
|
i think you have alot of learning to do b4 you create your own packets, have a look here first
http://www.ecst.csuchico.edu/~beej/guide/net/ and learn about the sockets interface. a great book is unix network programming vol I by W Richard Stevens. after reading that you'll have a solid grasp of whats going on and can move onto advanced stuff like raw sockets(that is how you create your own packets). |
dood that sight is what I have been looking for a long time seriously it rocks big time. Anyway, so now my question is: when you call the send(...) functions I take it you would use a struct that would be pointed to by *msg, but in that struct if I wanted to send something like SSDP packet or something like it. Like here:
NOTIFY * HTTP/1.1 HOST: 239.255.255.250:1900 CACHE-CONTROL: max-age=1 LOCATION: URL NT: urn: schemas-upnp-org:device:InternetGatewayDevice:1 NTS: ssdp:alive SERVER: EEYE/2001 UPnP/1.0 PASSITON/1.1 USN: uuid:EEYE how does that translate into a packet that I can make. Anyone have an places or sites where I can learn to put that info into a packet. thanks you guys have been awesome. |
eheh you gotta learn how sockets work before you go crafting your own packets. read the whole tutorial and i promise u'll understand after.
|
I read the whole thing and I put together a program that talks to another one on my mac using sockets.
|
so how do I put together packets?
|
edit.
|
All times are GMT -5. The time now is 08:06 AM. |