In my java server Application, 1000 UDP packets are coming per second. But my application can process only 100 packets/sec. So there are like 900 UDP packets/sec that my server can not process.
The server application is doing something like this.
while(true)
{
serverSocket.receive(receivePacket);
process(receivePacket); // takes around 50ms to complete
serverSocket.send(sendPacket);
}
From my understanding, those unprocessed packets are getting stored in OS's UDP receive buffer. when this buffer will become full OS will drop those packets.
But the problem is when I run the command to see my UDP buffer size.
cat /proc/net/udp
It shows that there is nothing stored on my UDP socket buffer
cat /proc/net/udp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode ref pointer drops
4: FCA9C11F:C36F 8C719AC6:0035 01 00000000:00000000 00:00000000 00000000 0 0 2983494501 2 ffff880169aff4c0 0
5: FCA9C11F:D3F0 8C719AC6:0035 01 00000000:00000000 00:00000000 00000000 0 0 2983494485 2 ffff8801b9bbedc0 0
16: 7A52BB59:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000 38 0 2438608536 2 ffff8807656764c0 0
16: A2EE0D55:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000 38 0 2438608045 2 ffff88077ccdd7c0 0
16: A58F466D:007B 00000000:0000 07 00000000:00000000 00:00000000 00000000 38 0 2438607809 2 ffff8801129f6240 0
It shows there is no packet drop and tx_queue and rx_queue are 0 in size. So there are no packets stored in UDP receive buffer?
But if I take a tcpdump, then I can see that lots of packets a coming to the server and server can process only 10% all those packets. so the other 90% should be stored in the UDP receive buffer.
What am i missing or not understanding?
Related
I made an android application that returns to the console some Linux commands.
In this case I want to find my wlan0 ip and my wlan1(when is connected) ip.
I've got the full text returned by ifconfig command. The problem is how can get into 2 variables these 2 IPs?
I Tried to substring after inet word but there are more than 1 word with inet. What is the optimal solution for this?
This is my string :
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 16436
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 37 bytes 7123 (6.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 37 bytes 7123 (6.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
p2p0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet6 xxxxxx prefixlen 64 scopeid 0x20<link>
ether xxxxxx txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 xxxxxxxxxxx prefixlen 64 scopeid 0x20<link>
ether xxxxxxx6 txqueuelen 1000 (Ethernet)
RX packets 1504 bytes 817297 (798.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 686 bytes 126080 (123.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Please note that I don't care about :p2p0 or lo section, only wlan0 and wlan1(when is connected).
What I want is to save 192.168.0.100 into a String ip;
Thanks in advance!
I am not sure if i understood what you trying but i think Regular Expressions
is a possible way to go
I am use Netty ( a java network framework) to server UDP request .
I found the
SO_RCVBUF
and
/proc/sys/net/core/rmem_default
and
/proc/net/udp
output confusing:
By the manual of socket( man 7 socket) It explains :
rmem_default
contains the default setting in bytes of the socket receive
buffer.
rmem_max
contains the maximum socket receive buffer size in bytes which
a user may set by using the SO_RCVBUF socket option.
and the /proc/net/udp show's the udp receive queue size :
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
60: 00000000:2F3C 00000000:0000 07 00000000:0003E094 00:00000000 00000000 500 0 2224362 2 ffff810066908cc0
I can get the SO_RCVBUF = 12904, but the rx_queue size is 254100(3E094), and rmem_default is 262142
my confuse is, why the SO_RCVBUF not equals to the rmem_default, and why the queue size not equals the SO_RCVBUF (but larger than it ) ?
It seams the ctx.channel().config().getOption(ChannelOption.SO_RCVBUF)'s value is half of /proc/sys/net/core/rmem_default and the real receive buffer size( queue size ) is also the value of /proc/sys/net/core/rmem_default
so why ctx.channel().config().getOption(ChannelOption.SO_RCVBUF) not equals to the system's config ?
The accepted answer is wrong. The correct alignment is:
tx_queue rx_queue
00000000:0003E094
So rx_queue is 0x0003E094 or 254100. This can be confirmed using netstat -unlp | grep pid , Recv-Q is second column. Example output:
cat /proc/net/udp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode ref pointer drops
8101: 41FD080A:06A5 00000000:0000 07 00000000:00005A00 00:00000000 00000000 1000 0 3892411 2 0000000000000000 0
netstat --udp -nl
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 23040 0 10.8.253.65:1701 0.0.0.0:*
Here, 0x00005A00==23040
You seem to have misread the output. When you line up the columns properly, rx_queue is zero.
I have a java app program run on centos 6.3 and tomcat 7 as the app container, currently I meet one error : java.io.socketexception Maximum number of datagram sockets reached
we use MulticastSocket class to send message. when this error happened, I check the current server UDP socket count with command: ss -s
Total: 212 (kernel 248)
TCP: 70 (estab 15, closed 44, orphaned 0, synrecv 0, timewait 40/0), ports 22
Transport Total IP IPv6
* 248 - -
RAW 0 0 0
UDP 40 40 0
TCP 26 26 0
INET 66 66 0
FRAG 0 0 0
and I also check the
ulimits -n
The default setting is 32768, seem UDP socket count not exceed max count.
Any ideas for this error?
we use MulticastSocket class to send message.
Why? You only need a MulticastSocket to receive multicasts.
Obviously you are leaking MulticastSockets. Presumably you are creating a new one per message and never closing it.
I was using SAR for monitoring bandwidth in one of my projects and I was not sure if it is reporting correct data. So I wrote a very simple dummy program (in java) for testing it which opens a server socket, opens a client connection to that server socket. The server socket upon accepting that client connection, starts writing bytebuffer (of size 1) in a while(true) loop with 1 sec sleep between each iteration. Ideally, I would expect 1 byte transfer every second on the loopback interface in the "SAR -n DEV 1 100" output but what I see is following:
10:54:53 IFACE Ipkts/s Ibytes/s Opkts/s Obytes/s
10:54:56 lo0 2 113 2 113
10:54:56 gif0 0 0 0 0
10:54:56 stf0 0 0 0 0
10:54:56 en0 0 0 0 0
10:54:56 en1 0 0 0 0
10:54:56 fw0 0 0 0 0
10:54:56 vmnet1 0 0 0 0
10:54:56 vmnet8 0 0 0 0
Anyone who can explain this output ?
thanks,
sandeep
If you're using a TCP connection, you don't transfer just the bytes, you also transfer some header information for each packet. Also, the client will have to acknowledge each packet received.
I've wrote simple Client-Server application and try to test it.
I need to write some code to handle when the reply message (sent by server) is being lost and don't reach the client ...
I need to know how to simulate such situation. but I cannot.
I've tried the CTRL-C the server .. but not sure if this a good scenario..
I got from the client:
send:
0 0 0 5 0 0 1 48 25 112 -55 106 0 0 0 34 60 -72 117 -101 37 28 116 -85 -91 61 55
-126 -50 9 5 64 -87 126 -31 -62 30 13 -90 -72 -124 118 20 88 -80 -9 -36 -33 -38
123
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at net.Net.readMessageObject(Net.java:36)
at net.Pitcher.run(Pitcher.java:59)
at net.Pitcher.main(Pitcher.java:122)
BTW, the app written in Java.
If your application is rather simple you can use a programm like netcat to connect to it, dont send anything at some point and see what happens.
Otherwise what you could do is rewrite your server app a little bit to introduce some sort of random fails for testing.
Create a mock network object, so you can simulate various situations, in each case manipulating the mock network object so that you can test that your application interacts with it appropriately.