Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Caco Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bfsc19
Caco Project
Commits
7bb7a45e
Commit
7bb7a45e
authored
2 years ago
by
Nico Ramos
Browse files
Options
Downloads
Patches
Plain Diff
kjsdflsdkj
parent
f6bd98d9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
headers/client.h
+11
-11
11 additions, 11 deletions
headers/client.h
with
11 additions
and
11 deletions
headers/client.h
+
11
−
11
View file @
7bb7a45e
...
@@ -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
<<
"
\t
Iniciando transmissao
\n
"
<<
RESET
;
->
log
cout
<<
YELLOW
<<
"
\t
Iniciando 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
<<
"
\t
Falha ao iniciar a transmissao
\n
"
<<
RESET
;
->
log
cout
<<
BOLDRED
<<
"
\t
Falha ao iniciar a transmissao
\n
"
<<
RESET
;
return
0
;
return
0
;
}
}
cout
<<
GREEN
<<
"
\t
Transmissao iniciada com sucesso
\n
"
<<
RESET
;
->
log
cout
<<
GREEN
<<
"
\t
Transmissao 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
<<
"
\t
start transmission
\n
"
;
->
log
cout
<<
"
\t
start 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
<<
"
\t
Frame enviado com sucesso
\n
"
;
->
log
cout
<<
"
\t
Frame 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
<<
"
\t
Terminou de enviar todos os frames
\n
"
;
//->
l
og
cout
<<
"
\t
Terminou 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
)
&&
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment