Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
P
project_TRTP
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Samuel de Meester de Ravestein
project_TRTP
Validations
ccba8897
Valider
ccba8897
rédigé
3 years ago
par
Samuel de Meester de Ravestein
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
sender handling crc now
parent
22567e48
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
headers/packet_interface.h
+11
-0
11 ajouts, 0 suppression
headers/packet_interface.h
src/packet_interface.c
+0
-7
0 ajout, 7 suppressions
src/packet_interface.c
src/sender.c
+27
-3
27 ajouts, 3 suppressions
src/sender.c
avec
38 ajouts
et
10 suppressions
headers/packet_interface.h
+
11
−
0
Voir le fichier @
ccba8897
...
@@ -94,6 +94,17 @@ pkt_t* pkt_new();
...
@@ -94,6 +94,17 @@ pkt_t* pkt_new();
* ressources associées */
* ressources associées */
void
pkt_del
(
pkt_t
*
);
void
pkt_del
(
pkt_t
*
);
/**
* @brief Calculates the CRC32
*
* @param buffer : The buffer on which to calculate CRC32.
* @param len : The number of bytes of the buffer.
* @return uint32_t
*/
uint32_t
calculate_crc
(
const
char
*
buffer
,
uint32_t
len
);
/*
/*
* Retourne la longueur du header en bytes.
* Retourne la longueur du header en bytes.
*/
*/
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/packet_interface.c
+
0
−
7
Voir le fichier @
ccba8897
...
@@ -13,13 +13,6 @@ void pkt_del(pkt_t *pkt)
...
@@ -13,13 +13,6 @@ void pkt_del(pkt_t *pkt)
free
(
pkt
);
free
(
pkt
);
}
}
/**
* @brief Calculates the CRC32
*
* @param buffer : The buffer on which to calculate CRC32.
* @param len : The number of bytes of the buffer.
* @return uint32_t
*/
uint32_t
calculate_crc
(
const
char
*
buffer
,
uint32_t
len
)
uint32_t
calculate_crc
(
const
char
*
buffer
,
uint32_t
len
)
{
{
return
(
uint32_t
)
crc32
(
0L
,
(
const
void
*
)
buffer
,
len
);
return
(
uint32_t
)
crc32
(
0L
,
(
const
void
*
)
buffer
,
len
);
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/sender.c
+
27
−
3
Voir le fichier @
ccba8897
...
@@ -86,7 +86,11 @@ int main(int argc, char **argv) {
...
@@ -86,7 +86,11 @@ int main(int argc, char **argv) {
}
}
// *** Step : Time for sending ***
// *** Step: Time for sending ***
pkt_t
buffer
[
MAX_WINDOW_SIZE
];
int
buffer_space
=
MAX_WINDOW_SIZE
;
int
seqnum
=
0
;
pkt_t
*
pkt
=
pkt_new
();
pkt_t
*
pkt
=
pkt_new
();
ssize_t
nbr_byte_read
=
read
(
fd
,
pkt
->
payload
,
MAX_PAYLOAD_SIZE
);
ssize_t
nbr_byte_read
=
read
(
fd
,
pkt
->
payload
,
MAX_PAYLOAD_SIZE
);
while
(
nbr_byte_read
>
0
)
while
(
nbr_byte_read
>
0
)
...
@@ -95,9 +99,29 @@ int main(int argc, char **argv) {
...
@@ -95,9 +99,29 @@ int main(int argc, char **argv) {
pkt_set_type
(
pkt
,
PTYPE_DATA
);
pkt_set_type
(
pkt
,
PTYPE_DATA
);
pkt_set_length
(
pkt
,
nbr_byte_read
);
pkt_set_length
(
pkt
,
nbr_byte_read
);
ssize_t
sent
=
send
(
socket_fd
,
pkt
,
PKT_MAX_LEN
,
0
);
// We set the TR to 0 in order to calculcate the CRC on the header
char
modified_header
[
8
];
memcpy
((
void
*
)
&
modified_header
,
(
void
*
)
&
pkt
->
header
,
8
);
modified_header
[
0
]
=
modified_header
[
0
]
&
TR_SETTER_TO_ZERO
;
uint32_t
crc1
=
htonl
(
calculate_crc
(
modified_header
,
8
));
pkt_set_crc1
(
pkt
,
crc1
);
uint32_t
crc2
=
htonl
(
calculate_crc
(
pkt
->
payload
,
(
uint32_t
)
pkt_get_length
(
pkt
)));
pkt_set_crc2
(
pkt
,
crc2
);
char
paquet_to_be_sent
[
PKT_MAX_LEN
];
if
(
pkt_encode
(
pkt
,
paquet_to_be_sent
,
PKT_MAX_LEN
)
!=
PKT_OK
)
{
close
(
fd
);
close
(
socket_fd
);
ERROR
(
"An error occured when trying to encode a paquet
\n
"
);
return
EXIT_FAILURE
;
}
ssize_t
sent
=
send
(
socket_fd
,
paquet_to_be_sent
,
PKT_MAX_LEN
,
0
);
if
(
sent
==
-
1
)
if
(
sent
==
-
1
)
{
{
close
(
fd
);
close
(
socket_fd
);
close
(
socket_fd
);
ERROR
(
"An error occured when trying to send a paquet
\n
"
);
ERROR
(
"An error occured when trying to send a paquet
\n
"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
...
@@ -108,7 +132,7 @@ int main(int argc, char **argv) {
...
@@ -108,7 +132,7 @@ int main(int argc, char **argv) {
nbr_byte_read
=
read
(
fd
,
pkt
->
payload
,
MAX_PAYLOAD_SIZE
);
nbr_byte_read
=
read
(
fd
,
pkt
->
payload
,
MAX_PAYLOAD_SIZE
);
}
}
pkt_del
(
pkt
);
pkt_del
(
pkt
);
close
(
fd
);
close
(
fd
);
close
(
socket_fd
);
close
(
socket_fd
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter