|
|
This is the results
DEBUG: [Passes = 5000] 311191.953 Byte/s
RESULT: 303.90 KB/sec
DEBUG: [Passes = 5000] 734956.927 Byte/s
RESULT: 717.73 KB/sec
DEBUG: [Passes = 5000] 391962.053 Byte/s
RESULT: 382.78 KB/sec
DEBUG: [Passes = 5000] 274082.350 Byte/s
RESULT: 267.66 KB/sec
DEBUG: [Passes = 5000] 281520.063 Byte/s
RESULT: 274.92 KB/sec
|
|
|
|
|
saiyuk6=7 wrote: double seconds = ((double)(iValue - iBaseTime) * dbFreq);
To get seconds, shouldn't you be dividing by the timer's frequency?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I've updated the code somewhat now, i have taken your advice by dividing the timers freq
i've changed how the bps is calculated as well
double bps = (double)((ulSize * iPasses) / tm.Seconds());
i've multiplied the Size of the Buffer by the number of passes that runs in the for loop
results are
<br />
DEBUG: 1074556249.047 Byte/s<br />
MEMSET: 0.00/sec 0.98/ms 1.00 GB/sec<br />
RESULT: 6.91/sec 6905.56/ms 72.41 MB/sec<br />
class CTimer {
public:
CTimer() {
m_TimeStart.QuadPart = 0;
m_TimeStop.QuadPart = 0;
QueryPerformanceFrequency(&m_Frequency);
}
void Start(void) {
QueryPerformanceCounter(&m_TimeStart);
}
void Stop(void) {
QueryPerformanceCounter(&m_TimeStop);
}
double Seconds() const {
return (double)(m_TimeStop.QuadPart - m_TimeStart.QuadPart) / (double)m_Frequency.QuadPart;;
}
double Milliseconds() const {
return Seconds() * 1000.0;
}
private:
double m_dbFreq;
LARGE_INTEGER m_Frequency;
LARGE_INTEGER m_TimeStart;
LARGE_INTEGER m_TimeStop;
};
#define MUL_BYTES 1024.0
#define MUL_KB (MUL_BYTES*1024.0)
#define MUL_MB (MUL_KB*1024.0)
#define MUL_GB (MUL_MB*1024.0)
std::string BPStoString(double dbPerSec)
{
char *pTemp[] = {
"Bytes", "KB", "MB",
"GB", "TB", "PB",
"EB", "ZB", "YB"
};
char szTemp[30];
int i = 0;
while (dbPerSec >= 0.9 * MUL_BYTES) {
dbPerSec /= MUL_BYTES;
i++;
}
sprintf(szTemp, "%5.2f %s/sec", dbPerSec, pTemp[i]);
return std::string(szTemp);
}
void Benchmark_MD5(void)
{
CTimer tm;
tm.Start();
unsigned long ulSize = MUL_KB;
unsigned char *bzBuffer = new unsigned char[ulSize];
if (bzBuffer != NULL) {
memset(bzBuffer, 0, ulSize);
tm.Stop();
<code>double bps = (double)((ulSize * 1) / tm.Seconds());</code>
printf("DEBUG: %5.3f Byte/s\n", bps);
printf("MEMSET: %5.2f/sec %5.2f/ms %s\n", tm.Seconds(), tm.Milliseconds(),BPStoString(bps).c_str());
}
tm.Start();
MD5_CTX md5;
int iPasses = 500;
for (int i = 0; i < iPasses; i++) {
MD5Init(&md5);
MD5Update(&md5, bzBuffer, ulSize);
MD5Final(&md5);
}
tm.Stop();
<code> double bps = (double)((ulSize * iPasses) / tm.Seconds());</code>
printf("RESULT: %5.2f/sec %5.2f/ms %s\n", tm.Seconds(), tm.Milliseconds(),BPStoString(bps).c_str());
delete bzBuffer;
}
modified on Monday, July 19, 2010 8:57 PM
|
|
|
|
|
saiyuk6=7 wrote: unsigned char *bzBuffer = new unsigned char[ulSize];
Why not:
unsigned char bzBuffer[MUL_KB];
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
well i've tried doing that but i get this error
bm.cpp
bm.cpp(40) : error C2057: expected constant expression
bm.cpp(40) : error C2466: cannot allocate an array of constant size 0
bm.cpp(40) : error C2133: 'bzBuffer' : unknown size
Well i had started to allocate memory for it because later on i was going to start using a hash driver that i was going to make that would provide me with several hash algo's,.... example
there might be errors below, but its just a example of what i had planned to do
unsigned char *bzBuffer;
for (int i = HT_MD5; i < (HT_WHIRLPOOL + 1); i++) {
hash.Init(i);
bzBuffer = new unsigned char[hash.DigestSize()];
if (bzBuffer == NULL) {
return 0;
}
hash.Update(hashTest[i].buffer, hashTest[i].length);
hash.Final(bzBuffer);
for (int h = 0; h < hash.DigestSize(); h++)
printf("%02.2%", bzBuffer[i]);
delete bzBuffer;
}
modified on Tuesday, July 20, 2010 12:28 PM
|
|
|
|
|
int _cdecl main(int argc, char *argv[])
{
OutputDebugString("Hello World");
}
When I compile and debug with Target = Win32 I get:
Hello World
(plus a lot of 'instlsp.exe': Loaded 'C:\WINDOWS\SysWOW64\....dll', Cannot find or open the PDB file)
When I compile and debug with Target = x64 I get nothing
It runs but the output is filtered somewhat.
I tried this
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Debug Print Filter]
"DEFAULT"=dword:0000000f
And also 0xFFFFFFFF
No success even after reboot.
I feel like I am stuck in chapter 1 of the Kernighan and Ritchie C book.
I am using Visual C++ Express under Windows XP Pro x64
Is this just a bad day?
Going to the zoo now. Perhaps the monkeys will have a clue, I should take a couple of typewriters with me.
|
|
|
|
|
Pascal Ganaye wrote: Going to the zoo now. Perhaps the monkeys will have a clue,
Sorry, but I have no clue.
Seriously though, I'm on Windows 7 x64 and it works just right for me. Which platform are you on?
It's time for a new sig. Seriously.
|
|
|
|
|
Hi
I am developing a application
knowing the size of downloaded data from the net
for a month for a PC.
How to do this?
|
|
|
|
|
You need to be more specific. What 'data'? Where is it stored? Is it part of your application?
If you have a more intelligent router connecting you to the Internet then you could use SNMP to pull statistics from the router.
Sorry but while you are so vague it is impossible to advise further.
P.S. this is more a general IT question.
Alan
|
|
|
|
|
|
I tried compiling my application in 64bit, during compilation I got errors. Cause my application uses UNICODE, does 64bit lack UNICODE support???
|
|
|
|
|
Fareed Rizkalla wrote: Cause my application uses UNICODE
The sentence is not clear.
Do you mean "because I'm using Unicode strings" or "because it seems the UNICODE preprocessor symbol is not defined"?
In the second case, just look in the compiler options if the Unicode support is activated ad if UNICODE and _UNICODE are in the defines symbol specifications.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
It would help if you showed the relevant lines of code and the exact error messages produced by the compiler.
It's time for a new signature.
|
|
|
|
|
I am stuck actually, im trying to write a md5 / blowfish function
im not sure if i am correctly converting the MD5[16] buffer into a unsigned long[4]
this doesnt really make too much sense too me
typedef struct _tag2Long {
unsigned long _1;
unsigned long _2;
unsigned long _3;
unsigned long _4;
} _2LONG;
void SignBuffer(unsigned char *pbzKey, unsigned char *pbzBuffer,
unsigned int iSize, unsigned long pSignature[4])
{
MD5_CTX md5;
BLOWFISH_CTX bf;
MD5Init(&md5);
MD5Update(&md5, pbzBuffer, iSize);
MD5Final(&md5);
_2LONG *tl = (_2LONG*) md5.digest;
printf("BLE 1\t\t %x %x %x %x\n", tl->_1, tl->_2, tl->_3, tl->_4);
Blowfish_Init(&bf, pbzKey, 16);
Blowfish_Encrypt(&bf, &tl->_1, &tl->_2);
Blowfish_Encrypt(&bf, &tl->_3, &tl->_4);
pSignature[0] = tl->_1;
pSignature[1] = tl->_2;
pSignature[2] = tl->_3;
pSignature[3] = tl->_4;
printf("BLE 2\t\t %x %x %x %x\n", pSignature[0], pSignature[1],
pSignature[2], pSignature[3]);
}
bool VerifyBuffer(unsigned char *pbzKey, unsigned char *pSignature,
unsigned int iSize, unsigned long pBuffer[4])
{
BLOWFISH_CTX bf;
MD5_CTX md5;
bool bResult = false;
printf("BLD 1\t\t %x %x %x %x\n", pBuffer[0], pBuffer[1],
pBuffer[2], pBuffer[3]);
Blowfish_Init(&bf, pbzKey, 16);
Blowfish_Decrypt(&bf, &pBuffer[0], &pBuffer[1]);
Blowfish_Decrypt(&bf, &pBuffer[2], &pBuffer[3]);
printf("BLD 2\t\t %x %x %x %x\n", pBuffer[0], pBuffer[1],
pBuffer[2], pBuffer[3]);
MD5Init(&md5);
MD5Update(&md5, pSignature, iSize);
MD5Final(&md5);
_2LONG *tl = (_2LONG*) md5.digest;
if (tl->_1 == pBuffer[0] && tl->_2 == pBuffer[1] &&
tl->_3 == pBuffer[2] && tl->_4 == pBuffer[4])
bResult = true;
return bResult;
}
void main(void)
{
unsigned char bszBuffer[2] = {'A', 'B'};
unsigned long ulSig[4];
SignBuffer((unsigned char*)"key", bszBuffer, 2, ulSig);
printf("\n");
if (VerifyBuffer((unsigned char*)"key", bszBuffer, 2, ulSig))
printf("\nok");
else printf("\nerr");
}
and this is the output of them
BLE 1 b0c66fb8 733df651 4c2d26de a9a0e334
BLE 2 f12b0ed9 782fae18 a87960ac f37b342e
BLD 1 f12b0ed9 782fae18 a87960ac f37b342e
BLD 2 dc95818a 65685d43 8d7d54b9 8827b217
err
modified on Friday, July 16, 2010 3:32 PM
|
|
|
|
|
the conversion looks fine.
but doesn't Blowfish use 64-bit (8-byte) blocks ?
so this Blowfish_Encrypt(&bf, &tl->_1, &tl->_2); will encrypt the 8 bytes starting at tl->_1 ? since _1 is only four bytes, it's going to run over into _2.
so, you're doing BF(_1 + _2) -> _2 + _3.
or maybe not. i don't know what Blowfish_Encrypt looks like.
|
|
|
|
|
|
ah, ok. it's expecting 2 32-bit parts. i thought the params were input and output.
|
|
|
|
|
do you happen to know how i can fix it? i am lost
|
|
|
|
|
you're doing this, right:
Sign:
Sig = BFE(MD5(data))
Verify:
X = BFD(Sig)
Sig2 = MD5(Sig)
Compare:
X == Sig2 ?
but shouldn't that bold line be Sig2 = MD5(data) ? the MD5 of the signature doesn't get you anything.
|
|
|
|
|
i fixed it, thank you very much for your help, i noticed
if (tl->_1 == pBuffer[0] && tl->_2 == pBuffer[1] &&
tl->_3 == pBuffer[2] && tl->_4 == pBuffer[4])
bResult = true;
pBuffer[4] should of been pBuffer[3] i was going out of range of the array which didnt exist
here is the updated code
int _ustrlen(unsigned char *pbz)
{
const unsigned char *ptr;
for (ptr = pbz; *ptr; ++ptr);
return (ptr - pbz);
}
void SignBuffer(unsigned char *pbzKey, unsigned char *pbzBuffer,
unsigned int iSize, unsigned long *pSignature)
{
MD5_CTX md5, md5key;
BLOWFISH_CTX bf;
MD5Init(&md5);
MD5Update(&md5, pbzBuffer, iSize);
MD5Final(&md5);
_2LONG *tl = (_2LONG*) md5.digest;
printf("BLE 1\t\t %x %x %x %x\n", tl->_1, tl->_2, tl->_3, tl->_4);
MD5Init(&md5key);
MD5Update(&md5key, pbzKey, _ustrlen(pbzKey));
MD5Final(&md5key);
Blowfish_Init(&bf, md5key.digest, 16);
Blowfish_Encrypt(&bf, &tl->_1, &tl->_2);
Blowfish_Encrypt(&bf, &tl->_3, &tl->_4);
pSignature[0] = tl->_1;
pSignature[1] = tl->_2;
pSignature[2] = tl->_3;
pSignature[3] = tl->_4;
printf("BLE 2\t\t %x %x %x %x\n", pSignature[0], pSignature[1],
pSignature[2], pSignature[3]);
}
bool VerifyBuffer(unsigned char *pbzKey, unsigned char *pSignature,
unsigned int iSize, unsigned long *pBuffer)
{
BLOWFISH_CTX bf;
MD5_CTX md5, md5key;
bool bResult = false;
printf("BLD 1\t\t %x %x %x %x\n", pBuffer[0], pBuffer[1],
pBuffer[2], pBuffer[3]);
MD5Init(&md5key);
MD5Update(&md5key, pbzKey, _ustrlen(pbzKey));
MD5Final(&md5key);
Blowfish_Init(&bf, md5key.digest, 16);
Blowfish_Decrypt(&bf, &pBuffer[0], &pBuffer[1]);
Blowfish_Decrypt(&bf, &pBuffer[2], &pBuffer[3]);
printf("BLD 2\t\t %x %x %x %x\n", pBuffer[0], pBuffer[1],
pBuffer[2], pBuffer[3]);
MD5Init(&md5);
MD5Update(&md5, pSignature, iSize);
MD5Final(&md5);
_2LONG *tl = (_2LONG*) md5.digest;
printf("BLD 3\t\t %x %x %x %x\n", tl->_1, tl->_2, tl->_3, tl->_4);
if (tl->_1 == pBuffer[0] && tl->_2 == pBuffer[1] &&
tl->_3 == pBuffer[2] && tl->_4 == pBuffer[3])
bResult = true;
return bResult;
}
void main(void)
{
unsigned char bszBuffer[2] = {'A', 'B'};
unsigned long ulSig[4];
SignBuffer((unsigned char*)"key", bszBuffer, 2, ulSig);
printf("\n");
if (VerifyBuffer((unsigned char*)"key", bszBuffer, 2, ulSig))
printf("\nok");
else printf("\nerr");
}
I had made _ustrlen because i got tired of using casting for (unsigned char*), unless there is a different way?
|
|
|
|
|
Hello!
It might only be me but it is not obvious (to me) where you are trying to do this conversion you are talking about, you should at least highlight the part of interest in your code so people who want to help don't have to study your whole program trying to grasp the way you think.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
BLE 2 f12b0ed9 782fae18 a87960ac f37b342e
is passed into VerifyBuffer, but when it is decrypted it doesnt match BLE 1 b0c66fb8 733df651 4c2d26de a9a0e334 when i pass a MD5 comparision from unsigned char *pSignature
hope that makes sense? it seems to lose data some how, not sure
|
|
|
|
|
Hi:
I am new to FIX. I am using quickfix engine in c++ to create a initiator. The host is saying that they cannot see username and password in tag 553 or 554, that is why logon is not happening. I have gone through all documentation of QuickFix and also several other examples of it but could not find any solution. The following is the settings file parameters:
If anyone has worked on QuickFix in c++, I would really appreciate if someone can help me?
tradeclient.cfg
-----------------------
<br />
#default settings for sessions<br />
[DEFAULT]<br />
ConnectionType=initiator<br />
LogonTimeout=30<br />
ReconnectInterval=30<br />
ResetOnLogon=Y<br />
<br />
<br />
#INET Session<br />
[SESSION]<br />
BeginString=FIX.4.2<br />
SenderCompID=XXX<br />
SenderSubID=1<br />
TargetCompID=XXX<br />
StartDay=sunday<br />
EndDay=friday<br />
StartTime=07:00:00<br />
EndTime=21:00:00<br />
HeartBtInt=30<br />
CheckLatency=Y<br />
MaxLatency=240<br />
SocketConnectPort=XXX<br />
SocketConnectHost=XXXXX<br />
EncryptMethod=0<br />
UserName=XXX<br />
Password=XXXX<br />
#SessionQualifier=INET<br />
UseDataDictionary=Y<br />
DataDictionary=C:\Users\asarkar\Financial Programs\QuickFix\quickfix\spec\FIX42.xml<br />
FileStorePath=C:\Users\asarkar\Documents\Visual Studio 2010\Projects\FIX_TradeClient\Debug\<br />
|
|
|
|
|
from distant memory, no, you cant do it like that ...
what you need to to is handle an Admin callback/message, and if that message is a logon message, you do a
some_message.setField(new Username("*****"));
some_message.setField(new Password("*****"));
thats as much as I remember - I did a quick google, and somewhere I found for the java version that was roughly the same
'g'
|
|
|
|
|