I have created virtual serial driver (UMDF) using microsoft sample. Instead of device, i am just receive and forward data to TCP server.
Do i need to handle virtual COM settings like Baud rate, Parity, Stop Bits, Data Length(set by application) in the driver considering that it is just virtual and no device? What about flow control as well?
https://github.com/microsoft/Windows-driver-samples
Using UMDF and basically a combination of these two example drivers from the WDK:
src\serial\VirtualSerial
src\general\echo\umdfSocketEcho\Driver
i.e. The driver device creates a GUID_DEVINTERFACE_COMPORT device interface,
implements all the serial IOCTLs (from the VirtualSerial example), and then
forwards all IO read/write requests to a TCP/IP socket file handle (from the
umdfSocketEcho example).
Related
I'm using Delphi 10.2 Tokyo. I have 4 internet sources with 4 LANs. I want to make a program using TNetHttpClient. How do I direct it to use a specific internet source?
Unfortunately, TNetHttpClient does not provide the ability to bind it to a specific LAN. If you need this capability, you will have to find another HTTP library that can do this.
UPDATE:
After doing some reading, it turns out that on Windows at least, binding a socket for an outbound connection only sets the source IP for the socket's packets, but prior to Vista the actual adapter used for making an IPv4 connection is determined solely by Windows' routing tables, the application can't force a specific IPv4 adapter to be used. But for IPv6 traffic, and for IPv4 traffic on Vista+, binding a socket to a specific adapter should work in most cases.
Q175396: Windows Socket Connection from a Multiple-Homed Computer
Strong and Weak Host Models
Using a specific network interface for a socket in windows
For instance, Indy's TIdHTTP has a public BoundIP property for binding its socket to a network interface's IP (on platforms that require an interface name instead, you can use the TIdHTTP.OnSocketAllocated or TIdHTTP.OnAfterBind event to call the TIdHTTP.Socket.Binding.SetSockOpt() method, such as for using the SO_BINDTODEVICE option on Linux).
I'm trying to write a simple C code with WinPcap to broadcast a beacon packet and capture it in all nearby WiFi units. The code I'm using is very similar to the ones available at WinPcap[1].
The code runs fine if I create an ad-hoc network connection and join all the computers into it. However, this process of creating and joining to an ad-hoc network is cumbersome. It would be much better if, regardless of what network each computer is in, the beacon packets would be broadcasted and captured once the code is running.
As simple as this problem might sound, after some searching it seems that this is not possible to be done on windows (unless re-writing drivers or maybe the kernel):
Raw WiFi Packets with WinPcap[2]
Sending packets without network connection[3]
Does winpcap/libpcap allow me to send raw wireless packets?[4]
Basically, it would be necessary to use the WiFi in monitor mode, which is not supported in Windows[5]. Therefore, if the computers are not in the same network connection, the packets will be discarded.
1st Issue
I'm still intriguing, beacon and probe request packets are a normal traffic across the network. How they could be being sent and received constantly but the user is not allowed to write a program to do so? How to reconcile that?
2nd Issue
Does anyone has experience with Managed Wifi API[6]? I've heard that it might help.
3rd Issue
Acrylic WiFi[7] claims to have developed a NDIS driver which support monitor mode under Windows. Does anyone has experience with this software? Is it possible to integrate with C codes?
4th Issue
Is it possible to code such Wifi beacon on Linux? and on Android?
www.winpcap.org/docs/docs_412/html/main.html
stackoverflow.com/questions/34454592/raw-wifi-packets-with-winpcap/34461313?noredirect=1#comment56674673_34461313
stackoverflow.com/questions/25631060/sending-packets-without-network-connection-wireless-adapter
stackoverflow.com/questions/7946497/does-winpcap-libpcap-allow-me-to-send-raw-wireless-packets
en.wikipedia.org/wiki/Monitor_mode#Operating_system_support
managedwifi.codeplex.com/
www.acrylicwifi.com/
Couple questions I will try to answer. Mgmt and Ctrl packets are used for running a wifi network and don't contain data, I would not call these normal packets. Windows used to(I think still does) convert data packets into ethernet frames and pass it up the stack. Beacon and Probe Req pkts are not necessary for TCP/IP stack to work, ie. web browsers don't need beacon frames to get your web page. Most OS's need minimal info from mgmt/ctrl pkts to help a user interact with a wifi adapter, most mgmt/ctrl pkts only are useful to the driver(and low level os components) to figure how to interact with the network. This way the wifi adapters look and act like ethernet adapters to high level os components.
Never had any experience with Managed Wifi API or Acrylic, so can't give you any feedback.
Most analyzers that capture and send packets do it in 2-3 separate modes mainly because of hardware. Wifi adapters can be in listen mode(promiscuous mode and/or monitor mode) or adapter mode. To capture network traffic you need to listen and not send, ie. if someone sends a pkt while you are sending you miss that traffic. In order to capture(or send) traffic you will need a custom NDIS driver in windows, on linux many of them already do. Checkout wireshark or tshark, they use winpcap to capture pkts in windows and there are some adapters they recommend to use to capture pkts.
Yes it is possible to send a beacon on linux, ie. Aireplay. I know its possible to capture traffic on Android but you it needs to have rooted or custom firmware, which I would believe also means you can send custom pkts. If you are simply trying to send a pkt it might be easier to capture some traffic in tshark or wireshark and use something like aireplay to resend that traffic. You could also edit the packet with a hex editor to tune it to what you need.
I want to implement a demo application to listen data via TCP/IP.
Data Transmitter will transmit a series or ASCII char or a series of string all the time. It feeds data into TCP/IP address (eg. 127.0.0.1:22) This could be a GPS transmitter.
I want to implement a demo application for receiving data by clicking the start button and listening to the data via TCP/IP and display it accordingly.
Correct me if I am wrong, I don't think I can use Server/Client server for this purpose. I tried to create a client application with TIdTcpClient, it receives only one time data. I don't think Indy has a TCP listening component.
Thanks in advance.
If you wanna monitor network comunications between some device and some other program on your computer using of TIdTCPServer won't work. Why? Once Indy will read network data it will mark it as processed and delete it from network buffer. So that data probably won't even reach to the other program on your computer. Workaround for this is that you design your application to actually work similar as network bridge. Your application listens to the data on one port and then forwards that data on another port on which the other program is listening. But the main problem is that you have to make this to work both ways.
What you need is somekind of a component which is able to peek at the network data but don't interact with it. This is usually done on driver level.
Now if it is not abolutely necessary to have such functionality in your own software but you are only interested in getting the data I recomend you try Wireshark (http://www.wireshark.org/). Wireshark is a verry powerfull freware software which alows you to monitor all netwrok traffic on basically all protocols without causing any interuptions. In order for this software to work it instals special driver which serves for intercepting the network data.
Maybe you would want to use same driver in your application if this functionality needs to be in your application.
Based on your diagram I think that your implementation could also be based on a message-oriented middleware, using a message broker which receives the GPS transmitter or other data.
The message broker would then store the data internally and forward it to all interested clients which are connected. A typical messaging pattern in this case is a "Topic", which broadcasts the messages similar to a radio station.
So the middleware will ensure that the information will be collected (optionally also persisted to disk) and then guarantees the delivery to the receivers. This can be done even in a way where receivers which have been off-line for a while still receive the GPS messages created while they where not listening ('retroactive consumers').
There are many popular free open source message brokers, and most of them also can be used with Delphi.
I am trying to modify the receipt printed in a POS printer using a virtual printer and some custom libraries. However I read that (old) POS printers worked by writing directly to a serial port, and if that's the case I would need more a port listener, as opposed to a conventional windows virtual printer. Is that correct?
I am trying to build a general solution, trying to cover as many cases as possible, but I got that direct serial is somewhat an outdated practice.
Check if the printer manufacturer has a virtual serial port emulator you can use. Most old POS software was written to send commands over a COM port. The emulator essentially listens in on that port, intercepts the commands, and translates them so a modern USB or Ethernet printer can output the print jobs.
That chart can be found here with more information: http://www.starmicronics.com/support/TechnologyCategoryDetail.aspx?id=28
This app sends data directly to a COM port and not to a Windows queue of any sort? What port options do you have? If you have LPT as an option that could be remapped to a share and then captured using Redmon or similar port monitor.
I heard about USB to LPT adapters that are capable of mapping PC legacy parallel port address. What is the level of such mapping? I mean - is it possible to access the adpater's pins by using 'in' or 'out' x86 assembler instructions (in Windows or Linux)? If not, what does it mean that the addresses are mapped? What kind of emulation is this?
Thanks.
Marcin
A mapping from legacy I/O port addresses to a USB device is most likely handled by trapping the port access in kernel mode operating system code. For several generations of systems now, the operating system has been able to impose itself between application code and the hardware in such a way that even things that look like raw hardware access to the application are not necessarily so.
Effectively, when the processor comes upon that raw port access, it isn't executed but an operating system service routine is called instead.