wireless networks c program - c

I would like to create a wireless network from a laptop. If laptops come within range, I would like it to send them a welcome message and send them a goodbye message when they leave the wifi range. Is it possible to do this in C?
Please help me out with this.

It is possible, but it is a very complex task and I don't think that programming language choice is the first thing to look into.
As a start, you can read up on Wikipedia on Wireless ad-hoc networks.

How should your messages be received and displayed on the remote side? If you want to use some existing protocol over TCP/IP, or create your own (deploying custom applications on the remote machines), you will need to mess with networks and this is not always possible as one machine can be a part of only one network. So the machines need to be not connected to anything and somehow allow you to connect to them, it involves changing network settings on all that machines (for example, setting them to join the ad-hoc network with predefined name).
If all machines automatically join the existing network, this question has nothing to do with wireless (physical layer) but with Avahi, Netbios or whatever other services allowing you to get notifications and/or enumerate devices in the network.

Related

CREG, CGREG, CEREG AT commands

I have to control a modem Cinterion ELS61 with a host application. Can anyone tell me in simple words which is the real difference among at+creg?, at+cgreg? and at+cereg? commands?
I know that cgreg is related to 2G and 3G radio access technology and cereg with 4G/LTE one, but the actual differences are not so clear and neither the relation with the creg command results.
It follows an example from a real case:
AT+CREG?
+CREG: 2,5,"38AD","02531900",7
OK
AT+CGREG?
+CGREG: 2,4
OK
AT+CEREG?
+CEREG: 2,5,"2AF2","02531900",7
OK
What is the difference among the answers to +creg and +cereg? Aren't they quite the same? And by the way, what does it mean that the same cell (02531900) has 2 difference location area codes (i.e. 38AD and 2AF2)?
Thanks for the attention
All the +C*REG commands, as you probably know, query the status of the registration to some network.
The first step is the following categorization:
+CREG, that queries the registration to the circuit switched network.
It is basically the GSM "classic" network, on which voice/data calls and SMSs are based
+C*REG commands, that query the registration to the packet networks.
They are the networks on which the packed data traffic is based. The network allowing the access to internet, to be clear.
+C*REG commands are technology specific commands:
+CGREG queries the registration to GPRS network
+CEREG queries the registration to LTE data packet network, and in some cases is mandatory also to perform tasks that were usually based on GSM: voice calls (if VoLTE, Voice Over LTE, is supported) or to sent SMSs (IMS protocol).
LTE technology, basically, moves almost everithing on packet traffic
The reason why different commands are available (even in the same cellular module) is that different registration processes are required for each sub-network.

Read SMBIOS of a remote PC

I know that when a PC is OFF, some components still working ,like the motherboard, the NIC (network card), and others. I thought that like the 'magic packet' send to the NIC on the Wake-on-Lan do, there is a form of sending another signal to this one.
How can I get the SMBIOS table, through the Network Card of a remote and power-off PC?
If someone knows of some code example, or manual which can read to learn, it would be very helpful.
How can I get the SMBIOS table, through the Network Card of a remote and power-off PC?
You can't. WoL is a function of the NIC. When it receives a magic packet it triggers a PMI event, waking up the mainboard - that's it. You can't magically talk through the NIC to the powered down system.
There are two solutions, depending on your actual goal:
Many servers, some workstations and PCs feature lights-out management through a baseboard management controller - features differ, you'll need to select the appropriate product.
Wake the machine, run whatever queries you need and shut it down again. This is a standard procedure for client management.

Synchronize sqlite files without a public IP

I'm trying to come up with a way to sync a sqlite database between two computers.
If this were on a machine with a public IP this would not be difficult but I'm trying to find a way to make this work for ANY two devices, and most computers don't have a static IP.
What are some of the ways I can tackle this problem?
Assuming you just need to find the peers IP address...
Broadcast a Udp packet onto Lan, if machines are same lan segment. You can also try using admin scoped multicast, but mileage will vary according to the network setup and gear in use.
If trying to find two machines across the internet (assuming you can solve the NAT address translation issue), you need to bounce off a node that will hold info for you. Eg write a packet to dweet.io or sparkfun or other website that will hold store and forward data. You can also read twitter feeds etc, basically you need a known reference point to both talk too. Look into how malware create command and control networks for some ideas. Or search for rendezvous servers and protocols.
If the address range is small, probe all possible addresses. But be careful as you might trigger anti virus or ISP action
If wanting more browser based, look at webrtc, not quite what you are after but some of the techniques for discovery might be interesting.
If you have access, you can play with your DNS records. Essentially this is a variation of (2).
There are more options too, but that get more special purpose or become a bit too stelthy for general use. Also see how mesh networks are formed.

How do mobile phone companies detect if you are sharing your 3G/4G internet connection?

I just spoke with a phone company in Denmark, that offer "Free 3G/4G", on the phone, but they have a limitation if you create a hotspot and share the connection, this limitation is on 50GB.
How do they detect if your mobile device is sharing the connection? Do they intercept some special headers that the computer/other phones send over the connection?
MAC addresses are used at a lower layer than IP and relate to each hop or leg of an end to end communication so they don't really help with this issue.
Detecting tethered devices is quite a complicated task and there are special solutions to do exactly this. They tend to look at multiple things to try to determine if other devices are using the mobiles connection, even if the devices are spoofing or manipulating headers etc.
Examples of things a solution will look at:
number of simultaneous sessions
HTTP user-agent headers
device type
device screen size
TCP Timestamp
TCP Source Port
TCP Sequence Number
Application-based correlation to TCP flows
Node-pair correlation to TCP flows
See here for an example solution and more details of the above (this is just one example solution):
https://www.sandvine.com/downloads/general/sandvine-technology-showcases/policy-control-for-connected-and-tethered-devices.pdf
We put the question to Three, which not too surprisingly declined to
answer. However, if you think about it logically, it should be fairly
simple to detect tethering. Every device with a network connection
(including Wi-Fi) has a unique hardware identifier called a MAC
address. Assuming that the operator can trace the final destination of
the data packets, it should be able to determine that the final MAC
doesn't match your phone's.
source
Although the post is about UK operators, it should apply in Denmark.

simulate different PC with different IP addresses in linux environment

im new to linux environment and any help/feedback would be appreciated. Im actually trying to develop a client-server (MULTICAST) program, so, i would like to test one client sending information to different servers (one-to-many relationship). thus, i would like to simulate different server side in linux with different IP addresses in one computer.
Did you try using different ports instead? I didn't try it myself, but perhaps that can help you in the mid-time.
If you're really multicasting, you don't need to worry about physical host-specific IP:s, all you should need to do is make sure all the programs (clients and servers) are using the same multicast group addresses. Then they should all see each other's traffic automatically.
There's nothing stopping you from running multiple clients on the same machine that also runs the server, in this case.
I sounds like you want to test your code with different IP's. You can create IP aliases on your interface and simulate multiple IP's on one computer.
for e.g. if eth0 is you're active interface with IP, say 192.168.5.11 you can assign another IP to eth0:0 (an alias to eth0) as below.
ifconfig eth0:0 192.168.5.12 netmask255.255.255.0 up
ifconfig eth0:1 192.168.5.13 netmask255.255.255.0 up
run your server on one of the IP's and distribute clients to all your aliases
Use either of the following when you do not have sufficient hardware:
Multicast loop which has the IP stack redirect outbound packets to local receivers.
Virtual machines.
Be aware that semantics of the socket option for #1 change depending on the operating system; for #2 only some virtual machines support multicast, refer to the vendor for details.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms739161(v=vs.85).aspx
Ultimately though you must test with different machines due to specific artifacts of how hosts manage multicast groups. You can for instance create send-only membership which will block every other application on the host. Also consider that an internet, lower case 'I', will introduce further artifacts regarding group joining and propagation delays and drops that your application may need to be aware of.
You can create multiple IP for same machine with help of IP alias. As mentioned above.
But to create multiple Server at one PC you must need different port for each server if you want to simulate the all server behavior with network as well.
I mean for one port multicast traffic always goes to that and some process in the PC will be receiving the packet and has to serve for all server in the PC, Means you have one packet only and all server is receiving with locally manipulation.
But really simulation would be you have multiple server at 1 PC and all are receiving multicast traffic from network rather then from local process.
my Solution: You keep number for server == number of port at the PC. Client send the multicast traffic over all port simultaneously and all server at the PC end will be receiving multicast packet from corresponding port from the Network.
Please correct me if my understanding is wrong.

Resources