Skip to content

Commit

Permalink
Merge pull request #4 from maiconkist/marathon
Browse files Browse the repository at this point in the history
Marathon
  • Loading branch information
maiconkist authored Apr 4, 2019
2 parents e710fc5 + 4113834 commit 243fc08
Show file tree
Hide file tree
Showing 14 changed files with 539 additions and 124 deletions.
12 changes: 6 additions & 6 deletions app/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "hydra/hydra_uhd_interface.h"

/* Configure the TX radio */
hydra::uhd_hydra_sptr usrp = std::make_shared<hydra::device_loopback>();
hydra::uhd_hydra_sptr usrp = std::make_shared<hydra::device_uhd>();

void
signal_handler(int signum)
Expand All @@ -20,20 +20,20 @@ int main()
signal(SIGHUP, signal_handler);

/* TRANSMITTER */
double d_tx_centre_freq = 1.1e9;
double d_tx_centre_freq = 2.43e9;
double d_tx_samp_rate = 2e6;
unsigned int u_tx_fft_size = 1024;
unsigned int u_tx_fft_size = 2048;

/* RECEIVER */
double d_rx_centre_freq = 1.1e9;
double d_rx_centre_freq = 2.43e9 + 3e6;
double d_rx_samp_rate = 2e6;
unsigned int u_rx_fft_size = 1024;
unsigned int u_rx_fft_size = 2048;

/* Control port */
unsigned int u_port = 5000;

/* Instantiate XVL */
hydra::HydraMain main = hydra::HydraMain("127.0.0.1:5000");
hydra::HydraMain main = hydra::HydraMain("192.168.5.54:5000");

main.set_tx_config(
usrp,
Expand Down
119 changes: 119 additions & 0 deletions app/slice_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/usr//bin/env python2

import sys, time

import hydra
import xmlrpclib
import json



# This class receives a hydra_client, which interacts with the Hydra-Server,
# and a xmlrpclib.ServerProxy, which interacts with the UE side.
# Use the methods to configure both the client and ue at the same time.

class Slice:
def __init__(self, client, ue):
self.client = client
self.ue = ue


def free(self):
self.client.free_resources()

def allocate_tx(self, freq, bandwidth):

# Configure TX freq for slice
spectrum_conf = hydra.rx_configuration(freq, bandwidth, False)
ret = self.client.request_tx_resources( spectrum_conf )

if (ret < 0):
print "Error allocating HYDRA TX resources: freq: %f, bandwidth %f" % (freq, bandwidth)
return -1

# Configure the RX freq for UE (to receive from the slice)
self.ue.set_freqrx(freq)
self.ue.set_vr1offset(0)
self.ue.set_vr2offset(0)
self.ue.set_samp_rate(bandwidth)

if (self.ue.get_freqrx() != freq or self.ue.get_samp_rate() != bandwidth):
print "Error allocating UE RX resources: freq: %f, bandwidth %f" % (freq, bandwidth)
return -1

return 0

def allocate_rx(self, freq, bandwidth):
# Configure RX freq for slice
spectrum_conf = hydra.rx_configuration(freq, bandwidth, False)
ret = self.client.request_rx_resources( spectrum_conf )

if (ret < 0):
print "Error allocating TX resources: freq: %f, bandwidth %f" % (freq, bandwidth)

# Configure the RX freq for UE (to receive from the slice)
self.ue.set_freqtx(freq)
self.ue.set_vr1offset(0)
self.ue.set_vr2offset(0)
self.ue.set_samp_rate(bandwidth)

if (self.ue.get_freqtx() != freq or self.ue.get_samp_rate() != bandwidth):
print "Error allocating UE TX resources: freq: %f, bandwidth %f" % (freq, bandwidth)
return -1

return 0


def main():
## IMPORTANT: The script ansible_hydra_client_2tx_2rx already allocated resources for transmission and reception
## These resources are under the use of clients ID 1 and ID 2. The trick of this script is to connect
# with the server using the same ID (1 and 2), and them releasing the resources allocated.
# We can then allocate new resources from this python without impacting the slices.

# We put the IP of the machine executing this script
client1 = hydra.hydra_client("192.168.5.70", 5000, 1, True)
# We put the IP of the machine running the UE
ue1 = xmlrpclib.ServerProxy("http://192.168.5.78:8080")

if client1.check_connection(3) == "":
print("client1 could not connect to server")
sys.exit(1)

# put both the client and the ue in a slice class.
slice1 = Slice( client1, ue1)
# This configuration is just to "clear" the offsets in the gnuradio file.
# Dont remove it.
slice1.allocate_tx(2.43e9 - 300e3, 400e3)
slice1.allocate_rx(2.43e9 + 3e6 - 300e3, 400e3)

if (True):
# We put the IP of the machine executing this script
client2 = hydra.hydra_client("192.168.5.70", 5000, 2, True)
# We put the IP of the machine running the UE
ue2 = xmlrpclib.ServerProxy("http://192.168.5.81:8080")

if client2.check_connection(3) == "":
print("client2 could not connect to server")
sys.exit(1)
slice2 = Slice( client2, ue2)
slice2.allocate_tx(2.43e9 + 200e3, 200e3)
slice2.allocate_rx(2.43e9 + 3e6 + 200e3, 200e3)


## YOUR CODE HERE
## YOUR CODE HERE
## YOUR CODE HERE
## YOUR CODE HERE
## YOUR CODE HERE
## YOUR CODE HERE
## YOUR CODE HERE
## YOUR CODE HERE
## YOUR CODE HERE
print("Press CTRL-C to quit")
while True:
time.sleep(1)



if __name__ == "__main__":
main()
Loading

0 comments on commit 243fc08

Please sign in to comment.