Exemplo n.º 1
0
int TestMod11B(PDOT11_MOD_ARGS pArgs)
{
    MDL                                 Mdl;
    PACKET_BASE                         Packet;
    DOT11B_PLCP_TXVECTOR                Dot11BTxVector;
    Dot11BTxVector.PreambleType         = DOT11B_PLCP_IS_LONG_PREAMBLE;
    Dot11BTxVector.ModSelect            = DOT11B_PLCP_IS_CCK;

    if (!Dot11BRate_KbpsValid(pArgs->nBitRate))
    {
        printf("Data rate %d kbps is not supported by 802.11b mode\n", pArgs->nBitRate);
        return -1;
    }
    Dot11BTxVector.DateRate = Dot11BDataRate_Kbps2Code(pArgs->nBitRate);

    // Measure modulation speed
    const int RUN_TIMES = 100;
	ULONGLONG ts1 = SoraGetCPUTimestamp ( &tsinfo );
    for (int ii = 0; ii < RUN_TIMES; ii++)
    {
        if (PreparePacket(pArgs->pcInFileName, &Mdl, &Packet, DataBuffer, (PUCHAR)SymbolBuffer, SAMPLE_BUFFER_SIZE) < 0)
            return -1;
        // Note: BB11BPMDPacketGenSignal() will modify Packet.pMdl and Packet.pReserved (data crc)
        //   so if run multiple times, please reload these data before calling it.
        BB11BPMDPacketGenSignal(&Packet, &Dot11BTxVector, (PUCHAR)TempBuffer, sizeof(TempBuffer)/sizeof(COMPLEX8));
    }
	ULONGLONG ts2 = SoraGetCPUTimestamp ( &tsinfo );

    printf("Signal data rate:    %d kbps\n", Dot11BDataRate_Code2Kbps(Dot11BTxVector.DateRate));
    printf("Signal packet size:  %d\n", Packet.PacketSize);
    printf("Signal encoded size: %d\n", Packet.Reserved3);
    printf("Time cost average:   %.3f us \n", SoraTimeElapsed (ts2-ts1, &tsinfo) * 1.0 / 1000 / RUN_TIMES);

    FILE* pOut = NULL;
#pragma warning (push)
#pragma warning (disable:4996)
    pOut = fopen(pArgs->pcOutFileName, "w+b");
#pragma warning (pop)
    if (!pOut)
    {
        printf("Cannot create output file.\n");
        return -1;
    }

    fwrite(Packet.pReserved, Packet.Reserved3, 1, pOut);
    fclose(pOut);

    return 0;
}
Exemplo n.º 2
0
int Test11B_FB_Demod()
{
	printf ( "Demodulate 11b with Fine Brick!\n" );


	ISource * ssrc = CreateDemodGraph ();

//	int bCnt = LoadSoraDumpFile ( "c:\\11b-1M-1.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\noise.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
	int bCnt = LoadSoraDumpFile ( "d:\\test.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );


	printf ( "Load sample %d\n", bCnt );



	ULONGLONG ts1 = SoraGetCPUTimestamp ( &tsinfo );
	for ( int i=0; i<100; i++) {
		
		InitFBDemodContext ((COMPLEX16*)InputBuf, (bCnt)*sizeof(COMPLEX16), OutputBuf, OUT_BUF_SIZE);

		ssrc->Reset ();
		if ( BB11bDemodCtx.CF_Error::error_code() == E_ERROR_SUCCESS ) {
			FB_11B_DemodBuffer (ssrc);
		} else {
			printf ( "Reset error!\n" );
		}
	}	
	ULONGLONG ts2 = SoraGetCPUTimestamp ( &tsinfo );
	
	ulong& err = BB11bDemodCtx.CF_Error::error_code();
	if (  err == E_ERROR_FRAME_OK ) {	
		printf ( "one good frame find!\n" );
	} else {
		printf ( "error code: %08x \n", err );
	}


	printf("Signal data rate:	 %dk\n",BB11bDemodCtx.CF_11bRxVector::data_rate_kbps() ); 
	printf("Bytes decoded: %d\n",   	BB11bDemodCtx.CF_11bRxVector::frame_length() );
    printf("Time cost average:   %.3fus \n", SoraTimeElapsed (ts2-ts1, &tsinfo) * 1.0 / 1000 / 100 );

/*
	if ( pArgs->pcOutFileName != NULL ) {
		FILE* pOut = NULL;
#pragma warning (push)
#pragma warning (disable:4996)
		pOut = fopen(pArgs->pcOutFileName, "w+b");
#pragma warning (pop)
		if (!pOut)
		{
			printf("Cannot create output file.\n");
			return -1;
		}

		fwrite(	OutputBuf, 
				fb11bDemodCtx.CF_MPDU_Info::frame_len(), 
				1, pOut);
		fclose(pOut);
	}
*/
	IReferenceCounting::Release (ssrc);

	return 0;
}
Exemplo n.º 3
0
int Test11A_FB_Demod()
{
	printf ( "Demodulate 11a with Fine Brick!\n" );

	// test usin/ucos

//	int bCnt = LoadSoraDumpFile ( "c:\\11b-1M-1.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\noise.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\test-real.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
//	int bCnt = LoadSoraDumpFile ( "d:\\test-ideal.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );
	bCnt = LoadSoraDumpFile ( "c:\\a48-40.dmp", (COMPLEX16*)InputBuf, IN_BUF_SIZE );



	printf ( "Load sample %d\n", bCnt );


	BB11aDemodCtx.Init ( (COMPLEX16*)InputBuf, (bCnt)*sizeof(COMPLEX16), OutputBuf, OUT_BUF_SIZE);
	
	CreateDemodGraph11a (ssrc, svit);
	fRunning = true;
	ULONGLONG tts1 = SoraGetCPUTimestamp ( &tsinfo );	
	
	thread2 = AllocStartThread ( ViterbiThread, NULL );
	thread1 = AllocStartThread ( RxThread, NULL );

	while ( fRunning ) {
		Sleep (1);
	}

	StopFreeThread (thread1 );
	StopFreeThread (thread2 );
	
//	printf("Signal data rate:	 %dk\n",BB11bDemodCtx.CF_11bRxVector::data_rate_kbps() ); 
//	printf("Bytes decoded: %d\n",   	BB11bDemodCtx.CF_11bRxVector::frame_length() );
    printf("Time cost average:   %.3fus \n", SoraTimeElapsed (tts2-tts1, &tsinfo) * 1.0 / 1000 / (TEST_NUM-1));
	printf ( "Total symbol %d!\n", BB11aDemodCtx.CF_11aRxVector::total_symbols() );


/*
	if ( pArgs->pcOutFileName != NULL ) {
		FILE* pOut = NULL;
#pragma warning (push)
#pragma warning (disable:4996)
		pOut = fopen(pArgs->pcOutFileName, "w+b");
#pragma warning (pop)
		if (!pOut)
		{
			printf("Cannot create output file.\n");
			return -1;
		}

		fwrite(	OutputBuf, 
				fb11bDemodCtx.CF_MPDU_Info::frame_len(), 
				1, pOut);
		fclose(pOut);
	}
*/

	IReferenceCounting::Release (ssrc);

	return 0;
}
Exemplo n.º 4
0
int __cdecl main(int argc, char **argv) {

  // Initialize the global parameters
  params = &Globals;
  try_parse_args(params, argc, argv);


#ifdef SORA_PLATFORM
  // Start Sora HW
  if (Globals.inType == TY_SDR || Globals.outType == TY_SDR)
  {
#ifdef BLADE_RF
	  if (BladeRF_RadioStart(params) < 0)
	  {
		  exit(1);
	  }
#endif

#ifdef SORA_RF
	  // SORA
	  RadioStart(&Globals);
	  if (Globals.inType == TY_SDR)
	  {
		  InitSoraRx(params);
	  }
	  if (Globals.outType == TY_SDR)
	  {
		  InitSoraTx(params);
	  }
#endif
  }


  // Start NDIS
  if (Globals.inType == TY_IP || Globals.outType == TY_IP)
  {
	HRESULT hResult = SoraUEnableGetTxPacket();
	assert(hResult == S_OK);
	Ndis_init(NULL);
  }

  // Start measuring time
  initMeasurementInfo(&(Globals.measurementInfo), Globals.latencyCDFSize);
#endif


  // Init
  initBufCtxBlock(&buf_ctx);
  initHeapCtxBlock(&heap_ctx, Globals.heapSize);

  wpl_global_init(Globals.heapSize);
  wpl_input_initialize();


#ifdef SORA_PLATFORM
  /////////////////////////////////////////////////////////////////////////////  
  // DV: Pass the User_Routines here

  int no_threads = wpl_set_up_threads(User_Routines);

  printf("Setting up threads...\n");

  ULONGLONG ttstart, ttend;

  printf("Starting %d threads...\n", no_threads);
  StartThreads(&ttstart, &ttend, &Globals.measurementInfo.tsinfo, no_threads, User_Routines);

  printf("Total input items (including EOF): %d (%d B), output items: %d (%d B)\n",
	  buf_ctx.total_in, buf_ctx.total_in*buf_ctx.size_in,
	  buf_ctx.total_out, buf_ctx.total_out*buf_ctx.size_out);
  printf("Time Elapsed: %ld us \n",
	  SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &Globals.measurementInfo.tsinfo));

  if (Globals.latencySampling > 0)
  {
	  printf("Min write latency: %ld, max write latency: %ld\n", (ulong)Globals.measurementInfo.minDiff, 
																 (ulong) Globals.measurementInfo.maxDiff);
	  printf("CDF: \n   ");
	  unsigned int i = 0;
	  while (i < Globals.measurementInfo.aDiffPtr)
	  {
		  printf("%ld ", Globals.measurementInfo.aDiff[i]);
		  if (i % 10 == 9)
		  {
			  printf("\n   ");
		  }
		  i++;
	  }
	  printf("\n");
  }


  // Free thread separators
  // NB: these are typically allocated in blink_set_up_threads
  ts_free();

#else
  int usec;
#ifdef __GNUC__
  struct timespec start, end;
  clock_gettime(CLOCK_MONOTONIC, &start);
  wpl_go();
  clock_gettime(CLOCK_MONOTONIC, &end);
  usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
#else
  clock_t start = clock(), diff;
  wpl_go();
  diff = clock() - start;
  usec = diff * 1000000 / CLOCKS_PER_SEC;
#endif
  printf("Time Elapsed: %d\n", usec);
#endif

  printf("Bytes copied: %ld\n", bytes_copied);

  wpl_output_finalize();

#ifdef SORA_PLATFORM
	// Stop Sora HW
	if (Globals.inType == TY_SDR || Globals.outType == TY_SDR)
	{
#ifdef BLADE_RF
		BladeRF_RadioStop(params);
#endif
#ifdef SORA_RF
		RadioStop(&Globals);
#endif
	}

	// Stop NDIS
	if (Globals.inType == TY_IP || Globals.outType == TY_IP)
	{
		if (hUplinkThread != NULL)
		{
			// Sora cleanup.
			SoraUThreadStop(hUplinkThread);
			SoraUThreadFree(hUplinkThread);
		}
		SoraUDisableGetTxPacket();
		// Winsock cleanup.
		closesocket(ConnectSocket);
		WSACleanup();
	}

#endif

  return 0;
}
Exemplo n.º 5
0
int __cdecl main(int argc, char **argv) 
{
	ULONGLONG ttstart, ttend;

	params_tx = &(params[0]);
	params_rx = &(params[1]);

	// Initialize the global parameters
	try_parse_args(params, argc, argv);


	printf("Setting up threads...\n");

	if (mac_type == 0)
	{
		// **** Single-thread MAC

		// Initialize various parameters
		init_mac_1thread();


		//SINGLE MODULE CODE: int no_threads = wpl_set_up_threads_tx(User_Routines);
		int no_threads = SetUpThreads_1t(User_Routines);
		StartThreads(&ttstart, &ttend, &(params_tx->measurementInfo.tsinfo), no_threads, User_Routines);

		printf("Time Elapsed: %ld us \n",
			SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &(params_tx->measurementInfo.tsinfo)));

		if (params_tx->latencySampling > 0)
		{
			printf("Min write latency: %ld, max write latency: %ld\n", (ulong)params_tx->measurementInfo.minDiff, (ulong)params_tx->measurementInfo.maxDiff);
			printf("CDF: \n   ");
			unsigned int i = 0;
			while (i < params_tx->measurementInfo.aDiffPtr)
			{
				printf("%ld ", params_tx->measurementInfo.aDiff[i]);
				if (i % 10 == 9)
				{
					printf("\n   ");
				}
				i++;
			}
			printf("\n");
		}
	}
	else
	{
		// **** TX/RX(2)-threaded MAC

		// Initialize various parameters
		init_mac_2threads();


		//SINGLE MODULE CODE: int no_threads = wpl_set_up_threads_tx(User_Routines);
		int no_threads = SetUpThreads_2t(User_Routines);
		StartThreads(&ttstart, &ttend, &(params_tx->measurementInfo.tsinfo), no_threads, User_Routines);

		printf("Time Elapsed: %ld us \n",
			SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &(params_tx->measurementInfo.tsinfo)));

	}

	// Free thread separators
	// NB: these are typically allocated in blink_set_up_threads
	ts_free();



	// Start Sora HW
	if (params_rx->inType == TY_SORA || params_tx->outType == TY_SORA)
	{
		RadioStop(*params_tx);
	}
	// Start NDIS
	if (params_tx->inType == TY_IP)
	{
		if (hUplinkThread != NULL)
		{
			// Sora cleanup.
			SoraUThreadStop(hUplinkThread);
			SoraUThreadFree(hUplinkThread);
		}
		SoraUDisableGetTxPacket();
		// Winsock cleanup.
		closesocket(ConnectSocket);
		WSACleanup();

	}

	if (params_rx->outType == TY_IP)
	{
		// To be implemented
		/*
		if (hUplinkThread != NULL)
		{
			// Sora cleanup.
			SoraUThreadStop(hUplinkThread);
			SoraUThreadFree(hUplinkThread);
		}
		SoraUDisableGetTxPacket();
		// Winsock cleanup.
		closesocket(ConnectSocket);
		WSACleanup();
		*/
	}


	return 0;
}