forked from zhaopy10/CoMP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packageReceiver.hpp
54 lines (44 loc) · 1.25 KB
/
packageReceiver.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef PACKAGERECEIVER
#define PACKAGERECEIVER
#include <iostream>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h> /* for fprintf */
#include <string.h> /* for memcpy */
#include <stdlib.h>
#include "Symbols.hpp"
#include <vector>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <pthread.h>
#include <cassert>
#include <unistd.h>
#include <chrono>
class PackageReceiver
{
public:
static const int OFDM_FRAME_LEN = OFDM_CA_NUM + OFDM_PREFIX_LEN;
// int for: frame_id, subframe_id, cell_id, ant_id
// float for: I/Q samples
static const int package_length = sizeof(int) * 4 + sizeof(float) * OFDM_FRAME_LEN * 2;
static const int data_offset = sizeof(int) * 4;
static const int MAX_FRAME_ID = 1e4;
public:
PackageReceiver();
PackageReceiver(int* in_pipe);
~PackageReceiver();
pthread_t startRecv(char* in_buffer, int* in_buffer_status, int in_buffer_frame_num, int in_buffer_length);
static void* loopRecv(void *context);
private:
struct sockaddr_in servaddr_; /* server address */
int socket_;
char* buffer_;
int* buffer_status_;
int buffer_length_;
int buffer_frame_num_;
int* pipe_; // write at port 1
};
#endif