ZiBaT => Peter Levinsky => Tech => exercise
UDP Proxy
Updated : 2018-09-04

Simple UDP Proxy


To design and program two projects one to be a REST Service and one to be a UDP proxy - receive UDP datagrams and send REST post method.


Previous exercises REST service & UDP server

To simulate a sensor download this package (FakeSensor.zip) unpack and run the sensor - 'GenericSensorBroadcaster.exe'.
This will send out message-lines like : {"SensorName":Room D3.04,"Temperature":1,"CO2":900} heading PORT 10100

Assignment A: Make a REST service for Sensor data

  1. In Visual Studio  Create a new solution 'ConsoleApp (.Net Core)', and name it e.g. 'UDPProxy'.
  2. Create a new Project 'ASP.NET Core Web Application', and name it e.g. 'SensorREST'.
  3. Create a new Project 'Class Libray (.Net Core)' and name it e.g. 'ModelLib'.
  4. In the ModelLib create one model classes
    1. a 'SensorData' with the properties 'Id, Name, Temperature, CO2'
  5. In the 'SensorREST' Create a controller 'Sensor'
    1. In the controller - make three methods
      1. Get All - to get all sensor data in the rest api
      2. Get one specified by the Id
      3. Create a new instance of Sensor Data i.e. a POST method
  6. Try your REST service with Postman, fiddler or Swagger


Assignment B:  Make a Proxy

  1. In the UDPProxy i.e. make a new class Proxy and create a Start method.
  2. In the start method in a loop :
    1. Receive UDP datagrams from the Sensor (e.g. port 10100)
    2. Make and send a POST request to your REST service
  3. Start your Fake Sensor, your REST Service and your Proxy
  4. Try from time to time to get all from your rest service from a browser.