测试环境(PC1装了N多软件,响应相当慢)
PC1 Win7 32位
Intel 2.10GH双核
内存2G
NAT
PC2 Windows Server 64位 Intel Xeon 2.50GHz
24核内存16G
公网IP(xxx.xxx.xx.xxx)
Test11(延迟):
PC1两进程互传
URPipe |
RPipe |
mcast |
socket |
Tcp(block) |
Udp(block) | |
1B |
16 |
47 |
2917 |
X |
0 |
0 |
100B |
31 |
63 |
2902 |
X |
0 |
0 |
400B |
31 |
78 |
2902 |
X |
0 |
0 |
1KB |
31 |
78 |
2917 |
X |
0 |
0 |
10KB |
31 |
62 |
2917 |
X |
0 |
0 |
Test12(延迟):
PC1->PC2(运行1000次取平均值)
URPipe |
RPipe |
mcast |
socket |
Tcp(block) |
Udp(block) | |
1B |
50 |
60 |
3184 |
X |
16 |
15 |
100B |
54 |
50 |
3150 |
X |
0 |
0 |
400B |
53 |
52 |
3146 |
X |
16 |
16 |
1KB |
56 |
84 |
3143 |
X |
15 |
0 |
10KB |
70 |
67 |
3147 |
X |
0 |
16 |
——————————————————————————————————————————————————
URPipe:不可靠模式双向管道
RPipe:可靠模式双向管道
mcast:组播(JxtaMulticastSocket)
socket:基于流的接口(JxtaServerSocket/JxtaSocket,对本项目影响不大,由于时间关系,没有进行测试)
单位:毫秒;表格中的数值是RTT(Round Trip Time)往返时间,计算单程时间减半。
Test11是在PC1上的两进程互传,可以近似看做是在同一个局域网中。
其中URPipe的时间明显小于RPipe的时间,但比起Tcp和Udp仍然较大。
比较出乎意料的是mcast,其RTT值将近3秒,这个以前没有注意过。
Test12是从PC1向PC2发送消息,然后PC2在收到消息后马上将消息返回给PC1所消耗的时间。测试结果与Test11基本相同,除了各项数值普遍要大一些。
另外一个现象值得注意:
在PC1上,对于双向管道,当使用连续密集发送100消息,延迟会逐渐增大到1s以上而使用不可靠模式时,丢包现象比较严重,发了100个消息,最后只收到40个消息。
在PC2上,对于双向管道,当使用连续密集发送100消息,延迟只增大到100ms级;而且使用不可靠模式时,基本没有丢包现象。
看来我的电脑确实该扔了。。。
——————————————————————————————————————————————————
感觉延迟虽然会对系统有一定影响,但还不是最关键的因素,对于流媒体来说,一定程度的延迟是可以接受的。
上面的测试结果可以作为参考,由于测试过程比较随意,因此不是很精确。
本来想多次发消息取平均值可能更科学一些,但在PC1上连续发消息很多次后,延迟很快增长到若干秒,感觉失去了测试的意义,就此作罢。。。
——————————————————————————————————————————————————
感觉延迟虽然会对系统有一定影响,但还不是最关键的因素,对于流媒体来说,一定程度的延迟是可以接受的。
上面的测试结果可以作为参考,由于测试过程比较随意,因此不是很精确。
本来想多次发消息取平均值可能更科学一些,但在PC1上连续发消息很多次后,延迟很快增长到若干秒(发送1000次时最高达到5秒),感觉测试的意义不大,就此作罢。。。
——————————————————————————————————————————————————
好吧,针对连续密集发送,可能之前的测试代码有问题,做如下改进后,看来好了很多
1 在循环外分配内存(原来在循环内分配内存)
2 每次发送消息后线程休眠100ms
下面是测试结果(可靠双向管道每次只发送1字节数据,第一列是序号,第二列是RTT)
seq=1, 31
seq=2, 16
seq=3, 14
seq=4, 15
seq=5, 17
seq=6, 12
seq=7, 21
seq=8, 19
seq=9, 13
seq=10, 10
seq=11, 21
seq=12, 22
seq=13, 16
seq=14, 9
seq=15, 9
seq=16, 8
seq=17, 19
seq=18, 29
seq=19, 26
seq=20, 19
seq=21, 9
seq=22, 9
seq=23, 11
seq=24, 11
seq=25, 9
seq=26, 11
seq=27, 8
seq=28, 14
seq=29, 8
seq=30, 15
seq=31, 10
seq=32, 40
seq=33, 16
seq=34, 8
seq=35, 8
seq=36, 13
seq=37, 19
seq=38, 16
seq=39, 16
seq=40, 8
seq=41, 8
seq=42, 8
seq=43, 8
seq=44, 34
seq=45, 15
seq=46, 19
seq=47, 8
seq=48, 8
seq=49, 28
seq=50, 9
seq=51, 10
seq=52, 15
seq=53, 9
seq=54, 12
seq=55, 8
seq=56, 8
seq=57, 23
seq=58, 31
seq=59, 10
seq=60, 7
seq=61, 8
seq=62, 21
seq=63, 8
seq=64, 16
seq=65, 7
seq=66, 11
seq=67, 7
seq=68, 8
seq=69, 8
seq=70, 39
seq=71, 9
seq=72, 23
seq=73, 10
seq=74, 9
seq=75, 29
seq=76, 9
seq=77, 8
seq=78, 17
seq=79, 9
seq=80, 9
seq=81, 11
seq=82, 7
seq=83, 37
seq=84, 7
seq=85, 9
seq=86, 10
seq=87, 10
seq=88, 41
seq=89, 20
seq=90, 10
seq=91, 31
seq=92, 9
seq=93, 11
seq=94, 7
seq=95, 22
seq=96, 35
seq=97, 24
seq=98, 8
seq=99, 9
seq=100, 7
seq=101, 38
seq=102, 32
seq=103, 6
seq=104, 9
seq=105, 10
seq=106, 10
seq=107, 7
seq=108, 40
seq=109, 22
seq=110, 10
seq=111, 26
seq=112, 25
seq=113, 8
seq=114, 9
seq=115, 6
seq=116, 8
seq=117, 10
seq=118, 10
seq=119, 13
seq=120, 23
seq=121, 7
seq=122, 12
seq=123, 7
seq=124, 34
seq=125, 9
seq=126, 9
seq=127, 20
seq=128, 10
seq=129, 7
seq=130, 6
seq=131, 12
seq=132, 13
seq=133, 9
seq=134, 8
seq=135, 6
seq=136, 9
seq=137, 37
seq=138, 8
seq=139, 13
seq=140, 9
seq=141, 7
seq=142, 7
seq=143, 22
seq=144, 6
seq=145, 8
seq=146, 10
seq=147, 9
seq=148, 19
seq=149, 12
seq=150, 6
seq=151, 30
seq=152, 8
seq=153, 21
seq=154, 8
seq=155, 11
seq=156, 25
seq=157, 26
seq=158, 9
seq=159, 8
seq=160, 7
seq=161, 8
seq=162, 9
seq=163, 11
seq=164, 22
seq=165, 16
seq=166, 6
seq=167, 13
seq=168, 7
seq=169, 13
seq=170, 18
seq=171, 9
seq=172, 8
seq=173, 7
seq=174, 7
seq=175, 19
seq=176, 33
seq=177, 24
seq=178, 7
seq=179, 7
seq=180, 9
seq=181, 19
seq=182, 6
seq=183, 10
seq=184, 6
seq=185, 6
seq=186, 8
seq=187, 11
seq=188, 19
seq=189, 7
seq=190, 8
seq=191, 7
seq=192, 7
seq=193, 11
seq=194, 24
seq=195, 8
seq=196, 6
seq=197, 6
seq=198, 12
seq=199, 10
seq=200, 9
seq=201, 7
seq=202, 6
seq=203, 9
seq=204, 9
seq=205, 15
seq=206, 6
seq=207, 7
seq=208, 6
seq=209, 9
seq=210, 6
seq=211, 13
seq=212, 21
seq=213, 6
seq=214, 8
seq=215, 7
seq=216, 6
seq=217, 6
seq=218, 7
seq=219, 14
seq=220, 6
seq=221, 8
seq=222, 21
seq=223, 8
seq=224, 12
seq=225, 6
seq=226, 6
seq=227, 13
seq=228, 6
seq=229, 7
seq=230, 6
seq=231, 7
seq=232, 7
seq=233, 7
seq=234, 9
seq=235, 30
seq=236, 8
seq=237, 7
seq=238, 8
seq=239, 7
seq=240, 7
seq=241, 9
seq=242, 7
seq=243, 41
seq=244, 10
seq=245, 10
seq=246, 7
seq=247, 8
seq=248, 27
seq=249, 15
seq=250, 10
seq=251, 9
seq=252, 6
seq=253, 6
seq=254, 7
seq=255, 22
seq=256, 10
seq=257, 9
seq=258, 9
seq=259, 8
seq=260, 8
seq=261, 38
seq=262, 7
seq=263, 7
seq=264, 7
seq=265, 10
seq=266, 9
seq=267, 17
seq=268, 6
seq=269, 9
seq=270, 8
seq=271, 11
seq=272, 6
seq=273, 31
seq=274, 9
seq=275, 7
seq=276, 9
seq=277, 7
seq=278, 8
seq=279, 7
seq=280, 6
seq=281, 23
seq=282, 26
seq=283, 9
seq=284, 6
seq=285, 11
seq=286, 9
seq=287, 6
seq=288, 8
seq=289, 8
seq=290, 8
seq=291, 23
seq=292, 11
seq=293, 7
seq=294, 7
seq=295, 8
seq=296, 35
seq=297, 11
seq=298, 24
seq=299, 9
seq=300, 23
seq=301, 9
seq=302, 8
seq=303, 19
seq=304, 37
seq=305, 12
seq=306, 6
seq=307, 8
seq=308, 6
seq=309, 7
seq=310, 11
seq=311, 14
seq=312, 12
seq=313, 10
seq=314, 11
seq=315, 10
seq=316, 9
seq=317, 10
seq=318, 6
seq=319, 25
seq=320, 23
seq=321, 7
seq=322, 7
seq=323, 10
seq=324, 21
seq=325, 6
seq=326, 6
seq=327, 7
seq=328, 26
seq=329, 28
seq=330, 6
seq=331, 8
seq=332, 6
seq=333, 18
seq=334, 17
seq=335, 34
seq=336, 17
seq=337, 29
seq=338, 10
seq=339, 7
seq=340, 6
seq=341, 12
seq=342, 18
seq=343, 13
seq=344, 8
seq=345, 8
seq=346, 25
seq=347, 8
seq=348, 18
seq=349, 8
seq=350, 15
seq=351, 17
seq=352, 19
seq=353, 8
seq=354, 9
seq=355, 7
seq=356, 8
seq=357, 7
seq=358, 30
seq=359, 19
seq=360, 12
seq=361, 10
seq=362, 7
seq=363, 6
seq=364, 9
seq=365, 17
seq=366, 18
seq=367, 7
seq=368, 9
seq=369, 14
seq=370, 20
seq=371, 14
seq=372, 23
seq=373, 9
seq=374, 7
seq=375, 22
seq=376, 8
seq=377, 9
seq=378, 6
seq=379, 8
seq=380, 9
seq=381, 7
seq=382, 7
seq=383, 6
seq=384, 16
seq=385, 41
seq=386, 13
seq=387, 7
seq=388, 6
seq=389, 7
seq=390, 9
seq=391, 7
seq=392, 9
seq=393, 9
seq=394, 8
seq=395, 8
seq=396, 6
seq=397, 8
seq=398, 7
seq=399, 8
seq=400, 15
seq=401, 9
seq=402, 9
seq=403, 7
seq=404, 6
seq=405, 7
seq=406, 10
seq=407, 7
seq=408, 9
seq=409, 7
seq=410, 8
seq=411, 11
seq=412, 8
seq=413, 12
seq=414, 8
seq=415, 8
seq=416, 13
seq=417, 6
seq=418, 11
seq=419, 6
seq=420, 13
seq=421, 11
seq=422, 12
seq=423, 7
seq=424, 9
seq=425, 9
seq=426, 7
seq=427, 8
seq=428, 9
seq=429, 7
seq=430, 10
seq=431, 7
seq=432, 13
seq=433, 7
seq=434, 9
seq=435, 8
seq=436, 6
seq=437, 10
seq=438, 8
seq=439, 10
seq=440, 9
seq=441, 6
seq=442, 8
seq=443, 10
seq=444, 9
seq=445, 7
seq=446, 8
seq=447, 10
seq=448, 32
seq=449, 10
seq=450, 7
seq=451, 11
seq=452, 9
seq=453, 7
seq=454, 8
seq=455, 6
seq=456, 12
seq=457, 6
seq=458, 11
seq=459, 6
seq=460, 8
seq=461, 6
seq=462, 7
seq=463, 10
seq=464, 18
seq=465, 7
seq=466, 12
seq=467, 7
seq=468, 10
seq=469, 6
seq=470, 8
seq=471, 27
seq=472, 20
seq=473, 8
seq=474, 8
seq=475, 29
seq=476, 24
seq=477, 17
seq=478, 13
seq=479, 8
seq=480, 6
seq=481, 6
seq=482, 10
seq=483, 7
seq=484, 15
seq=485, 32
seq=486, 19
seq=487, 19
seq=488, 18
seq=489, 10
seq=490, 9
seq=491, 12
seq=492, 30
seq=493, 7
seq=494, 8
seq=495, 17
seq=496, 9
seq=497, 6
seq=498, 7
seq=499, 11
seq=500, 6
seq=501, 6
seq=502, 15
seq=503, 9
seq=504, 12
seq=505, 6
seq=506, 10
seq=507, 6
seq=508, 6
seq=509, 13
seq=510, 12
seq=511, 37
seq=512, 12
seq=513, 8
seq=514, 8
seq=515, 8
seq=516, 8
seq=517, 23
seq=518, 6
seq=519, 6
seq=520, 7
seq=521, 6
seq=522, 5
seq=523, 25
seq=524, 21
seq=525, 12
seq=526, 9
seq=527, 6
seq=528, 6
seq=529, 6
seq=530, 8
seq=531, 7
seq=532, 43
seq=533, 9
seq=534, 8
seq=535, 6
seq=536, 7
seq=537, 19
seq=538, 7
seq=539, 9
seq=540, 7
seq=541, 12
seq=542, 9
seq=543, 16
seq=544, 8
seq=545, 9
seq=546, 11
seq=547, 8
seq=548, 5
seq=549, 7
seq=550, 10
seq=551, 9
seq=552, 6
seq=553, 22
seq=554, 7
seq=555, 9
seq=556, 20
seq=557, 9
seq=558, 7
seq=559, 9
seq=560, 6
seq=561, 29
seq=562, 7
seq=563, 8
seq=564, 6
seq=565, 11
seq=566, 7
seq=567, 8
seq=568, 6
seq=569, 10
seq=570, 6
seq=571, 36
seq=572, 10
seq=573, 20
seq=574, 7
seq=575, 9
seq=576, 24
seq=577, 15
seq=578, 6
seq=579, 8
seq=580, 8
seq=581, 9
seq=582, 10
seq=583, 24
seq=584, 21
seq=585, 6
seq=586, 9
seq=587, 19
seq=588, 28
seq=589, 15
seq=590, 6
seq=591, 9
seq=592, 9
seq=593, 6
seq=594, 25
seq=595, 8
seq=596, 6
seq=597, 12
seq=598, 27
seq=599, 7
seq=600, 21
seq=601, 11
seq=602, 5
seq=603, 18
seq=604, 28
seq=605, 11
seq=606, 15
seq=607, 17
seq=608, 26
seq=609, 8
seq=610, 15
seq=611, 11
seq=612, 19
seq=613, 43
seq=614, 6
seq=615, 14
seq=616, 6
seq=617, 6
seq=618, 6
seq=619, 9
seq=620, 6
seq=621, 10
seq=622, 6
seq=623, 6
seq=624, 11
seq=625, 8
seq=626, 6
seq=627, 15
seq=628, 6
seq=629, 8
seq=630, 12
seq=631, 19
seq=632, 28
seq=633, 9
seq=634, 9
seq=635, 5
seq=636, 28
seq=637, 27
seq=638, 10
seq=639, 9
seq=640, 7
seq=641, 8
seq=642, 6
seq=643, 6
seq=644, 27
seq=645, 10
seq=646, 21
seq=647, 6
seq=648, 6
seq=649, 6
seq=650, 25
seq=651, 6
seq=652, 7
seq=653, 6
seq=654, 18
seq=655, 11
seq=656, 24
seq=657, 7
seq=658, 6
seq=659, 6
seq=660, 14
seq=661, 9
seq=662, 9
seq=663, 6
seq=664, 25
seq=665, 15
seq=666, 13
seq=667, 11
seq=668, 21
seq=669, 16
seq=670, 21
seq=671, 7
seq=672, 8
seq=673, 9
seq=674, 7
seq=675, 30
seq=676, 18
seq=677, 10
seq=678, 9
seq=679, 18
seq=680, 9
seq=681, 11
seq=682, 32
seq=683, 6
seq=684, 11
seq=685, 6
seq=686, 10
seq=687, 7
seq=688, 9
seq=689, 6
seq=690, 8
seq=691, 7
seq=692, 44
seq=693, 6
seq=694, 6
seq=695, 7
seq=696, 7
seq=697, 11
seq=698, 8
seq=699, 6
seq=700, 10
seq=701, 7
seq=702, 28
seq=703, 6
seq=704, 6
seq=705, 6
seq=706, 10
seq=707, 10
seq=708, 8
seq=709, 16
seq=710, 6
seq=711, 22
seq=712, 8
seq=713, 33
seq=714, 7
seq=715, 11
seq=716, 21
seq=717, 31
seq=718, 7
seq=719, 22
seq=720, 6
seq=721, 7
seq=722, 9
seq=723, 10
seq=724, 6
seq=725, 21
seq=726, 14
seq=727, 32
seq=728, 10
seq=729, 8
seq=730, 8
seq=731, 20
seq=732, 25
seq=733, 26
seq=734, 7
seq=735, 13
seq=736, 10
seq=737, 26
seq=738, 24
seq=739, 21
seq=740, 20
seq=741, 10
seq=742, 12
seq=743, 18
seq=744, 6
seq=745, 6
seq=746, 6
seq=747, 10
seq=748, 10
seq=749, 19
seq=750, 38
seq=751, 21
seq=752, 21
seq=753, 10
seq=754, 7
seq=755, 51
seq=756, 7
seq=757, 7
seq=758, 6
seq=759, 8
seq=760, 6
seq=761, 13
seq=762, 11
seq=763, 14
seq=764, 11
seq=765, 13
seq=766, 7
seq=767, 15
seq=768, 5
seq=769, 39
seq=770, 20
seq=771, 5
seq=772, 6
seq=773, 6
seq=774, 9
seq=775, 29
seq=776, 8
seq=777, 6
seq=778, 14
seq=779, 27
seq=780, 6
seq=781, 14
seq=782, 9
seq=783, 6
seq=784, 34
seq=785, 17
seq=786, 6
seq=787, 20
seq=788, 20
seq=789, 13
seq=790, 8
seq=791, 16
seq=792, 12
seq=793, 6
seq=794, 7
seq=795, 7
seq=796, 6
seq=797, 36
seq=798, 6
seq=799, 20
seq=800, 8
seq=801, 8
seq=802, 15
seq=803, 6
seq=804, 9
seq=805, 18
seq=806, 8
seq=807, 6
seq=808, 6
seq=809, 10
seq=810, 13
seq=811, 28
seq=812, 15
seq=813, 11
seq=814, 9
seq=815, 7
seq=816, 10
seq=817, 7
seq=818, 8
seq=819, 9
seq=820, 6
seq=821, 10
seq=822, 10
seq=823, 9
seq=824, 8
seq=825, 6
seq=826, 34
seq=827, 22
seq=828, 6
seq=829, 6
seq=830, 6
seq=831, 35
seq=832, 9
seq=833, 6
seq=834, 5
seq=835, 7
seq=836, 18
seq=837, 21
seq=838, 6
seq=839, 7
seq=840, 6
seq=841, 16
seq=842, 9
seq=843, 20
seq=844, 6
seq=845, 6
seq=846, 11
seq=847, 28
seq=848, 7
seq=849, 19
seq=850, 13
seq=851, 9
seq=852, 9
seq=853, 11
seq=854, 12
seq=855, 6
seq=856, 7
seq=857, 11
seq=858, 10
seq=859, 10
seq=860, 10
seq=861, 9
seq=862, 7
seq=863, 8
seq=864, 6
seq=865, 8
seq=866, 6
seq=867, 13
seq=868, 12
seq=869, 6
seq=870, 9
seq=871, 6
seq=872, 8
seq=873, 22
seq=874, 27
seq=875, 15
seq=876, 5
seq=877, 6
seq=878, 8
seq=879, 9
seq=880, 7
seq=881, 8
seq=882, 7
seq=883, 8
seq=884, 5
seq=885, 6
seq=886, 6
seq=887, 6
seq=888, 6
seq=889, 10
seq=890, 7
seq=891, 21
seq=892, 7
seq=893, 6
seq=894, 6
seq=895, 6
seq=896, 10
seq=897, 7
seq=898, 5
seq=899, 8
seq=900, 9
seq=901, 39
seq=902, 8
seq=903, 7
seq=904, 9
seq=905, 7
seq=906, 7
seq=907, 14
seq=908, 7
seq=909, 9
seq=910, 10
seq=911, 7
seq=912, 9
seq=913, 7
seq=914, 10
seq=915, 8
seq=916, 6
seq=917, 6
seq=918, 6
seq=919, 7
seq=920, 10
seq=921, 7
seq=922, 6
seq=923, 6
seq=924, 6
seq=925, 26
seq=926, 6
seq=927, 14
seq=928, 7
seq=929, 13
seq=930, 23
seq=931, 7
seq=932, 7
seq=933, 23
seq=934, 9
seq=935, 11
seq=936, 7
seq=937, 5
seq=938, 7
seq=939, 6
seq=940, 9
seq=941, 35
seq=942, 8
seq=943, 11
seq=944, 8
seq=945, 8
seq=946, 6
seq=947, 26
seq=948, 6
seq=949, 25
seq=950, 16
seq=951, 27
seq=952, 8
seq=953, 16
seq=954, 7
seq=955, 7
seq=956, 12
seq=957, 6
seq=958, 42
seq=959, 7
seq=960, 7
seq=961, 8
seq=962, 8
seq=963, 6
seq=964, 6
seq=965, 7
seq=966, 24
seq=967, 10
seq=968, 7
seq=969, 7
seq=970, 11
seq=971, 7
seq=972, 11
seq=973, 6
seq=974, 8
seq=975, 14
seq=976, 6
seq=977, 6
seq=978, 22
seq=979, 7
seq=980, 7
seq=981, 7
seq=982, 9
seq=983, 10
seq=984, 6
seq=985, 25
seq=986, 6
seq=987, 9
seq=988, 34
seq=989, 6
seq=990, 5
seq=991, 9
seq=992, 9
seq=993, 9
seq=994, 13
seq=995, 25
seq=996, 7
seq=997, 7
seq=998, 6
seq=999, 20
seq=1000, 5