DIY-pcap 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +21 -19
- data/lib/diy/builder.rb +14 -1
- data/lib/diy/version.rb +1 -1
- data/lib/diy/worker_keeper.rb +1 -0
- metadata +3 -3
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -10,22 +10,22 @@ DIY-pcap
|
|
10
10
|
1. 安装很简单
|
11
11
|
|
12
12
|
```bash
|
13
|
-
|
14
|
-
|
13
|
+
gem install DIY-pcap
|
14
|
+
```
|
15
15
|
|
16
16
|
服务端与本机需要同时安装.
|
17
17
|
|
18
18
|
2. 准备好要发送和接收的数据放在 `pcaps` 目录下, 创建文件 spec.rb:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
pcap do |s|
|
22
|
+
s.dir = "pcaps"
|
23
|
+
s.send "r1.dat"
|
24
|
+
s.recv "s1.dat"
|
25
|
+
s.recv "s2.dat"
|
26
|
+
s.send "r2.dat"
|
27
|
+
end
|
28
|
+
```
|
29
29
|
|
30
30
|
上面的意思是, 从本机发送 `r1.dat` 到 服务端, 并等待接收 `s1.dat`, `s2.dat` 数据包, 之后再发送 `r2.dat`, 最后结束.
|
31
31
|
更多内容请参考: simple/ 里面的内容.
|
@@ -43,21 +43,23 @@ DIY-pcap
|
|
43
43
|
2. 准备好 pcap 文件放在 `pcaps/simple.pcap` 目录下, 创建文件 spec.rb:
|
44
44
|
|
45
45
|
```ruby
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
require 'rubygems'
|
47
|
+
require 'diy-pcap'
|
48
|
+
DIY::Builder.new do
|
49
|
+
pcapfile "pcaps/simple.pcap"
|
50
|
+
use DIY::SimpleStrategy.new
|
51
|
+
client "x.x.x.x" # 配置客户端ip, 缺省端口为7878
|
52
|
+
server "x.x.x.x" # 配置服务端ip, 缺省端口为7879, 以上都可以写为 x.x.x.x:x 的形式, 与 rpcap或pcap的 -i 参数对应
|
53
|
+
end
|
52
54
|
```
|
53
|
-
3. 使用方法(
|
55
|
+
3. 使用方法( 准备三台主机或逻辑主机, 只是试验的话可以使用 `127.0.0.1` )
|
54
56
|
|
57
|
+
开始前建议重起服务端与客户端.
|
55
58
|
* 服务端, 执行 `rpcap` ( 如果启动出错, 请参考 rpcap -h 中参数 -i 与 -n )
|
56
|
-
|
57
59
|
* 客户端, 执行 `pcap` ( 如果启动出错, 请参考 pcap -h 中参数 -i 与 -n )
|
58
|
-
|
59
60
|
* 控制端, 执行 `ruby spec.rb`, OK, 开始交互, 结束后, 会有 cost time 与 fail count 输出.
|
60
61
|
|
62
|
+
|
61
63
|
4. (其他说明) 扩展策略, 自定义日志, 修改报文内容参见 [Wiki Home](/windy/DIY-pcap/wiki).
|
62
64
|
|
63
65
|
OK, 一切如故.
|
data/lib/diy/builder.rb
CHANGED
@@ -22,7 +22,10 @@ module DIY
|
|
22
22
|
def find_worker_keepers
|
23
23
|
@curi ||= "druby://localhost:7878"
|
24
24
|
@suri ||= "druby://localhost:7879"
|
25
|
-
|
25
|
+
@me ||= "druby://localhost:7880"
|
26
|
+
# controller drb server
|
27
|
+
DRb.start_service(@me)
|
28
|
+
# client and server drb server
|
26
29
|
@client = DRbObject.new_with_uri(@curi)
|
27
30
|
@server = DRbObject.new_with_uri(@suri)
|
28
31
|
end
|
@@ -47,6 +50,16 @@ module DIY
|
|
47
50
|
@suri = ip2druby(iport)
|
48
51
|
end
|
49
52
|
|
53
|
+
def me(ip_or_iport)
|
54
|
+
default_port = "7880"
|
55
|
+
if ! ip_or_iport.include?(':')
|
56
|
+
iport = ip_or_iport + ':' + default_port
|
57
|
+
else
|
58
|
+
iport = ip_or_iport
|
59
|
+
end
|
60
|
+
@me = ip2druby(iport)
|
61
|
+
end
|
62
|
+
|
50
63
|
def ip2druby(ip)
|
51
64
|
if ! ip.include?('://')
|
52
65
|
return "druby://" + ip
|
data/lib/diy/version.rb
CHANGED
data/lib/diy/worker_keeper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- yafei Lee
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-09-
|
17
|
+
date: 2012-09-29 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|