source: PlatformSupport/matperf/client/matperfClient_StartExp.asv

Last change on this file was 951, checked in by chunter, 16 years ago

adding matperf

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1function matperfClient_StartExp(varargin)
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% options :
4%       UDP/TCP single
5%       UDP/TCP dualtest
6%       UDP/TCP tradeoff
7% usage :
8%       matperfClient_StartExp('UDP','10.96.94.199','dualtest')
9%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10tic;
11
12UdpTcp  = 0; % UdpTcp is 1 when UDP and it is 2 when TCP
13clear_set;
14
15if strcmp(varargin(1),'UDP'),
16    UdpTcp = 1;
17    tmp_add = varargin(2);
18elseif strcmp(varargin(1), 'TCP'),
19    UdpTcp = 2;
20    tmp_add = varargin(2);
21end
22% tells matlab what mode user wants to use.
23if strcmp(varargin(3), 'single'),
24    mode = 1; % single
25elseif strcmp(varargin(3), 'dualtest'),
26    mode = 2; % dualtest
27elseif strcmp(varargin(3), 'tradeoff'),
28    mode = 3; % tradeoff
29else
30    return
31end
32
33%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34% Ask server to generate & accept experiment
35% 0 - experiment request
36% 1 - trial request
37%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
39%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40% In the below while loop, it will generate a udp packet that includese whether
41% the client is in UDP/TCP single, dualtest or trade off mode and asks the
42% server to get ready for the experiment. If the server successfully
43% recognizes the request and be ready, it will send 0 back to the client
44% and matlab gets out of this while loop.
45%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46udp = pnet('udpsocket', 3333);
47packet = [0; UdpTcp; mode]; % prepares a package
48while(1),
49    pnet(udp,'write',packet);
50    pnet(udp,'writepacket',char(tmp_add),3333); % sends a packet carrying signal 0.
51    pnet(udp,'setreadtimeout',1.2); % wait for the response for 1.2 seconds
52    len = pnet(udp,'readpacket');
53    [address] = pnet(udp,'gethost');
54    if len == 0 || len < 0, % if the client does not receive the response
55        disp('server not responding...reasking to awknowledge');
56        pnet('closeall');
57        udp = pnet('udpsocket',3333);
58        continue;
59    elseif len >0,          % client has received a response.
60        data = pnet(udp,'read',1000,'double');
61        if data == 0,
62            disp('server approved experiment request');
63        else
64            disp('Wrong Code');
65            continue
66        end
67        break;
68    end
69end
70pnet('closeall');
71
72%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73% calling the matperfClient_StartTrial(length, bandwidth, UdpTcp, mode)
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75
76%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77% if need to define port #              %
78% define here                           %
79%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80reqport = 5001; % default               
81
82%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83% if need to define time #              %
84% define here                           %
85  time = 30; % default                  %
86%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87oneM = 1024 * 1024; % defined as 1 Mbits
88tenM = 10 * oneM;
89i = 1;
90%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91oneWM = 1024 * 8;
92%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93% when UDP is selected, the client will run the two for loops with
94% different values of bandwidth and length; and it will set the windows
95% value to 0, which is not needed here. And after one trial, i and the port
96% number will increment by 1 and used in next trial.
97%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98if UdpTcp == 1,
99    windows = 0;
100    for length = 200 :600: 1400
101        for bandwidth = linspace(oneM,oneM * 50,50)
102            matperfClient_StartTrial(length, windows, bandwidth, UdpTcp, mode, time,address,reqport)
103            nem = sprintf('executed %d trial',i);
104            i = i + 1;
105            disp(nem);
106        end
107    end
108    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109    % when TCP is selected, length and bandwidth are kept constant and only
110    % window value is being changed and i and port number increment by 1 as
111    % well.
112    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113elseif UdpTcp == 2,
114    length = 0;
115    bandwidth = 0;
116    for windows = linspace(2* oneWM, 216* oneWM, 10)
117        matperfClient_StartTrial(length, windows, bandwidth, UdpTcp, mode, time,address,reqport)
118        nem = sprintf('executed %d trial',i);
119        reqport = reqport + 1;
120        i = i + 1;
121        disp(nem);
122    end
123   
124end
125toker = toc;
126disp(toker)
127return
Note: See TracBrowser for help on using the repository browser.