2 * Copyright (c) 2008 Microsoft Corporation. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
35 #include "iba/ib_types.h"
\r
36 #include "iba/ibat.h"
\r
39 inline LONGLONG GetElapsedTime()
\r
41 LARGE_INTEGER elapsed;
\r
42 QueryPerformanceCounter(&elapsed);
\r
43 return elapsed.QuadPart;
\r
46 inline LONGLONG GetFrequency()
\r
48 LARGE_INTEGER Frequency;
\r
49 QueryPerformanceFrequency(&Frequency);
\r
50 return Frequency.QuadPart;
\r
53 int PrintUsage( int argc, char *argv[] )
\r
55 UNREFERENCED_PARAMETER( argc );
\r
56 printf( "%s <source IP> <destination IP>\n", argv[0] );
\r
61 int __cdecl main(int argc, char *argv[])
\r
64 return PrintUsage( argc, argv );
\r
66 struct sockaddr_in srcAddr = {0};
\r
67 srcAddr.sin_family = AF_INET;
\r
68 srcAddr.sin_addr.s_addr = inet_addr( argv[1] );
\r
70 struct sockaddr_in destAddr = {0};
\r
71 destAddr.sin_family = AF_INET;
\r
72 destAddr.sin_addr.s_addr = inet_addr( argv[2] );
\r
75 HRESULT hr = IBAT::Resolve(
\r
76 (struct sockaddr*)&srcAddr,
\r
77 (struct sockaddr*)&destAddr,
\r
78 (IBAT_PATH_BLOB*)&path
\r
82 printf( "Resolve returned %08x.\n", hr );
\r
89 "source GID %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n"
\r
90 "destination GID %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",
\r
92 path.sgid.raw[0], path.sgid.raw[1], path.sgid.raw[2], path.sgid.raw[3],
\r
93 path.sgid.raw[4], path.sgid.raw[5], path.sgid.raw[6], path.sgid.raw[7],
\r
94 path.sgid.raw[8], path.sgid.raw[9], path.sgid.raw[10], path.sgid.raw[11],
\r
95 path.sgid.raw[12], path.sgid.raw[13], path.sgid.raw[14], path.sgid.raw[15],
\r
96 path.dgid.raw[0], path.dgid.raw[1], path.dgid.raw[2], path.dgid.raw[3],
\r
97 path.dgid.raw[4], path.dgid.raw[5], path.dgid.raw[6], path.dgid.raw[7],
\r
98 path.dgid.raw[8], path.dgid.raw[9], path.dgid.raw[10], path.dgid.raw[11],
\r
99 path.dgid.raw[12], path.dgid.raw[13], path.dgid.raw[14], path.dgid.raw[15]
\r
102 LONGLONG StartTime = GetElapsedTime();
\r
103 for( int i = 0; i < 2000; i++ )
\r
105 HRESULT hr = IBAT::Resolve(
\r
106 (struct sockaddr*)&srcAddr,
\r
107 (struct sockaddr*)&destAddr,
\r
108 (IBAT_PATH_BLOB*)&path
\r
112 printf( "Resolve returned %08x.\n", hr );
\r
116 LONGLONG RunTime = GetElapsedTime() - StartTime;
\r
117 double Rate = 2000.0 / ((double)RunTime / (double)GetFrequency());
\r
118 printf( "%7.2f lookups per second\n", Rate );
\r