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.
Related
I want to analysis my app memory. But when I use adb dumpsys meminfo myapp it returns:
App Summary
Pss(KB)
------
Java Heap: 0
Native Heap: 0
Code: 0
Stack: 0
Graphics: 0
Private Other: 0
System: 0
TOTAL: 0 TOTAL SWAP PSS: 0
Objects
Views: 20 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 2 AssetManagers: 2
Local Binders: 10 Proxy Binders: 16
Parcel memory: 6 Parcel count: 25
Death Recipients: 0 OpenSSL Sockets: 0
WebViews: 0
myapp
It has an activity message, but Pss is 0;
And when I dumpsys meninfo systemapp like settings:
App Summary
Pss(KB)
------
Java Heap: 3264
Native Heap: 5404
Code: 10172
Stack: 40
Graphics: 0
Private Other: 1916
System: 12551
TOTAL: 33347 TOTAL SWAP PSS: 0
Objects
Views: 110 ViewRootImpl: 1
AppContexts: 3 Activities: 1
Assets: 2 AssetManagers: 2
Local Binders: 29 Proxy Binders: 28
Parcel memory: 4 Parcel count: 18
Death Recipients: 0 OpenSSL Sockets: 0
WebViews: 0
settings
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?
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
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Running Ubuntu 12.04.3 LTS with 32 cores 244GB. Its the Amazon EC2 memory instance the big one and Java 1.7u25
My java process is running with -Xmx226g
I'm trying to create a really large local cache using CQEngine and so far its blazingly fast with 30,000,000 records. Of course I will add an eviction policy that will allow garbage collection to clean up old objects evicted, but really trying to push the limits here :)
When looking at jvisualvm, the total heap is at about 180GB which dies 40GB to soon. I should be able to squeeze out a bit more.
Not that I don't want the kernel to kill a process if it runs out of resources but I think it's killing it to early and want to squeeze the mem usage as much as possible.
The ulimit output is as follows...
ubuntu#ip-10-156-243-111:/var/log$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 1967992
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1967992
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
The kern.log output is...
340 total pagecache pages
0 pages in swap cache
Swap cache stats: add 0, delete 0, find 0/0
Free swap = 0kB
Total swap = 0kB
63999984 pages RAM
1022168 pages reserved
649 pages shared
62830686 pages non-shared
[ pid ] uid tgid total_vm rss cpu oom_adj oom_score_adj name
[ 505] 0 505 4342 93 9 0 0 upstart-udev-br
[ 507] 0 507 5456 198 2 -17 -1000 udevd
[ 642] 0 642 5402 155 28 -17 -1000 udevd
[ 643] 0 643 5402 155 29 -17 -1000 udevd
[ 739] 0 739 3798 49 10 0 0 upstart-socket-
[ 775] 0 775 1817 124 25 0 0 dhclient3
[ 897] 0 897 12509 152 10 -17 -1000 sshd
[ 949] 101 949 63430 91 9 0 0 rsyslogd
[ 990] 102 990 5985 90 8 0 0 dbus-daemon
[ 1017] 0 1017 3627 40 9 0 0 getty
[ 1024] 0 1024 3627 41 10 0 0 getty
[ 1029] 0 1029 3627 43 6 0 0 getty
[ 1030] 0 1030 3627 41 3 0 0 getty
[ 1032] 0 1032 3627 41 1 0 0 getty
[ 1035] 0 1035 1083 34 1 0 0 acpid
[ 1036] 0 1036 4779 49 5 0 0 cron
[ 1037] 0 1037 4228 40 8 0 0 atd
[ 1045] 0 1045 3996 57 3 0 0 irqbalance
[ 1084] 0 1084 3627 43 2 0 0 getty
[ 1085] 0 1085 3189 39 11 0 0 getty
[ 1087] 103 1087 46916 300 0 0 0 whoopsie
[ 1159] 0 1159 20490 215 0 0 0 sshd
[ 1162] 0 1162 1063575 263 15 0 0 console-kit-dae
[ 1229] 0 1229 46648 153 4 0 0 polkitd
[ 1318] 1000 1318 20490 211 10 0 0 sshd
[ 1319] 1000 1319 6240 1448 1 0 0 bash
[ 1816] 1000 1816 70102543 62010032 4 0 0 java
[ 1947] 0 1947 20490 214 6 0 0 sshd
[ 2035] 1000 2035 20490 210 0 0 0 sshd
[ 2036] 1000 2036 6238 1444 13 0 0 bash
[ 2179] 1000 2179 13262 463 2 0 0 vi
Out of memory: Kill process 1816 (java) score 987 or sacrifice child
Killed process 1816 (java) total-vm:280410172kB, anon-rss:248040128kB, file-rss:0kB
The kern.log clearly states that it killed my process because it ran out of memory. But like I said I think I can squeeze it a bit more. Is there any settings I need to do to allow me to use the 226GB allocated to JAVA.
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.