Gatling j.n.ConnectException: Address already in use - gatling

When running simulations with Gatling I get the following exceptions:
j.n.ConnectException: Address already in use: no further information
Does this occur when the server tested against fails to respond or timeout?
I want to make sure this is a exception thrown by the server and not by the client.

I also encountered this problem running Gatling (with a lot of requests, > 100 RPS) on Windows. It seems Windows is running out of ephemeral ports to use. See this discussion in the user group forum. So this is not a problem with your system under test, but with the machine running Gatling.
On Windows, you can see and change your ephemeral port range using the netsh command. You can use following commands to
see your currently configured IPv4 port range for TCP:
netsh int ipv4 show dynamicport tcp
change the port range:
netsh int ipv4 set dynamic tcp start=number num=range
E.g., I increased my ephemeral IPv4 TCP port range like so to resolve the problem:
netsh int ipv4 set dynamic tcp start=1025 num=57975

Related

Is there any C API to check if the source IP address is from same network?

I have a server written in C. Is there any API or way to check if the incoming request is from same network as the server is running in ?
Thanks
I assume you are talking about linux platform.
I do not think there is an API for that.
I see 3 methods to check what you need:
1) You can use ttl of ping to see whether client is too many hops away thus most likely being not a member of your network.
Just try this as a proof of concept
ping -t 1 8.8.8.8
2) Also you can get mac address of client's IP from arp table and compare it with mac of your gateway. if they match then there is a chance that your client does not belong to your network.
3) Also you can enumerate all ip addresses you bind to and apply theirs masks to your ip and client ip and check for the match. If they match then client certainly belong to your network.

XAMPP - Share my PC localhost on mobile hotspot to any devices

I wanted to try localhost in my mobile, so I can see if it is really responsive cause in the chrome there are only few selections like iPad,etc.. so My PC has a mobile hotspot. Is it possible to share my localhost to the connected devices?
Why are you using your PC as mobile hotspot? Isn't there another network that both your PC and other devices can connect to and find each other on?
Either way, localhost is just a shorthand for the local loopback IP address (127.0.0.1), which is used for a computer to handle network requests to itself. Now, if the other devices can connect to the PC, then all you need to do is find out what your IP address on the local network is, if XAMPP's Apache server is listening for requests on the network and if any local Firewall isn't blocking access.
(Windows)Before you do anything else, make sure Windows IIS isn't running! It occupies the default http port (80) and is going to cause problems if it's there!
First up, figuring out your IP address:
(Windows)Open the commandprompt (start -> search cmd.exe or run and enter cmd) // (Linux/Unix/Mac)Open a terminal
(Windows)run ip-config and look for the line that specifies your IPv4 address, write it down if you have to // (Linux/Unix/Mac)run ifconfig and look for the line stating inet.
Either way, this address probably looks like 192.168.X.Y
Next, check to see if Apache is listening
As this is often the default setting, it probably is. So grab any other device connected on the same network and open a browser
In the address bar type the 192.168.X.Y IP address of the PC running XAMPP
If you don't see an error, go to your files and enjoy!
If you do get an error, change the config for Apache (httpd.conf) and search for a line containing "Listen 80", if you can't find it then it's probably listening to 0.0.0.0:80 and you need to edit that line to "Listen 80" as that will allow it to listen to all addresses on the network.
Finally, you can't reach it so check if your firewall is blocking access. This is usually Windows firewall not trusting anything that doesn't carry a Microsoft label
Go to Control Panel > Windows Firewall > Allow a program to communicate through windows firewall > Add another program Name: http Port: 80
If it still doesn't work and you're running Windows, refer to this Stack Overflow question as you are not the first person that has trouble setting things up.

Programmatically get IP of directly connected device

Using C I am trying to discover the IP of a locally connected device without knowing any information about the device.
[ my box ]--eth0--------------[ unknown device ]
I can't seem to find a way to arp/broadcast to get the IP of the device. I understand that if I use multicast the device itself has to be a member of the group. When I arp or arp-scan they ask me to assign my eth0 interface an IP but I don't have one assigned, I can put one if I need to but I am unsure what it needs to be set to in order to discover anything.
Example: I have a Linksys wireless IP camera and I want to find the IP/Subnet. Without knowing its subnet/netmask I wouldn't know what to set my eth0 to.
I have written a C program to parse the arp table in Linux but I cannot seem to get the IP from the locally connected device in it. As mentioned above, I cannot use these tools without setting eth0 to something.
I think Your best chance to find something is by capturing all incoming network traffic, especially while unknown device is booting (using tcpdump, wireshark or something similar). Just filter out traffic, which is sent from my box.
Most likely You'll see DHCP requests and maybe ARP requests. If device is using DHCP, the easyest solution would be to run DHCP server on eth0 (so You can assign IP to this device).
If for some reason You need to program in C (and network capture gives expected results), libpcap may be usefull.
If evrything else fails, You can try to dicover unknown IP using fake ARP packets (so You don't need to change IP on eth0) and capturing any responses.

Get all hosts on LAN network in C?

Is it possible to get all the hosts on a LAN network(using C). I need to get the IP addresses and host names.
As explained in this answer, the to ping all hosts in your subnet and see which respond or access the ARP cache. The first approach is accomplished by creating a raw socket using
int sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP));
However, raw sockets basically give you only the IP header so you need to construct the ICMP echo packet yourself. After you constructed it, then you just send them to every IP in the subnet using sendto() and wait for response. For the second approach I suggest reading something like this.
As for determining the host names, it depends on whether the hosts have DNS or NETBIOS names. If you have a DNS configured on your LAN, you may get away with calling getaddrinfo() on the the addresses that respond. Unfortunately, I do not have any idea how to find out the NETBIOS name of any given IP.

Address already in use while executing C socket programme

Hii All,
While running a socket programme (server side ) am getting message like
Address already in use
Am trying to connect to port 80 since port 80 is reserved for https application So before running server side programme i am closing all application that uses https application ,is it enough...
or am doing it wrong??
Am trying to make a communication between browser and termial...
You must run your application as super user(root) on Linux or administrator privileges on Windows in order to bind to port 80. This is the case for all service ports, which is < 1024. Either that or there still is another program binded to that port.
Try using netstat to find out what programs might be listening on port 80.
Example:
on Linux:
netstat -punta
on Windows:
netstat -ban
Both must be run with super user/admin privileges in order to see the program names that bind to specific ports.
If you just closed another process listening on 80 port, this port will be blocked for a certain timespan depending on your OS. This behavior is here to prevent an attacker to crash a service on your machine and immediately restart a malicious service on the same port.
This behavior can be disabled by using SO_REUSEADDR (by using setsockopt).
If your main problem is to communicate from a custom server to your broswer, you can use any port in your server for providing HTTP (8080 is common for that), just specify the port in the url http://server:port/ (ie. http://localhost:8080/)

Resources