This shows you the differences between two versions of the page.
isrm:laboratoare:new:02a [2022/03/12 12:15] mbarbulescu [[00] Pregătirea mediului pentru viitoarele laboratoare] |
isrm:laboratoare:new:02a [2024/10/16 09:04] (current) dragos.niculescu |
||
---|---|---|---|
Line 19: | Line 19: | ||
===== Instalare și configurare ===== | ===== Instalare și configurare ===== | ||
- | In cadrul laboratoarelor, vom folosi masina virtuala pe care o puteti descarca de [[https://ocw.cs.pub.ro/courses/isrm/mv|aici]]. Pe VM au fost deja executati pasii de configurare de mai jos. | + | In cadrul laboratoarelor, vom folosi masina virtuala pe care o puteti descarca de [[https://ocw.cs.pub.ro/courses/isrm/mv|aici]], sau urma instrucțiunilde de instalare specifice Linux. |
- | + | ||
- | <spoiler Pasi configurare masina virtuala> | + | |
- | + | ||
- | * Dependențele necesare ''ns-3'' sunt descrise în [[https://www.nsnam.org/wiki/Installation|pagina de instalare]]. Pentru ISRM vom folosi următoarele pachete pe o distribuție Ubuntu: | + | |
- | + | ||
- | <code bash> | + | |
- | student@isrm-vm:~$ sudo apt update | + | |
- | student@isrm-vm:~$ sudo apt -y install libgsl-dev gsl-bin libgslcblas0 \ | + | |
- | autoconf cvs bzr unrar \ | + | |
- | sqlite sqlite3 libsqlite3-dev \ | + | |
- | libxml2 libxml2-dev | + | |
- | </code> | + | |
- | + | ||
- | <note tip> | + | |
- | Pe mașina virtuală de ISRM aveți deja toate pachetele instalate. | + | |
- | </note> | + | |
- | + | ||
- | * Clonăm [[https://gitlab.com/nsnam/ns-3-dev|codul sursă al simulatorului nsnam/ns-3]] și ne mutăm pe versiunea 3.32: | + | |
- | + | ||
- | <code bash> | + | |
- | student@isrm-vm:~$ git clone https://gitlab.com/nsnam/ns-3-dev.git | + | |
- | student@isrm-vm:~$ cd ~/ns-3-dev | + | |
- | student@isrm-vm:~/ns-3-dev$ git checkout -b ns-332-rel ns-3.32 | + | |
- | </code> | + | |
- | + | ||
- | * Clonăm [[https://github.com/isrm-lab/ns3-labs|modelele din laborator (aici trebuie doar să fim pe master, ultimul commit)]] | + | |
- | + | ||
- | <code bash> | + | |
- | student@isrm-vm:~$ cd ~/ns-3-dev/examples | + | |
- | student@isrm-vm:~$ git clone https://github.com/isrm-lab/ns3-labs.git | + | |
- | student@isrm-vm:~$ cd ~/ns-3-dev/examples/ns3-labs && git log -1 | + | |
- | commit 5214caf7fbc39b280edf47154ed95f2fcca78a7c (HEAD -> master, origin/master, origin/HEAD) | + | |
- | </code> | + | |
- | + | ||
- | * Pentru a compila simulatorul împreună cu modelele de laborator, vom folosi sistemul de build ''waf'': | + | |
- | + | ||
- | <code bash> | + | |
- | student@isrm-vm:~/ns-3-dev$ ./waf configure --build-profile=debug --enable-examples --enable-tests | + | |
- | student@isrm-vm:~/ns-3-dev$ ./waf build -j4 | + | |
- | </code> | + | |
- | + | ||
- | <note tip> | + | |
- | Pentru a adăuga suport de C++11/14 și a beneficia de capabilitățile noi aduse de limbaj în cadrul simulărilor în pasul de configure putem seta variabila ''CXXFLAGS'' astfel: | + | |
- | + | ||
- | <code bash> | + | |
- | CXXFLAGS="-std=c++11" ./waf -d debug --enable-examples --enable-tests configure | + | |
- | </code> | + | |
- | + | ||
- | Versiunea de ''g++'' atât pe sistemele din laborator, cât și din mașina virtuală este ''7.4.0'' și are suport pentru C++14. | + | |
- | + | ||
- | E posibil ca cei de la ns-3 să fi hardcodat în folderul rădăcină în ''wscript'' standardul. E suficient să modificați linia următoare și puteți obține by default suportul pentru C++14: | + | |
- | + | ||
- | <code bash> | + | |
- | student@isrm-vm:~/ns-3-dev$ git diff wscript | + | |
- | + | ||
- | diff --git a/wscript b/wscript | + | |
- | index 4283a2899..c0dd18ccd 100644 | + | |
- | --- a/wscript | + | |
- | +++ b/wscript | + | |
- | @@ -250,7 +250,7 @@ def options(opt): | + | |
- | dest='enable_desmetrics') | + | |
- | opt.add_option('--cxx-standard', | + | |
- | help=('Compile NS-3 with the given C++ standard'), | + | |
- | - type='string', default='-std=c++11', dest='cxx_standard') | + | |
- | + type='string', default='-std=c++14', dest='cxx_standard') | + | |
- | + | ||
- | # options provided in subdirectories | + | |
- | opt.recurse('src') | + | |
- | </code> | + | |
- | </note> | + | |
- | + | ||
- | * Validăm funcționarea corectă a buildului. Ultimul pas cu ''test.py'' este opțional, presupune rularea testelor unitare interne ale ns-3. Dacă primele două comenzi vă funcționează aveți un build stabil al simulatorului și putem începe să rulăm exemple de simulări. | + | |
- | + | ||
- | <code bash> | + | |
- | student@isrm-vm:~/ns-3-dev$ ./waf --check-profile | + | |
- | Waf: Entering directory `/home/student/ns-3-dev/build' | + | |
- | Build profile: debug | + | |
- | student@isrm-vm:~/ns-3-dev$ ./waf --run hello-simulator | + | |
- | Waf: Entering directory `/home/student/ns-3-dev/build' | + | |
- | Waf: Leaving directory `/home/student/ns-3-dev/build' | + | |
- | Build commands will be stored in build/compile_commands.json | + | |
- | 'build' finished successfully (2.256s) | + | |
- | Hello Simulator | + | |
- | student@isrm-vm:~/ns-3-dev$ ./test.py | + | |
- | (...) | + | |
- | 'build' finished successfully (1.799s) | + | |
- | (...) | + | |
- | 92 of 92 tests passed (92 passed, 0 failed, 0 crashed, 0 valgrind errors) | + | |
- | </code> | + | |
- | + | ||
- | Pentru a realiza grafice, trebuie sa instalam si pachetele de Python: | + | |
- | <code bash> | + | |
- | student@isrm-vm:~$ sudo apt-get update | + | |
- | student@isrm-vm:~$ sudo apt-get install python3-pip | + | |
- | student@isrm-vm:~$ pip3 install matplotlib jupyter | + | |
- | student@isrm-vm:~$ sudo ln -s ~/.local/bin/jupyter-notebook /usr/bin/jupyter-notebook | + | |
- | </code> | + | |
- | + | ||
- | Pentru a lansa aplicatia de Jupyter Notebook, rulati urmatoarea comanda: | + | |
- | + | ||
- | <code bash> | + | |
- | student@isrm-vm:~$ jupyter-notebook | + | |
- | </code> | + | |
- | + | ||
- | </spoiler> | + | |
===== Rulare exemple existente ===== | ===== Rulare exemple existente ===== | ||
Line 137: | Line 33: | ||
<code bash> | <code bash> | ||
- | student@isrm-vm:~/ns3$ ./waf --run wifi-tcp | + | student@isrm-vm:~/ns3$ cd lab02 |
+ | student@isrm-vm:lab02$ ../ns3 run wifi-tcp --cwd . | ||
Waf: Entering directory `/home/student/ns3/build' | Waf: Entering directory `/home/student/ns3/build' | ||
Waf: Leaving directory `/home/student/ns3/build' | Waf: Leaving directory `/home/student/ns3/build' | ||
Line 153: | Line 50: | ||
<code bash> | <code bash> | ||
- | student@isrm-vm:~/ns3$ ./waf --run examples/wireless/wifi-tcp | + | student@isrm-vm:lab02$ ../ns3 run examples/wireless/wifi-tcp --cwd . |
</code> | </code> | ||
- | Dacă vrem să transmitem parametrii în linia de comandă simulării (deoarece ''wifi-tcp'' suportă), o putem face cu ghilimele: | + | Această simulare are parametri expuși pe linia ei de comandă (nu a ns3): |
<code bash> | <code bash> | ||
- | student@isrm-vm:~/ns3$ ./waf --run "wifi-tcp --pcap --simulationTime=3" | + | student@isrm-vm:lab02$ ../ns3 run "wifi-tcp --help" |
+ | </code> | ||
+ | |||
+ | Dacă vrem să transmitem parametri în linia de comandă simulării, o putem face cu ghilimele: | ||
+ | |||
+ | <code bash> | ||
+ | student@isrm-vm:lab02$ ../ns3 run "wifi-tcp --pcap --simulationTime=3" --cwd . | ||
Waf: Entering directory `/home/student/ns3/build' | Waf: Entering directory `/home/student/ns3/build' | ||
Waf: Leaving directory `/home/student/ns3/build' | Waf: Leaving directory `/home/student/ns3/build' | ||
Line 175: | Line 78: | ||
<code bash> | <code bash> | ||
- | student@isrm-vm:~/ns3$ ls AccessPoint*.pcap Station*.pcap | + | student@isrm-vm:lab02$ ls AccessPoint*.pcap Station*.pcap |
AccessPoint-0-0.pcap Station-1-0.pcap | AccessPoint-0-0.pcap Station-1-0.pcap | ||
</code> | </code> | ||
Line 212: | Line 115: | ||
<code bash> | <code bash> | ||
- | student@isrm-vm:~/ns3$ ./waf --command-template="valgrind \ | + | student@isrm-vm:~/ns3$ ./ns3 run --command-template="valgrind \ |
--leak-check=full --show-reachable=yes %s" \ | --leak-check=full --show-reachable=yes %s" \ | ||
--run wifi-tcp | --run wifi-tcp | ||
Line 249: | Line 152: | ||
===== [00] Pregătirea mediului pentru viitoarele laboratoare ===== | ===== [00] Pregătirea mediului pentru viitoarele laboratoare ===== | ||
- | <note tip>Codul sursă al laboratoarelor de ISRM este disponibil pe [[https://github.com/isrm-lab/ns3-labs|Github]]. Dacă vreți să lucrați pe propriul calculator atunci trebuie să urmați acești pași: | + | <note tip>Codul sursă al laboratoarelor de ISRM este disponibil pe [[https://github.com/isrm-lab/ns3-labs|Github]]. |
- | + | ||
- | <code bash> | + | |
- | # Clonați repo-ul ns-3-dev de aici: https://gitlab.com/b12mihai1/ns-3-dev | + | |
- | git clone https://gitlab.com/b12mihai1/ns-3-dev.git | + | |
- | + | ||
- | # Clonați repo-ul ns-3-labs în folderul ns-3-dev/examples | + | |
- | cd ns-3-dev/examples | + | |
- | git clone https://github.com/isrm-lab/ns3-labs.git | + | |
- | + | ||
- | # Rulați build-ul sistemului de ns3 | + | |
- | ./waf configure --build-profile=debug --enable-examples --enable-tests | + | |
- | ./waf build -j4 | + | |
- | </code> | + | |
</note> | </note> | ||
Line 269: | Line 158: | ||
<code bash> | <code bash> | ||
- | student@isrm-vm-2020:~$ cd ns-3-dev | + | student@isrm-vm:~$ cd ns-3-dev |
- | student@isrm-vm-2020:~$ student@isrm-vm-2020:~/ns-3-dev$ ./waf --run lab3 | + | student@isrm-vm:~/ns-3-dev$ ./ns3 run lab3 |
Waf: Entering directory `/home/student/ns-3-dev/build' | Waf: Entering directory `/home/student/ns-3-dev/build' | ||
Waf: Leaving directory `/home/student/ns-3-dev/build' | Waf: Leaving directory `/home/student/ns-3-dev/build' | ||
Line 286: | Line 175: | ||
</code> | </code> | ||
+ | * Aflați parametrii specifici cu care poate fi rulat laboratorul 3. | ||
+ | * Ce face opțiunea --PrintGlobals, și ce parametri interesanți expune? | ||
===== [01] Grafic throughput ===== | ===== [01] Grafic throughput ===== | ||
Line 320: | Line 211: | ||
<code bash> | <code bash> | ||
- | student@isrm-vm-2020:~$ sudo apt-get install tshark | + | student@isrm-vm:~$ sudo apt-get install tshark |
</code> | </code> | ||
Line 332: | Line 223: | ||
<code bash> | <code bash> | ||
- | student@isrm-vm:~/ns-3-dev$ ./waf --run "wifi-tcp --pcap=true" | + | student@isrm-vm:~/ns-3-dev$ ./ns3 run "wifi-tcp --pcap=true" |
(...) | (...) | ||
student@isrm-vm:~/ns-3-dev$ ls -al *.pcap | student@isrm-vm:~/ns-3-dev$ ls -al *.pcap | ||
Line 363: | Line 254: | ||
<code bash> | <code bash> | ||
student@isrm-vm:~/ns-3-dev$ tshark -T fields -e frame.time_epoch \ | student@isrm-vm:~/ns-3-dev$ tshark -T fields -e frame.time_epoch \ | ||
- | -e frame.number -e ip.src \ | + | -e frame.number -e ip.src \ -r ./AccessPoint-0-0.pcap '(ip.proto == 6) && (ip.src == 10.0.0.1)' > frames.txt |
- | -r ./AccessPoint-0-0.pcap '(ip.proto == 6) && (ip.src == 10.0.0.1)' > frames.txt | + | |
</code> | </code> | ||
Line 390: | Line 280: | ||
* Folosiți câmpurile ''frame.time_epoch'' de la câteva linii consecutive și determinați la ce interval de timp (în ''ms'') AP-ul (access point-ul) trimite beacon-uri | * Folosiți câmpurile ''frame.time_epoch'' de la câteva linii consecutive și determinați la ce interval de timp (în ''ms'') AP-ul (access point-ul) trimite beacon-uri | ||
- | * Folosind ''tshark'' extrageți în 2 fișiere separate, fiecare fișier având filtrul ''wlan.fc.type_subtype <= 0x0011'' (subtipul <= 0x0011) și celălalt ''wlan.fc.type_subtype == 0x0028'' următoarele câmpuri: ''frame.time_epoch'', ''wlan_radio.phy'', ''frame.number''. | + | * Folosind ''tshark'' extrageți în 2 fișiere separate, fiecare fișier având filtrul ''wlan.fc.type_subtype <= 0x0011'' (subtipul mai mic sau egal cu 0x0011) și celălalt ''wlan.fc.type_subtype == 0x0028'' următoarele câmpuri: ''frame.time_epoch'', ''wlan_radio.phy'', ''frame.number''. |
* Ce puteți spune despre PHY type-ul din primul fișier, dar al doilea? Ce credeți că se întâmplă | * Ce puteți spune despre PHY type-ul din primul fișier, dar al doilea? Ce credeți că se întâmplă | ||
* Dacă sunteți curioși ce inseamna type/subtype, consultați [[https://community.cisco.com/t5/wireless-mobility-documents/802-11-frames-a-starter-guide-to-learn-wireless-sniffer-traces/ta-p/3110019#toc-hId--1447989924|acest tabel din standardul 802.11]] | * Dacă sunteți curioși ce inseamna type/subtype, consultați [[https://community.cisco.com/t5/wireless-mobility-documents/802-11-frames-a-starter-guide-to-learn-wireless-sniffer-traces/ta-p/3110019#toc-hId--1447989924|acest tabel din standardul 802.11]] | ||
Line 403: | Line 293: | ||
<code bash> | <code bash> | ||
- | ./waf --run "lab3 --numberOfNodes=2 --payloadSize=1400 \ | + | ./ns3 run "lab3 --numberOfNodes=2 --payloadSize=1400 \ |
--offeredRate=11Mbps --phyRate=DsssRate11Mbps --simulationTime=2 --tracing=true" | --offeredRate=11Mbps --phyRate=DsssRate11Mbps --simulationTime=2 --tracing=true" | ||
</code> | </code> |