fujuntang
2021-08-11 68d23225a38a35f1325eb39fa4ed5a005d5de473
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
function server() {
    
    # 开启bus 
 ./shm_util start_bus_server  & server_pid=$! &&  echo "pid: ${server_pid}"
    # 开启网络转发代理
    ./shm_util  start_net_proxy --port=5000 & server_pid=$! && echo "pid: ${server_pid}" 
 
    # 打开请求应答测试的接受端
    ./shm_util recvfrom --bind=100 & server_pid=$! &&  echo "pid: ${server_pid}" 
    ./shm_util recvfrom --bind=101 & server_pid=$! &&  echo "pid: ${server_pid}" 
    ./shm_util recvfrom --bind=102 & server_pid=$! &&  echo "pid: ${server_pid}" 
 
    # 打开回队列收进程
    ./shm_util start_resycle & server_pid=$! &&  echo "pid: ${server_pid}" 
}
 
# 交互式客户端
function client() {
    # ./shm_util start_net_client \
    #  --sendlist="192.168.5.10:5000:11, 192.168.5.22:5000:11, 192.168.20.104:5000:11" \
    #  --publist="192.168.5.10:5000:8, 192.168.5.22:5000:8, 192.168.20.104:5000:8"
 
 
    ./shm_util start_net_client \
     --sendlist=" :5000:100" \
     --publist="localhost:5000"  
 
     
}
 
# one_to_many send
function one_to_many() {
    ./shm_util one_sendto_many \
     --sendlist=" :5000:100, :5000:101, :5000:102"
     
}
 
#  
function send() {
    ./shm_util test_net_sendandrecv \
     --sendlist=" :5000:100, :5000:101, :5000:102"
     
}
 
# 无限循环 pub
function pub() {
    ./shm_util test_net_pub \
     --publist="localhost:5000, localhost:5000"
     
}
# 多线程pub
function mpub() {
    ./shm_util test_net_pub_threads \
     --publist="localhost:5000, localhost:5000"
     
}
 
function stop() {
    ps -ef | grep -e "shm_util" -e "heart_beat"| awk  '{print $2}' | xargs -i kill -15 {}
    
}
 
function close() {
    ps -ef | grep -e "shm_util" -e "heart_beat"| awk  '{print $2}' | xargs -i kill -9 {}
    ipcrm -a
}
 
function scp() {
 
    scp -P 100 -rp ~/wk/softbus basic@192.168.5.22:/data/disk2/test    
    scp -rp ~/wk/softbus basic@192.168.20.10:/data3/workspace/wzq
}
 
case ${1} in
  "server")
  server
  ;;
  "client")
     client
  ;;
  "one_to_many")
    one_to_many
  ;;
  "send")
    send
  ;;
  "mpub")
    mpub
  ;;
  "pub")
    pub
  ;;
  "close")
     close
  ;;
  "")
    close
    sleep 2
    server 
    client
  ;;
 
  *)
  echo "argument input error"
  exit 1
  ;;
esac