-
Notifications
You must be signed in to change notification settings - Fork 0
/
Thoroughfare.cpp
31 lines (22 loc) · 921 Bytes
/
Thoroughfare.cpp
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
#include "Thoroughfare.hpp"
vector<bool> Thoroughfare::disorderGenerator(const vector<bool>& message) {
std::vector<bool> disorderedMessage;
for (bool bit : message) {
if ((rand() % 100) <= ERROR_PROB) {
disorderedMessage.push_back(!bit);
} else {
disorderedMessage.push_back(bit);
}
}
return disorderedMessage;
}
void Thoroughfare::thoroughfareSender(const vector<bool>& message) {
vector<bool> finalMessage{};
Logger::logBeginOfLayer("Camada Física de Transmissao");
Logger::logInfo(Logger::bitsAsString(message), "-deturpação");
finalMessage = Thoroughfare::disorderGenerator(message);
Logger::logInfo(Logger::bitsAsString(finalMessage), "+deturpação");
Logger::printDifference(message, finalMessage);
Logger::logEndOfLayer("Camada Física de Transmissao");
EnlaceLayer::enlaceLayerReceiver(finalMessage);
}