[2175] | 1 | %****************************************************************************** |
---|
| 2 | % WARPLab Setup |
---|
| 3 | % |
---|
| 4 | % File : wl_setup.m |
---|
| 5 | % Authors: Chris Hunter (chunter [at] mangocomm.com) |
---|
| 6 | % Patrick Murphy (murphpo [at] mangocomm.com) |
---|
| 7 | % Erik Welsh (welsh [at] mangocomm.com) |
---|
| 8 | % License: Copyright 2013, Mango Communications. All rights reserved. |
---|
| 9 | % Distributed under the WARP license (http://warpproject.org/license) |
---|
| 10 | % |
---|
| 11 | %****************************************************************************** |
---|
| 12 | % MODIFICATION HISTORY: |
---|
| 13 | % |
---|
| 14 | % Ver Who Date Changes |
---|
| 15 | % ----- ---- -------- ------------------------------------------------------- |
---|
| 16 | % 3.00a ejw 8/21/13 Update to use new WARPLab MEX transport; |
---|
| 17 | % Added mex/ directory to MATLAB path |
---|
| 18 | % |
---|
| 19 | %****************************************************************************** |
---|
| 20 | |
---|
[1915] | 21 | function wl_setup |
---|
| 22 | |
---|
[4818] | 23 | REQUIRED_MEX_VERSION = '1.0.4a'; |
---|
| 24 | |
---|
| 25 | |
---|
[1915] | 26 | fprintf('Setting up WARPLab Paths...\n'); |
---|
| 27 | |
---|
[2175] | 28 | %------------------------------------------------------------------------------ |
---|
| 29 | % Remove any paths from previous WARPLab installations |
---|
| 30 | |
---|
[2180] | 31 | % NOTE: We had to add in code involving regular expressions to catch a absolute vs |
---|
| 32 | % relative path issue that we found. For example, if ./util exists in the path, |
---|
| 33 | % then the previous version of the code will run forever because it will find |
---|
| 34 | % the file using 'which' but then the absolute path returned will not be in the |
---|
| 35 | % actual path. Now, we use regular expressions to make sure the path exists |
---|
| 36 | % before removing it. |
---|
| 37 | |
---|
[2175] | 38 | % Remove legacy WARPLab v6 paths |
---|
| 39 | % NOTE: warplab_defines is not used in WARPLab v7 |
---|
[1915] | 40 | done = false; |
---|
| 41 | while(~done) |
---|
[2175] | 42 | [wl_path,ig,ig] = fileparts(which('warplab_defines')); |
---|
[1915] | 43 | if(~isempty(wl_path)) |
---|
| 44 | fprintf(' removing path ''%s''\n',wl_path); |
---|
[2180] | 45 | |
---|
| 46 | my_path = regexprep( sprintf('%s', path), ';', ' ' ); |
---|
| 47 | search_term = regexprep( sprintf('%s ',wl_path), '\\', '\\\\' ); |
---|
| 48 | path_comp = regexp( sprintf('%s',my_path), sprintf('%s',search_term), 'match' ); |
---|
| 49 | |
---|
| 50 | if ( ~isempty( path_comp ) ) |
---|
| 51 | rmpath(wl_path) |
---|
| 52 | else |
---|
| 53 | done = true; |
---|
| 54 | end |
---|
[1915] | 55 | else |
---|
| 56 | done = true; |
---|
| 57 | end |
---|
| 58 | end |
---|
| 59 | |
---|
[2175] | 60 | % Check on .../M_Code_Reference/classes |
---|
[1915] | 61 | done = false; |
---|
| 62 | while(~done) |
---|
[2175] | 63 | [wl_path,ig,ig] = fileparts(which('wl_node')); |
---|
[1915] | 64 | if(~isempty(wl_path)) |
---|
| 65 | fprintf(' removing path ''%s''\n',wl_path); |
---|
[2180] | 66 | |
---|
| 67 | my_path = regexprep( sprintf('%s', path), ';', ' ' ); |
---|
| 68 | search_term = regexprep( sprintf('%s ',wl_path), '\\', '\\\\' ); |
---|
| 69 | path_comp = regexp( sprintf('%s',my_path), sprintf('%s',search_term), 'match' ); |
---|
| 70 | |
---|
| 71 | if ( ~isempty( path_comp ) ) |
---|
| 72 | rmpath(wl_path) |
---|
| 73 | else |
---|
| 74 | done = true; |
---|
| 75 | end |
---|
[1915] | 76 | else |
---|
| 77 | done = true; |
---|
| 78 | end |
---|
| 79 | end |
---|
| 80 | |
---|
[2175] | 81 | % Check on .../M_Code_Reference/util |
---|
[1915] | 82 | done = false; |
---|
| 83 | while(~done) |
---|
[2175] | 84 | [wl_path,ig,ig] = fileparts(which('wl_ver')); |
---|
[1915] | 85 | if(~isempty(wl_path)) |
---|
| 86 | fprintf(' removing path ''%s''\n',wl_path); |
---|
[2180] | 87 | |
---|
| 88 | my_path = regexprep( sprintf('%s', path), ';', ' ' ); |
---|
| 89 | search_term = regexprep( sprintf('%s ',wl_path), '\\', '\\\\' ); |
---|
| 90 | path_comp = regexp( sprintf('%s',my_path), sprintf('%s',search_term), 'match' ); |
---|
| 91 | |
---|
| 92 | if ( ~isempty( path_comp ) ) |
---|
| 93 | rmpath(wl_path) |
---|
| 94 | else |
---|
| 95 | done = true; |
---|
| 96 | end |
---|
[1915] | 97 | else |
---|
| 98 | done = true; |
---|
| 99 | end |
---|
| 100 | end |
---|
| 101 | |
---|
[2175] | 102 | % Check on .../M_Code_Reference/util/inifile |
---|
[1915] | 103 | done = false; |
---|
| 104 | while(~done) |
---|
| 105 | [wl_path,ig,ig] = fileparts(which('inifile')); |
---|
| 106 | if(~isempty(wl_path)) |
---|
| 107 | fprintf(' removing path ''%s''\n',wl_path); |
---|
[2180] | 108 | |
---|
| 109 | my_path = regexprep( sprintf('%s', path), ';', ' ' ); |
---|
| 110 | search_term = regexprep( sprintf('%s ',wl_path), '\\', '\\\\' ); |
---|
| 111 | path_comp = regexp( sprintf('%s',my_path), sprintf('%s',search_term), 'match' ); |
---|
| 112 | |
---|
| 113 | if ( ~isempty( path_comp ) ) |
---|
| 114 | rmpath(wl_path) |
---|
| 115 | else |
---|
| 116 | done = true; |
---|
| 117 | end |
---|
[1915] | 118 | else |
---|
| 119 | done = true; |
---|
| 120 | end |
---|
| 121 | end |
---|
| 122 | |
---|
[2175] | 123 | % Check on .../M_Code_Reference/config |
---|
[1915] | 124 | done = false; |
---|
| 125 | while(~done) |
---|
| 126 | [wl_path,ig,ig] = fileparts(which('wl_config.ini')); |
---|
| 127 | if(~isempty(wl_path)) |
---|
| 128 | fprintf(' removing path ''%s''\n',wl_path); |
---|
[2180] | 129 | |
---|
| 130 | my_path = regexprep( sprintf('%s', path), ';', ' ' ); |
---|
| 131 | search_term = regexprep( sprintf('%s ',wl_path), '\\', '\\\\' ); |
---|
| 132 | path_comp = regexp( sprintf('%s',my_path), sprintf('%s',search_term), 'match' ); |
---|
| 133 | |
---|
| 134 | if ( ~isempty( path_comp ) ) |
---|
| 135 | rmpath(wl_path) |
---|
| 136 | else |
---|
| 137 | done = true; |
---|
| 138 | end |
---|
[1915] | 139 | else |
---|
| 140 | done = true; |
---|
| 141 | end |
---|
| 142 | end |
---|
| 143 | |
---|
[2175] | 144 | % Check on .../M_Code_Reference/mex |
---|
| 145 | done = false; |
---|
| 146 | while(~done) |
---|
| 147 | [wl_path,ig,ig] = fileparts(which('wl_mex_udp_transport')); |
---|
| 148 | if(~isempty(wl_path)) |
---|
| 149 | fprintf(' removing path ''%s''\n',wl_path); |
---|
[2180] | 150 | |
---|
| 151 | my_path = regexprep( sprintf('%s', path), ';', ' ' ); |
---|
| 152 | search_term = regexprep( sprintf('%s ',wl_path), '\\', '\\\\' ); |
---|
| 153 | path_comp = regexp( sprintf('%s',my_path), sprintf('%s',search_term), 'match' ); |
---|
| 154 | |
---|
| 155 | if ( ~isempty( path_comp ) ) |
---|
| 156 | rmpath(wl_path) |
---|
| 157 | else |
---|
| 158 | done = true; |
---|
| 159 | end |
---|
[2175] | 160 | else |
---|
| 161 | done = true; |
---|
| 162 | end |
---|
| 163 | end |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | %------------------------------------------------------------------------------ |
---|
| 168 | % Add new paths |
---|
| 169 | |
---|
| 170 | % Add .../M_Code_Reference/classes |
---|
[1940] | 171 | myPath = sprintf('%s%sclasses',pwd,filesep); |
---|
| 172 | fprintf(' adding path ''%s''\n',myPath); |
---|
| 173 | addpath(myPath) |
---|
[1915] | 174 | |
---|
[2175] | 175 | % Add .../M_Code_Reference/util |
---|
[1940] | 176 | myPath = sprintf('%s%sutil',pwd,filesep); |
---|
| 177 | fprintf(' adding path ''%s''\n',myPath); |
---|
| 178 | addpath(myPath) |
---|
[1915] | 179 | |
---|
[2175] | 180 | % Add .../M_Code_Reference/util/inifile |
---|
[1940] | 181 | myPath = sprintf('%s%sutil%sinifile',pwd,filesep,filesep); |
---|
| 182 | fprintf(' adding path ''%s''\n',myPath); |
---|
| 183 | addpath(myPath) |
---|
[1915] | 184 | |
---|
[2175] | 185 | % Add .../M_Code_Reference/mex |
---|
| 186 | myPath = sprintf('%s%smex',pwd,filesep); |
---|
| 187 | fprintf(' adding path ''%s''\n',myPath); |
---|
| 188 | addpath(myPath) |
---|
| 189 | |
---|
| 190 | % Add .../M_Code_Reference/config |
---|
[1940] | 191 | configPath = sprintf('%s%sconfig',pwd,filesep); |
---|
| 192 | fprintf(' adding path ''%s''\n',configPath); |
---|
| 193 | addpath(configPath) |
---|
[1915] | 194 | |
---|
[1940] | 195 | configFile = sprintf('%s%swl_config.ini',configPath,filesep); |
---|
[1915] | 196 | |
---|
[2149] | 197 | % Example of adding a user path to WARPLab setup: |
---|
[2175] | 198 | % In this example, C:\WARP_Repository\ResearchApps\PHY\WARPLAB\WARPLab7\M_Code_Reference\mex is added to the MATLAB path |
---|
[2149] | 199 | % |
---|
[2175] | 200 | % myPath = sprintf('C:%sWARP_Repository%sResearchApps%sPHY%sWARPLAB%sWARPLab7%sM_Code_Reference%smex',filesep,filesep,filesep,filesep,filesep,filesep,filesep); |
---|
| 201 | % fprintf(' adding path ''%s''\n',myPath); |
---|
| 202 | % addpath(myPath) |
---|
[2149] | 203 | |
---|
[1915] | 204 | fprintf(' saving path\n\n\n'); |
---|
| 205 | savepath |
---|
| 206 | |
---|
[2175] | 207 | %------------------------------------------------------------------------------ |
---|
| 208 | % Read config file |
---|
| 209 | |
---|
[4375] | 210 | IP = ''; |
---|
| 211 | host = ''; |
---|
| 212 | port_unicast = ''; |
---|
| 213 | port_bcast = ''; |
---|
| 214 | transport = ''; |
---|
| 215 | max_transport_payload_size = ''; |
---|
[1924] | 216 | |
---|
[4375] | 217 | % Read existing config file for defaults |
---|
| 218 | if(exist(configFile)) |
---|
[1915] | 219 | fprintf('A wl_config.ini file was found in your path. Values specified in this\n'); |
---|
| 220 | fprintf('configuration file will be used as defaults in the construction of the\n'); |
---|
| 221 | fprintf('new file.\n'); |
---|
[4375] | 222 | |
---|
| 223 | readKeys = {'network', '', 'host_address',''}; |
---|
| 224 | IP = inifile(configFile, 'read', readKeys); |
---|
[1915] | 225 | IP = IP{1}; |
---|
| 226 | |
---|
[4375] | 227 | readKeys = {'network', '', 'host_ID', ''}; |
---|
| 228 | host = inifile(configFile, 'read', readKeys); |
---|
[1915] | 229 | host = host{1}; |
---|
| 230 | |
---|
[4375] | 231 | readKeys = {'network', '', 'unicast_starting_port', ''}; |
---|
| 232 | port_unicast = inifile(configFile, 'read', readKeys); |
---|
[1915] | 233 | port_unicast = port_unicast{1}; |
---|
| 234 | |
---|
[4375] | 235 | readKeys = {'network', '', 'bcast_port', ''}; |
---|
| 236 | port_bcast = inifile(configFile, 'read', readKeys); |
---|
[1915] | 237 | port_bcast = port_bcast{1}; |
---|
| 238 | |
---|
[4375] | 239 | readKeys = {'network', '', 'transport', ''}; |
---|
| 240 | transport = inifile(configFile, 'read', readKeys); |
---|
[1915] | 241 | transport = transport{1}; |
---|
[1997] | 242 | |
---|
[4375] | 243 | readKeys = {'network', '', 'max_transport_payload_size', ''}; |
---|
| 244 | max_transport_payload_size = inifile(configFile, 'read', readKeys); |
---|
| 245 | max_transport_payload_size = max_transport_payload_size{1}; |
---|
[1924] | 246 | end |
---|
| 247 | |
---|
[4375] | 248 | % Sane Defaults |
---|
[1924] | 249 | if(isempty(IP)) |
---|
| 250 | IP = '10.0.0.250'; |
---|
| 251 | end |
---|
| 252 | if(isempty(host)) |
---|
[1915] | 253 | host = '250'; |
---|
[1924] | 254 | end |
---|
| 255 | if(isempty(port_unicast)) |
---|
[1915] | 256 | port_unicast = '9000'; |
---|
[1924] | 257 | end |
---|
| 258 | if(isempty(port_bcast)) |
---|
| 259 | port_bcast = '10000'; |
---|
| 260 | end |
---|
[4416] | 261 | % if(isempty(transport)) % Moved lower in the function |
---|
| 262 | % transport = 'java'; |
---|
| 263 | % end |
---|
[4375] | 264 | if(isempty(max_transport_payload_size)) |
---|
| 265 | max_transport_payload_size = '1470'; |
---|
[1997] | 266 | end |
---|
[1915] | 267 | |
---|
| 268 | inifile(configFile,'new') |
---|
| 269 | |
---|
[4375] | 270 | writeKeys = {'config_info', '', 'date_created', date}; |
---|
| 271 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1915] | 272 | |
---|
| 273 | [MAJOR,MINOR,REVISION] = wl_ver(); |
---|
[4375] | 274 | writeKeys = {'config_info', '', 'wl_ver', sprintf('%d.%d.%d', MAJOR, MINOR, REVISION)}; |
---|
| 275 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1915] | 276 | |
---|
| 277 | fprintf('\n\n') |
---|
| 278 | fprintf('------------------------------------------------------------\n') |
---|
| 279 | fprintf('Please enter a WARPLab Ethernet interface address.\n\n') |
---|
| 280 | fprintf('Pressing enter without typing an input will use a default\n') |
---|
[4375] | 281 | fprintf('IP address of: %s\n\n', IP); |
---|
[1915] | 282 | |
---|
[2347] | 283 | % Sanity check input due to errors users were experiencing on the forums |
---|
| 284 | ip_valid = 0; |
---|
| 285 | |
---|
| 286 | while( ip_valid == 0 ) |
---|
| 287 | |
---|
| 288 | temp = input('WARPNet Ethernet Interface Address: ','s'); |
---|
| 289 | if( isempty(temp) ) |
---|
| 290 | temp = IP; |
---|
| 291 | ip_valid = 1; |
---|
| 292 | fprintf(' defaulting to %s\n',temp); |
---|
| 293 | else |
---|
| 294 | if ( regexp( temp, '\d+\.\d+\.\d+\.\d+' ) == 1 ) |
---|
| 295 | ip_valid = 1; |
---|
| 296 | fprintf(' setting to %s\n',temp) |
---|
| 297 | else |
---|
| 298 | fprintf(' %s is not a valid IP address. Please enter a valid IP address.\n',temp); |
---|
| 299 | end |
---|
| 300 | end |
---|
[1915] | 301 | end |
---|
| 302 | |
---|
[1924] | 303 | if(ispc) |
---|
| 304 | [status, tempret] = system('ipconfig /all'); |
---|
| 305 | elseif(ismac||isunix) |
---|
| 306 | [status, tempret] = system('ifconfig -a'); |
---|
| 307 | end |
---|
| 308 | tempret = strfind(tempret,temp); |
---|
| 309 | |
---|
| 310 | if(isempty(tempret)) |
---|
| 311 | warning('No interface found. Please ensure that your network interface is connected and configured with static IP %s',temp); |
---|
| 312 | pause(1) |
---|
| 313 | end |
---|
| 314 | |
---|
[4375] | 315 | writeKeys = {'network', '', 'host_address', temp}; |
---|
| 316 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1915] | 317 | |
---|
| 318 | fprintf('\n\n') |
---|
| 319 | fprintf('------------------------------------------------------------\n') |
---|
[2036] | 320 | fprintf('Please enter a WARPLab host ID.\n') |
---|
| 321 | fprintf('Valid host IDs are integers in the range of [200,254]\n\n') |
---|
[1915] | 322 | fprintf('Pressing enter without typing an input will use a default\n') |
---|
[4375] | 323 | fprintf('host ID of: %s\n\n', host); |
---|
[1915] | 324 | |
---|
[4375] | 325 | temp = input('WARPLab Host ID: ', 's'); |
---|
[1915] | 326 | if(isempty(temp)) |
---|
| 327 | temp = host; |
---|
[2036] | 328 | if(isempty(str2num(temp))) |
---|
[2867] | 329 | error('Host ID must be an integer in the range of [200,254]'); |
---|
[2036] | 330 | else |
---|
[4375] | 331 | if((str2num(temp) < 200) || ((str2num(temp) > 254))) |
---|
[2867] | 332 | error('Host ID must be an integer in the range of [200,254]'); |
---|
[2036] | 333 | end |
---|
| 334 | end |
---|
[4375] | 335 | fprintf(' defaulting to %s\n', temp); |
---|
[1915] | 336 | else |
---|
[2036] | 337 | if(isempty(str2num(temp))) |
---|
[2867] | 338 | error('Host ID must be an integer in the range of [200,254]'); |
---|
[2036] | 339 | else |
---|
[4375] | 340 | if((str2num(temp) < 200) || ((str2num(temp) > 254))) |
---|
[2867] | 341 | error('Host ID must be an integer in the range of [200,254]'); |
---|
[2036] | 342 | end |
---|
| 343 | end |
---|
| 344 | |
---|
[4375] | 345 | fprintf(' setting to %s\n', temp); |
---|
[1915] | 346 | end |
---|
| 347 | |
---|
[4375] | 348 | writeKeys = {'network', '', 'host_ID', temp}; |
---|
| 349 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1915] | 350 | |
---|
| 351 | fprintf('\n\n') |
---|
| 352 | fprintf('------------------------------------------------------------\n') |
---|
| 353 | fprintf('Please enter a unicast starting port.\n\n') |
---|
| 354 | fprintf('Pressing enter without typing an input will use a default\n') |
---|
[4375] | 355 | fprintf('unicast starting port of: %s\n\n', port_unicast); |
---|
[1915] | 356 | |
---|
[4375] | 357 | temp = input('Unicast Starting Port: ', 's'); |
---|
[1915] | 358 | if(isempty(temp)) |
---|
| 359 | temp = port_unicast; |
---|
[4375] | 360 | fprintf(' defaulting to %s\n', temp); |
---|
[1915] | 361 | else |
---|
[4375] | 362 | fprintf(' setting to %s\n', temp); |
---|
[1915] | 363 | end |
---|
| 364 | |
---|
[4375] | 365 | writeKeys = {'network', '', 'unicast_starting_port', temp}; |
---|
| 366 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1915] | 367 | |
---|
| 368 | |
---|
| 369 | fprintf('\n\n') |
---|
| 370 | fprintf('------------------------------------------------------------\n') |
---|
| 371 | fprintf('Please enter a broadcast port.\n\n') |
---|
| 372 | fprintf('Pressing enter without typing an input will use a default\n') |
---|
[4375] | 373 | fprintf('broadcast port of: %s\n\n', port_bcast); |
---|
[1915] | 374 | |
---|
[4375] | 375 | temp = input('Broadcast Port: ', 's'); |
---|
[1915] | 376 | if(isempty(temp)) |
---|
| 377 | temp = port_bcast; |
---|
[4375] | 378 | fprintf(' defaulting to %s\n', temp); |
---|
[1915] | 379 | else |
---|
[4375] | 380 | fprintf(' setting to %s\n', temp); |
---|
[1915] | 381 | end |
---|
| 382 | |
---|
[4375] | 383 | writeKeys = {'network', '', 'bcast_port', temp}; |
---|
| 384 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1915] | 385 | |
---|
| 386 | |
---|
| 387 | fprintf('\n\n') |
---|
| 388 | fprintf('------------------------------------------------------------\n') |
---|
| 389 | %%%%%%%% Transport Setup %%%%%%%% |
---|
[2855] | 390 | I_JAVA = 1; |
---|
| 391 | I_WL_MEX_UDP = 2; |
---|
[1915] | 392 | |
---|
[2149] | 393 | TRANS_NAME_LONG{I_JAVA} = 'Java UDP'; |
---|
| 394 | TRANS_NAME_SHORT{I_JAVA} = 'java'; |
---|
| 395 | TRANS_NAME_LONG{I_WL_MEX_UDP} = 'WARPLab Mex UDP'; |
---|
| 396 | TRANS_NAME_SHORT{I_WL_MEX_UDP} = 'wl_mex_udp'; |
---|
[1915] | 397 | |
---|
[2084] | 398 | TRANS_AVAIL(I_JAVA) = true; |
---|
[2149] | 399 | TRANS_AVAIL(I_WL_MEX_UDP) = false; |
---|
[1915] | 400 | |
---|
[2149] | 401 | fprintf('Select from the following available transports:\n') |
---|
| 402 | |
---|
[4699] | 403 | try |
---|
[4818] | 404 | version = wl_mex_udp_transport('version'); |
---|
| 405 | version = sscanf(version, '%d.%d.%d%c'); |
---|
| 406 | version_req = sscanf(REQUIRED_MEX_VERSION, '%d.%d.%d%c'); |
---|
| 407 | |
---|
| 408 | % Version must match required version |
---|
| 409 | if(version(1) == version_req(1) && version(2) == version_req(2) && version(3) == version_req(3) && version(4) >= version_req(4)) |
---|
[4699] | 410 | TRANS_AVAIL(I_WL_MEX_UDP) = true; |
---|
| 411 | else |
---|
| 412 | [major, minor, rev] = wl_ver(); |
---|
| 413 | wl_version = sprintf('v%d.%d.%d', major, minor, rev); |
---|
| 414 | version = wl_mex_udp_transport('version'); |
---|
[4818] | 415 | version_req = REQUIRED_MEX_VERSION; |
---|
[4699] | 416 | fprintf('\nERROR: MEX transport version mismatch: \n') |
---|
| 417 | fprintf('ERROR: WARPLab %s requires MEX transport version %s.\n', wl_version, version_req ) |
---|
| 418 | fprintf('ERROR: Current complied version is %s. \n', version) |
---|
| 419 | fprintf('ERROR: Please recompile to use the MEX transport:\n', version) |
---|
| 420 | fprintf('ERROR: http://warpproject.org/trac/wiki/WARPLab/MEX \n\n') |
---|
[2084] | 421 | end |
---|
[4699] | 422 | |
---|
| 423 | catch me |
---|
| 424 | fprintf(' For better transport performance, please setup the WARPLab Mex UDP transport: \n') |
---|
| 425 | fprintf(' http://warpproject.org/trac/wiki/WARPLab/MEX \n') |
---|
| 426 | TRANS_AVAIL(I_WL_MEX_UDP) = false; |
---|
[2084] | 427 | end |
---|
| 428 | |
---|
[4375] | 429 | % Set MEX to be the default transport if available |
---|
[4416] | 430 | if(isempty(transport)) |
---|
| 431 | if(TRANS_AVAIL(I_WL_MEX_UDP)) |
---|
| 432 | transport = 'wl_mex_udp'; |
---|
| 433 | else |
---|
| 434 | transport = 'java'; |
---|
| 435 | end |
---|
[4375] | 436 | end |
---|
| 437 | |
---|
| 438 | % Check if any transports are available |
---|
[1915] | 439 | if(any(TRANS_AVAIL)==0) |
---|
| 440 | error('no supported transports were found installed on your computer'); |
---|
| 441 | end |
---|
| 442 | |
---|
[2175] | 443 | defaultSel = 1; |
---|
| 444 | sel = 1; |
---|
[1915] | 445 | for k = 1:length(TRANS_AVAIL) |
---|
| 446 | if(TRANS_AVAIL(k)) |
---|
[4375] | 447 | if(strcmp(TRANS_NAME_SHORT{k}, transport)) |
---|
[1915] | 448 | defaultSel = sel; |
---|
[4375] | 449 | fprintf('[%d] (default) %s\n', sel, TRANS_NAME_LONG{k}) |
---|
[1915] | 450 | else |
---|
[4375] | 451 | fprintf('[%d] %s\n', sel, TRANS_NAME_LONG{k}) |
---|
[1915] | 452 | end |
---|
| 453 | selectionToIndex(sel) = k; |
---|
[4375] | 454 | sel = sel + 1; |
---|
[1915] | 455 | end |
---|
| 456 | end |
---|
| 457 | |
---|
| 458 | temp = input('Selection: '); |
---|
| 459 | if(isempty(temp)) |
---|
[2175] | 460 | temp = defaultSel; |
---|
[1915] | 461 | end |
---|
| 462 | |
---|
| 463 | if(temp>(sel-1)) |
---|
| 464 | error('invalid selection') |
---|
| 465 | end |
---|
| 466 | |
---|
| 467 | transport = TRANS_NAME_SHORT{selectionToIndex(temp)}; |
---|
| 468 | |
---|
[4375] | 469 | fprintf(' setting to %s\n', transport); |
---|
[1915] | 470 | |
---|
[4375] | 471 | writeKeys = {'network', '', 'transport', transport}; |
---|
| 472 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1915] | 473 | |
---|
[1997] | 474 | fprintf('\n\n') |
---|
[1915] | 475 | fprintf('------------------------------------------------------------\n') |
---|
[1997] | 476 | %%%%%%%% Transport Setup %%%%%%%% |
---|
[4375] | 477 | PAYLOAD_SIZE{1} = '1470'; |
---|
| 478 | PAYLOAD_SIZE{2} = '5000'; |
---|
| 479 | PAYLOAD_SIZE{3} = '8966'; |
---|
[1915] | 480 | |
---|
[4375] | 481 | fprintf('Select from the following maximum transport payload size:\n') |
---|
[1915] | 482 | |
---|
[4375] | 483 | sel = 1; |
---|
| 484 | for k = 1:3 |
---|
[1915] | 485 | |
---|
[4375] | 486 | % Check if this exercises jumbo mode |
---|
| 487 | if (str2num(PAYLOAD_SIZE{k}) <= 1470) |
---|
| 488 | jumbo = '(non-jumbo)'; |
---|
| 489 | else |
---|
| 490 | jumbo = '(jumbo)'; |
---|
| 491 | end |
---|
| 492 | |
---|
| 493 | if(strcmp(PAYLOAD_SIZE{k}, max_transport_payload_size)) |
---|
| 494 | defaultSel = sel; |
---|
| 495 | fprintf('[%d] (default) %s bytes %s\n', sel, PAYLOAD_SIZE{k}, jumbo) |
---|
| 496 | else |
---|
| 497 | fprintf('[%d] %s bytes %s\n', sel, PAYLOAD_SIZE{k}, jumbo) |
---|
| 498 | end |
---|
| 499 | selectionToIndex(sel) = k; |
---|
| 500 | sel = sel + 1; |
---|
[1997] | 501 | end |
---|
[1915] | 502 | |
---|
[4375] | 503 | fprintf('\nDepending on your host NIC and network setup you may be able to\n') |
---|
| 504 | fprintf('use larger packets to increase your transport performance.\n\n') |
---|
| 505 | |
---|
[1997] | 506 | temp = input('Selection: '); |
---|
[4375] | 507 | |
---|
[1997] | 508 | if(isempty(temp)) |
---|
| 509 | temp = defaultSel; |
---|
| 510 | end |
---|
[1915] | 511 | |
---|
[4375] | 512 | if(temp > (sel - 1)) |
---|
[1997] | 513 | error('invalid selection') |
---|
| 514 | end |
---|
| 515 | |
---|
[4375] | 516 | max_transport_payload_size = PAYLOAD_SIZE{selectionToIndex(temp)}; |
---|
[1997] | 517 | |
---|
[4375] | 518 | fprintf(' setting maximum transport payload size to %s bytes\n', max_transport_payload_size); |
---|
[1997] | 519 | |
---|
[4375] | 520 | writeKeys = {'network', '', 'max_transport_payload_size', max_transport_payload_size}; |
---|
| 521 | inifile(configFile, 'write', writeKeys, 'tabbed') |
---|
[1997] | 522 | |
---|
| 523 | |
---|
| 524 | fprintf('\n\n') |
---|
| 525 | fprintf('------------------------------------------------------------\n') |
---|
[1915] | 526 | fprintf('\n\nSetup Complete\nwl_ver():\n'); |
---|
| 527 | wl_ver() |
---|
[4975] | 528 | fprintf('\n') |
---|
[1915] | 529 | |
---|
[4974] | 530 | % Catch 64-bit support issues in Matlab during wl_setup |
---|
| 531 | try |
---|
| 532 | temp_1 = uint64(0); |
---|
| 533 | temp_2 = uint64(0); |
---|
| 534 | result = temp_1 + temp_2; |
---|
| 535 | catch |
---|
[4975] | 536 | warning('Matlab version does not support uint64 arithmetic. Please use Matlab R2011a or later.'); |
---|
[4974] | 537 | end |
---|
| 538 | |
---|
[1915] | 539 | end |
---|