Skip to content
Snippets Groups Projects
Commit 7bb7a45e authored by Nico Ramos's avatar Nico Ramos
Browse files

kjsdflsdkj

parent f6bd98d9
No related branches found
No related tags found
No related merge requests found
...@@ -107,7 +107,7 @@ frame *client::send_frame_socket(frame *f) { ...@@ -107,7 +107,7 @@ frame *client::send_frame_socket(frame *f) {
// Inicia a transmissao com o servidor // Inicia a transmissao com o servidor
int client::start_transmission() { int client::start_transmission() {
cout<< YELLOW << "\tIniciando transmissao\n" << RESET; ->log cout<< YELLOW << "\tIniciando transmissao\n" << RESET;
frame *ini = new frame(INIT, 0, vector<char>(1, 0)); frame *ini = new frame(INIT, 0, vector<char>(1, 0));
frame *enviado = new frame(); frame *enviado = new frame();
enviado = send_frame_socket(ini); enviado = send_frame_socket(ini);
...@@ -117,11 +117,11 @@ int client::start_transmission() { ...@@ -117,11 +117,11 @@ int client::start_transmission() {
enviado = send_frame_socket(ini); enviado = send_frame_socket(ini);
} }
if (!enviado) { if (!enviado) {
cout<< BOLDRED << "\tFalha ao iniciar a transmissao\n" << RESET; ->log cout<< BOLDRED << "\tFalha ao iniciar a transmissao\n" << RESET;
return 0; return 0;
} }
cout<< GREEN << "\tTransmissao iniciada com sucesso\n" << RESET; ->log cout<< GREEN << "\tTransmissao iniciada com sucesso\n" << RESET;
return 1; return 1;
} }
...@@ -149,9 +149,9 @@ int client::send_frames(vector<frame *> frames) { ...@@ -149,9 +149,9 @@ int client::send_frames(vector<frame *> frames) {
if (frames.empty()) { return 0; } if (frames.empty()) { return 0; }
cout << "\tstart transmission\n"; ->log cout << "\tstart transmission\n";
if (!start_transmission()) { return 0; } if (!start_transmission()) { return 0; }
cout << "\t ->>> started transmission <<< -\n"; ->log cout << "\t ->>> started transmission <<< -\n";
// Adiciona o frame de fim de transmissao // Adiciona o frame de fim de transmissao
int next_seq = frames.back()->get_seq() + 1; int next_seq = frames.back()->get_seq() + 1;
...@@ -173,11 +173,11 @@ int client::send_frames(vector<frame *> frames) { ...@@ -173,11 +173,11 @@ int client::send_frames(vector<frame *> frames) {
// frames[iniJanela + frameCounter]->imprime(DEC); // frames[iniJanela + frameCounter]->imprime(DEC);
if (socket->send_frame(frames[iniJanela + frameCounter]) == -1) { if (socket->send_frame(frames[iniJanela + frameCounter]) == -1) {
cout << "Falha ao enviar o frame\n"; ->log cout << "Falha ao enviar o frame\n";
continue; continue;
} }
cout << "\tFrame enviado com sucesso\n"; ->log cout << "\tFrame enviado com sucesso\n";
} }
// Recebe a resposta do servidor // Recebe a resposta do servidor
...@@ -192,7 +192,7 @@ int client::send_frames(vector<frame *> frames) { ...@@ -192,7 +192,7 @@ int client::send_frames(vector<frame *> frames) {
} while (res == NULL && retries < NUM_RETRIES); } while (res == NULL && retries < NUM_RETRIES);
if (res == NULL && retries == NUM_RETRIES) { if (res == NULL && retries == NUM_RETRIES) {
cout << "Numero maximo de tentativas excedido\n"; ->log cout << "Numero maximo de tentativas excedido\n";
break; } break; }
...@@ -201,7 +201,7 @@ int client::send_frames(vector<frame *> frames) { ...@@ -201,7 +201,7 @@ int client::send_frames(vector<frame *> frames) {
<< "Janela front: " << janela.front() << "\n"; << "Janela front: " << janela.front() << "\n";
if (res->get_tipo() == NACK && res->get_dado()[0] == janela.front()) { if (res->get_tipo() == NACK && res->get_dado()[0] == janela.front()) {
cout << "NACK " << (int)res->get_dado()[0] << " recebido\n"; ->log cout << "NACK " << (int)res->get_dado()[0] << " recebido\n";
iniJanela += res->get_dado()[0]; iniJanela += res->get_dado()[0];
janela.pop(); janela.pop();
break; break;
...@@ -227,7 +227,7 @@ int client::send_frames(vector<frame *> frames) { ...@@ -227,7 +227,7 @@ int client::send_frames(vector<frame *> frames) {
janela.pop(); janela.pop();
} }
cout << "\tTerminou de enviar todos os frames\n"; //->log cout << "\tTerminou de enviar todos os frames\n"; //->og
return 1; return 1;
} }
...@@ -242,7 +242,7 @@ int client::send_frames(vector<frame *> frames) { ...@@ -242,7 +242,7 @@ int client::send_frames(vector<frame *> frames) {
*/ */
bool client::verify_ack_nack(frame *received) { bool client::verify_ack_nack(frame *received) {
// received error frame // received error frame
cout << "Verificando ACK/NACK/Error\n"; ->log cout << "Verificando ACK/NACK/Error\n";
return ((received->get_tipo() == ACK || received->get_tipo() == NACK || return ((received->get_tipo() == ACK || received->get_tipo() == NACK ||
received->get_tipo() == ERRO) && received->get_tipo() == ERRO) &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment