-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnlaceLayer.cpp
More file actions
61 lines (49 loc) · 1.81 KB
/
EnlaceLayer.cpp
File metadata and controls
61 lines (49 loc) · 1.81 KB
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
55
56
57
58
59
60
#include "EnlaceLayer.hpp"
void EnlaceLayer::enlaceLayerSender(vector<bool> frame) {
Logger::logBeginOfLayer("Camada de Enlace");
frame = handleError(frame);
Thoroughfare::thoroughfareSender(frame);
}
vector<bool> EnlaceLayer::handleError(vector<bool> frame) {
Logger::logInfo(
("Escolhendo heuristica de tratamento de inconsistencias."));
switch (ERROR_ROUTINE) {
case 0:
Logger::logInfo(("Paridade Par."));
return PartityAlgsTests::evenParity(frame);
case 1:
Logger::logInfo(("Paridade Impar."));
return PartityAlgsTests::oddParity(frame);
case 2:
Logger::logInfo(("Polinomios."));
return PartityAlgsTests::crc32(frame);
}
return frame;
}
void EnlaceLayer::enlaceLayerReceiver(vector<bool> frame) {
Logger::logInfo("Camada de Enlace Receptora", "Camada de Enlace");
if (EnlaceLayer::handleErrorReceiver(frame)){
cout << Logger::red(string(30, '-')) << endl;
cout << Logger::red(string(7, '-') + "[ERRO DETECTADO]" + string(7, '-'))
<< endl;
cout << Logger::red(string(30, '-')) << endl;
}
Logger::logInfo("Binário Recebido", Logger::bitsAsString(frame));
App::appReceiver(frame);
}
bool EnlaceLayer::handleErrorReceiver(vector<bool> frame) {
Logger::logInfo(
("Escolhendo heuristica de teste de integridade"));
switch (ERROR_ROUTINE) {
case 0:
Logger::logInfo(("Paridade Par."));
return PartityAlgsTests::evenParityTest(frame);
case 1:
Logger::logInfo(("Paridade Impar."));
return PartityAlgsTests::oddParityTest(frame);
case 2:
Logger::logInfo(("Polinomios."));
return PartityAlgsTests::crc32Test(frame);
}
return false;
}