代写CSCI4430 Assignment 2: Adaptive Video Streaming via CDN代做C/C++编程

CSCI4430

Assignment 2: Adaptive Video Streaming via CDN

Due: March 9th, 2025 @11:59 PM

Video traffic dominates the Internet. In this project,you will explore how video content distribution networks(CDNs)work. In particular,you  will implement(1)adaptive bitrate selection through an HTTP proxy server and (2)load balancing.

This project is divided into Part 1 and Part 2.We recommend that you work on them simultaneously(both of them can be independently tested),and finally integrate both parts together.This is a group project;you may work in groups of up to two people.

This project has the following goals:

● Understand the HTTP protocol and how it is used in practice to fetch data from the web.

● Understand the DASH MPEG video protocol and how it enables adaptive bitrate video streaming.

● Use polling to implement a server capable of handling multiple simultaneous client connections.

● Understand how Video CDNs work in real life.

Table of contents

1. Background

2. Getting Started

3. Part 1:HTTP Proxy

4. Part 2:Load Balancer

5. Autograder

Background

Video CDNs in the Real World


The figure above depicts a high level view of what this system looks like in the real world.Clients trying to stream a video first issue a DNS query to resolve the service's domain name to an IP address for one of the CDN's video servers.The CDN's authoritative DNS server selects the "best"content server for each particular client based on(1)the client's IP address (from which it learns the client's geographic location)and (2)current load on the content servers (which the servers periodically report to the DNS server).

Once the client has the IP address for one of the content servers,it begins requesting chunks of the video the user requested.The video is encoded at multiple bitrates.As the cient player receives video data,it calculates the throughput of the transfer and it requests the highest bitrate the connection can support (i.e.play a video smoothly, without buffering if possible).For instance,you have almost certainly used a system like this when using the default "Auto"quality option on YouTube:


Video CDN in this Assignment

Normally,the video player clients select the bitrate of the video segments they request based on the throughput of the connection.However,in this assignment,you will be implementing this functionality on the server side.The server will estimate the throughput of the connection with each client and select a bitrate it deems appropriate.

You'lwrite the components highlighted in yellow in the diagram above(the proxy and the load balancer).

Clients: You can use an off-the-shelf web browser(Firefox,Chrome,etc.)to play videos served by your CDN(via your proxy).You can simulate multiple clients by opening multiple tabs of the web browser and accessing the same video,or even using multiple browsers.You will use network throttling options in your browser to simulate different  network conditions(available in both Firefox and Chrome).

Video Server(s):Video content will be served from our custom video server;instructions for running it are included below.With the included instructions,you can run multiple instances of video servers as well on different ports.

Proxy:Rather than modify the video player itself,you will implement adaptive bitrate selection in an HTTP proxy.The player requests chunks with standard HTTP GET requests;your proxy will intercept these and modify them to retrieve whichever bitrate   your algorithm deems appropriate,returning them back to the client.Your proxy will be capable of handling multiple clients simultaneously.

Load  Balancer:You  will  implement  a  simple  load  balancer  that  can  assign  clients  to    video   servers   either   geographically   or   using   a   simple   round-robin   method.This   load   balancer  is  a  stand-in  for  a   DNS  server;as  we  are   not   running  a   DNS  protocol,we  will refer  to   it  as  a  load  balancer.The  load  balancer  will   read   in  information  about  the various  video  servers  from   a  file  when   it   is  created;it  will   not  communicate  with   the video   servers   themselves.

After you  implement  the  basics  of  the  HTTP Proxy and the  Load  Balancer, you   will    integrate  the  two  together.The  proxy  can  query  the  load  balancer  every  time  a  new client  connects  to  figure  out  which  video  server  to  connect  to.

Important:IPs and Ports

In  the  real  world,IP  Addresses  disambiguate   machines.Typically,a  given  service   runs  on a  predetermined  port  on  a  machine.For  instance,HTTP  web  servers  typically  use  port 80,while  HTTPS  servers  use  port  443.

For  the  purposes  of  this  project,as  we  want  you  to  be  able  to  run  everything  locally,we will   instead   distinguish    different   video   servers    by   their(ip,port)tuple.For   instance,you  may  have  two  video  servers  running  on  (localhost,8000)and  (localhost,8001).We  want to  emphasize  that  this  would  not  make  much  sense  in  the  real  world;you  would probably  use  a  DNS  server  for  load  balancing,which  would  point  to  several  IPs  where video servers  are  hosted,each  using  the  same  port  for  a  specific  service.

Getting Started

This  project  has  been adapted so that  it can  be  run and tested on your own device, without  any  need  for  a  virtual  machine.Although  this  leads  to  a  slightly  less  realism,we hope  it  makes  development  faster  and  easier.

Note:The  only  configuration  that  cannot   be  tested   locally   is  running  a  geographic  load  balancer  in  conjunction  with   a  load-balancing  miProxy.This  willhave   to  occur on  Mininet.However,you  are  able  to  locally  test  both(1)miProxy  with  a  round- robin  load  balancer  and  (2)a  geographic  load  balancer  on  its  own.

To  get  started,clone  this  Github  repository.We  are  using  google  drive  to  store  the video files in the Git repo.You can use this  link  to    download    the    tears-of-steel     video files,and   this  link  to  download  the  Soar  with  CUHK  video  files.The  downloaded  video  file   should   be   placed   under   the   videoserver/static/videos   folder.The   structure   of   the videoserver/static    should    be:

You can then create your own private GitHub repository,and push these files to that repo.Your repository should be shared only with your group members,and should not be publicly accessible.Making your solution code publicly accessible,even by accident,will be considered a violation of the Honor Code.You can create a private repository through the GitHub website,and add it as a remote to the cloned repository with

$git           init

$git        remote         add        origin         [email protected]:[Your-User:Your-Repo]

$git  add  -A

$git  commit  -m  "Initial  commit"

$git      push      --set-upstream      origin      main

The structure of the files is as follows:


Your   Code

As in Part 1,we will be using CMake as our build system.The top-level CMake file is at cpp/CMakeLists.txt.There are also CMakeLists.txt files in every subdirectory.These files have been filled out for you.We encourage you to take a look and see how they work.You may need to modify them if the structure of your code changes.You may not use any external  packages other than the ones we  provide:spdlog,cxxopts,pugixml, and    boost::regex.

We have also included a common folder with a few network utility functions as well as the protocol definition for communicating with the load balancer.You can(and should!) add more network utility functions and other code that can be shared between miProxy and loadBalancer into the common folder.

The structure of the project is otherwise self-explanatory;your implementation for miProxy should go in the miProxy folder,and your implementation of the loadBalancer should go in the loadBalancer folder.The following commands should allow us to build your code from the base of the project:

$mkdir   build 

$cd   build

$cmake  ../cpp 

$make

This  should  result  in  executables  build/bin/miProxy  and  build/bin/loadBalancer.

We also encourage you to integrate CMake with your editor.For instance,VSCode has a CMakeTools extension.This enables VSCode's intellisense to properly find code dependencies,which can eliminate annoying fake syntax errors.There are many resources online for you to figure out how to do this.

The two parts of the project can each be tested on their own before the integrated version is tested.You may wish to parallelize work among your groupmates;feel free to do so,but please remember that all individuals are responsible for understanding the entire project.

Running the Video Server

We have provided a simple video server for you,implemented in the videoserver/ directory.First,you will need to unzip some of the video files:

$cd     videoserver/static/videos 

$tar   -xvzf   cuhk.tar.gz

$tar     -xvzf     tears-of-steel.tar.gz

This  should  lead  to  two  folders  --cuhk  and  tears-of-steel  --being  created  inside the     videos/folder.

For Python,we will be using the uv package manager.Please follow the instructions on the linked Github page to install uv on your machine.

Once you have installed uv,you can navigate to the videoserver/directory and run

uv sync

This willdownload all necessary Python dependencies and create a virtual environment. You can then run

uv  run  launch_videoservers.py

to launch videoservers.This takes the following command line arguments

●  -n|--num-servers:Defaults  to   1.Controls  how  many  video  servers  will  be launched.

●  -p|--port:Defaults  to   8000.Controls  which   port   the   video   server(s)will  serve     on.For  multiple  videoservers,the  ports  will  be  sequential;for  instance,running  the following command will  launch three videoservers on  ports  8000,8001,and 8002.

uv  run  launch_videoservers.py  -n  3-p  8000

Note:It is not necessary to have multiple videoservers running for the early part of this project.You willonly really need this if you want to test how well your miProxy works with load balancing and separating multiple clients.

Once you launch a videoserver (e.g.on port 8000),you can navigate to  127.0.0.1:8000 (or  localhost:8000)in  your  browser  to  see  it.It  will  look  something  like  this:

You can click on the linked pages to play the videos.The first one(Tears of Steel)does not  have audio,while the second one(CUHK Video)does;this can  help vary your testing.The Tears of Steel video also has watermarks to indicate the bitrate of the current segment.The video server will also log helpful output to stdout that can help you  debug.

Note that you are currently directly accessing the video server;when testing this project,you will instead navigate to the ip:port of your running proxy,which will communicate with the video server for you.

Libraries

We expect you to use cxxopts for parsing command-line options,and spdlog for  variable-level logging.We will require certain logs to be printed using spdlog from both the HTTP proxy and the load balancer in order to faciliateautograding and debugging.

We have also included pugixml,a C++XML-parsing library and the boost::regex library in the CMake files.You do not have to use these libraries,but it will make parsing video manifest files and HTTP requests much easier.Documentation for these libraries is available online.

Why not use #include <regex>?The C++standard library's regex header is widely known to be slow and inefficient.This means that you will instead see packages     like  re2 or  boost  used  in  production  code.

We provide a script. download_deps.sh to download these libraries,all the downloaded libraries will be stored under the deps folder.

 ./download_deps.sh

After downloading,the structure of deps folder should be:

You may have to install Boost on your system.If you are on a Mac,this is very easy. Simply use Homebrew and run

brew install cmake boost

and you're done and ready to skip to "Setting Up the Starter Code".

On Windows or Linux,installing CMake and Boost are also relatively simple.On Ubuntu /WSL,you can run

sudo  apt-get  install  cmake  libboost-all-dev

Part 1:HTTP Proxy

Many video players monitor how quickly they receivedata from the server and use this throughput value to request better or lower quality encodings of the video,aiming to   stream the highest quality encoding that the connection can handle.Instead of modifying an existing video client to perform bitrate adaptation,you will implement this functionality in an HTTP proxy through which your browser will direct requests.

You are to implement a simple HTTP proxy,miProxy .It accepts connections from web  browsers,modifies video chunk requests as described below,opens a connection with   the resulting IP address,and forwards the modified request to the server.Any data (the video chunks)returned by the server should be forwarded,unmodified,to the browser miProxy should:

1.Run as a server on a specified port

2.Accept connections from clients,including multiple clients simultaneously

3.Connect to a video server

4.Forward HTTP requests from clients to the appropriate video server

5.Forward HTTP responses from the video server to the appropriate client

6.Measure the throughput of each video segment to each client

7.Capture video manifest file HTTP requests,returning the no-list manifest file to clients while reqeuesting the regular manifest file for itself

8.Capture video segment HTTP requests and modify the request to have the appropriate  bitrate

You will implement two modes of miProxy:

1.No load balancing occurs,with a single video server for all clients

2.A load balanced version,where miProxy queries your load balancer (implemented in Part 2)to figure out which video server to assign to each incoming TCP connection.

Clients vs.Incoming Sockets

For optimization,web browsers may open up several TCP connections for a single tab;  this can lead to multiple sockets connecting to your miProxy server for a single client  We will use the term "client socket"to refer to an individual socket and "client"to refer to a group of sockets of a single tab that form one logical client.




热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图