serialization de Integer (cryptopp) in ns3
std::ostringstream oss;
oss << m_n;
std::string s = oss.str();
//std::cout << s << std::endl;
// serialisation
int x;
int len=s.length();
uint8_t l= (uint8_t) len;
// std::cout <<"h serialize"<< h<< std::endl;
// cout<< "len serialz "<<len<<" \n"<<endl;
i.WriteU8 (l); //insérer la longueur de la chaine pour l'utiliser dans la déserialisation
for (int j = 0; j < len; j++)
{
x= (int) s[j];
uint8_t y = (uint8_t) x;
i.WriteU8 (y);
}
unserialization of Integer (cryptopp) in ns3
uint8_t l = i.ReadU8 (); //récupérer la longueur
double gg= (double) l;
int len = ( int ) gg;
//cout<< "len deserialz "<<len<<" \n"<<endl;
len=310;
// cout<< "len serialz "<<len<<" \n"<<endl;
std::istringstream iss;
string s="";
//construction du string
for (int j = 0; j < len; j++)
{
uint8_t ci = i.ReadU8();
int cii = (int) ci;
char c = char(cii);
//cout<< "le caractère est :cc "<<c<<" \n"<<endl;
s+=c; //concaténer caractère par caractère pour récupérer toute la chaine
}
const char* cstr = s.c_str() ;
//j'ai utiliser ce constructeur pour récupérer le Integer, Integer(const char *str)
Integer g = Integer(cstr);
m_n=g;
I found the solution I want to share it with you for