I am creating an app that acts as a remote control for a lighting console and I need to send commands to the console over UDP. The protocol that I am using has its own custom header. How do I create the data packet with header and message to send over UDP? Thanks!
If you are trying to test the protocol, without writing any code, I suggest you use WireShark.
The probably most powerful solution you can use is scapy, which is a python module that allows very advanced packet crafting and manipulation. See its documentation or search the interwebs for examples to find out how to generate arbitrary packets and transmit them.
If you can't use python for some reason, there are multiple command line tools for packet generation, one other example being nping (documentation), the brother of nmap, the popular network scanner. nping has options to generate UDP packets with arbitrary payloads, with can be specified as a hex string, for example.
There may be other options as well. It would be good to know more details like the operating system you're on or where you get your input data from, and in which format.
Related
i doing a simple application that able to integrate with GSM Modem to send and receive the SMS. i had completed the send SMS part, but i not able to receive the SMS. i get error message said that my SIM card memory is full when trying to send the SMS with other mobile device to my SIM card in the GSM Modem. i tried to use the AT command "AT+CMGL" to remove all the messages, but still same. May i know there are any method to store the message in my computer memory so that i able to receive the SMS with my GSM Modem. I using the sample code from here
http://www.codeproject.com/Articles/38705/Send-and-Read-SMS-through-a-GSM-Modem-using-AT-Com
The AT+CMGL command is for listing messages, not deleting them. Deleting messages is done with the AT+CMGD command. Do yourself a favour and download a copy of the 3GPP 27.005 standard, it defines all the standard sms AT commands (most other mobile phone AT commands are defined in 27.007), and by all means get a copy of the ITU standard V.250 which defines the basic command syntax, structure and behaviour for AT commands - an absolute must read for anyone that issues AT commands (read all of chapter 5 at least). These documents are more valuable than any random internet web site, including stackoverflow.
Speaking of random websites, the web page you linked as source seems to be of dubious value. It gives an example function DeleteMsg which issues AT+CMGF=1 but this command does in no way delete anything, it selects text or PDU mode for the various sms related commands.
It does have response handling that is better than the horrible send-sleep-read mistake that unfortunately is not as uncommon as it ought to be, but it is only half decent and not robust at all.
After sending an AT command to a modem you should continuously read and parse response lines from the modem (over and over again) until you receive a final result code (and not just once). See this answer for details.
All of the the message commands operate on the storage location set by AT+CPMS. And notice that you should always set <mem1> and <mem2> at the same time, e.g.
AT+CPMS="SM","SM"
It both makes little sense to only change one of mem1/mem2, and some phones do not like attempts to set only one of them.
I have a string that I want to send to another computer that uses my software. I would like to send the string directly to the software in the other computer. Is there any way to do it?
other alternatives are to use tcp or udp broadcasts
If you need to send the string to multiple computers at once you can use a udp broadcast to 255.255.255.255 ; however with udp there is no confirmation of receipt.
Lots of examples are available if you search for them, here is one:
http://msdn.microsoft.com/en-us/library/tst0kwb1(v=VS.71).aspx
A standard way of achieving such task is to use Sockets. There are plenty of examples over the internet depending on the language and environment you are using.
The following link might be useful to you:
http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.aspx
Is there a way to create a custom UDP header in Lua? I am using Ubuntu 11.10, Lua 5.1, and Luasocket. Am I missing a module for this to work or is it impossible?
What I was planning to do is to send a character in the length section of the UDP header from the client then decode it on the server. Is there a better way of doing this without sending data via normal data transfer?
Thanks.
The only way to modify packet headers is to use raw sockets and construct the packet yourself, including both the IP and UDP headers.
However, what you want to do, use the length field for data, will not work. Remember that all routers/switches/hubs between your client and server looks at the header to determine how long the packet is. If there isn't a valid length there they will fail sending your packet on.
I would like to use WinPCap library for "reliable" UDP receiving in my C++ application. All examples that I found, using this library for capturing and then proceding. Is there any way (example) how to configure PCap for streaming mode and receive UDP only and on uder defined port or how to solve this. In this time I have reliable UDP server able to receiving 0.5Gb/s. But on slower PC I have a packet lose I can see packets in ethereal but not in application.
thanks
vsm
I assume that you have already tried all of the more standard methods of increasing the number of datagrams that you are able to process? Things like increasing the recv buffer size, speeding up the processing that you do per datagram and using IOCP to allow you to bring more threads to bear on the problem or using RIO if you can target Windows 8?
If so then using WinPCap might work but it sounds like a bit of an extreme solution.
What you need to do is create a filter so that you only capture the datagrams that you are interested in... The docs include examples which use filters.
I have server from here: http://www.gamedev.net/topic/533159-article-using-udp-with-iocp/. This code working with IOCP. Its working fine on WIndows XP. There is no problem with receiving 0.5Gb/s. But now on Win7 is little unreliable. Sometimes there are packets positions error. (my device generating udp packets and in its payload there is PacketNumber - number increasing with each packet. When error occured i write all packet numbers into file. I can see for exmaple: 10,11,290,13,14... ). Is there any known differences in WinXP and Win7 for IOCP and multi threading? Or do you konw any free UDP server with IOCP processing?
In procedding loop I only adding packets into buffer and checking their numbers.
I need a network framework that can post raw data such as 0x01. or any raw data i need posted to a server. Not just a HTTP request. I can't seem to find any network frameworks like this. Also, If there are none that currently exist. How would i go about writing the sockets? I can't seem to get that down. which is why i am looking for a existing framework. Thanks for any help. I have tried using sockets but, I was unable to convert the CFArrayRef. I tried many things, But, It crashed every time i tested. So, I am running out of options but to use a prebuilt framework.
Note, I do not want to do only a request like:
POST / HTTP/1.1
Host: localhost
Content-Length: 4
0x01
No, I would like to send RAW data so, The following would be sent to the remote server through a socket.
0x01
This would not be visible raw text however, It would be converted to a data string then sent. I know how to convert most of the stuff i need to do, Its the sending and receiving the response I need the framework for or something that'd work. Any tutorials online or examples on how to do something similar that I can modify to fit to my needs would be greatly appreciated.
How do i send raw data to a socket?
Where do i find a framework like this?
Can you provide tutorials that I can modify to fit my needs?
The best framework for this is CocoaAsyncSocket. While it allows sending arbitrary data on the socket, it also provides very useful abstraction of much of the busywork of socket management. Look particularly a the GCD version that replaces the older RunLoop based code.
I've built several low-level protocols on this stack. I recommend it highly.
You can either use raw sockets or the CFStream API. I recommend the latter.