Omnet++ Olivier FLAUZAC

Documents pareils
Introduction à l héritage en C++

Serveur d'application Client HTML/JS. Apache Thrift Bootcamp

Introduction à la programmation Travaux pratiques: séance d introduction INFO0201-1

1.6- Génération de nombres aléatoires

Approche Contract First

Création d un service web avec NetBeans 5.5 et SJAS 9

Projet L1, S2, 2015: Simulation de fourmis, Soutenance la semaine du 4 mai.

Prénom : Matricule : Sigle et titre du cours Groupe Trimestre INF1101 Algorithmes et structures de données Tous H2004. Loc Jeudi 29/4/2004

TP1 : Initiation à Java et Eclipse

Le langage C++ est un langage de programmation puissant, polyvalent, on serait presque tenté de dire universel, massivement utilisé dans l'industrie

Programme Compte bancaire (code)

as Architecture des Systèmes d Information

Projet de programmation (IK3) : TP n 1 Correction

INFO-F-105 Language de programmation I Séance VI

Cours de C++ François Laroussinie. 2 novembre Dept. d Informatique, ENS de Cachan

Programmation en C/C++

ETUDE DE CAS en UML : GESTION DES COMMANDES DE PIECES FABRIQUEES PAR LA SOCIETE C

Programmation stochastique

Introduction au pricing d option en finance

C++ Programmer. en langage. 8 e édition. Avec une intro aux design patterns et une annexe sur la norme C++11. Claude Delannoy

IFT287 Exploitation de base de données relationnelles et orientées objet. Laboratoire Mon premier programme Java en Eclipse

Programmer en JAVA. par Tama

Web Tier : déploiement de servlets

Le hub d entreprise est une application de déploiement des applications mais aussi un outil de communication

Licence Bio Informatique Année Premiers pas. Exercice 1 Hello World parce qu il faut bien commencer par quelque chose...

Un ordonnanceur stupide

TD/TP PAC - Programmation n 3

Quelques éléments de compilation en C et makefiles

Introduction à C++ et à wxwidgets

Développement mobile MIDP 2.0 Mobile 3D Graphics API (M3G) JSR 184. Frédéric BERTIN

Systeme d'exploitation

Introduction au langage C

Généralités sur le Langage Java et éléments syntaxiques.

Alfstore workflow framework Spécification technique

Département Automatisation et Informatisation Année Programmation en C++ Institut des Sciences et Techniques de l Ingénieur d Angers

Architecture Orientée Service, JSON et API REST

wxwidgets dans un environnement Microsoft Windows

Principes. 2A-SI 3 Prog. réseau et systèmes distribués 3. 3 Programmation en CORBA. Programmation en Corba. Stéphane Vialle

TD Objets distribués n 3 : Windows XP et Visual Studio.NET. Introduction à.net Remoting

Bases Java - Eclipse / Netbeans

Notions fondamentales du langage C# Version 1.0

et Programmation Objet

Programmation C++ (débutant)/instructions for, while et do...while

Java Licence Professionnelle CISII,

Remote Method Invocation Les classes implémentant Serializable

Design patterns. Design patterns - définition. Design patterns - avantages

Cours de C/C++ par la pratique. Hugues Talbot

Plan du cours. Historique du langage Nouveautés de Java 7

Exceptions. 1 Entrées/sorties. Objectif. Manipuler les exceptions ;

Resolution limit in community detection

TD/TP PAC - Programmation n 3

Langage Java. Classe de première SI

Le MSMQ. Version 1.0. Pierre-Franck Chauvet

Projet Android (LI260) Cours 2

Une introduction à Java

Derrière toi Une machine virtuelle!

Cours intensif Java. 1er cours: de C à Java. Enrica DUCHI LIAFA, Paris 7. Septembre Enrica.Duchi@liafa.jussieu.fr

[APPLICATON REPARTIE DE VENTE AUX ENCHERES]

INTRODUCTION A JAVA. Fichier en langage machine Exécutable

JADE : Java Agent DEvelopment framework. Laboratoire IBISC & Départ. GEII Université & IUT d Evry nadia.abchiche@ibisc.univ-evry.

Informatique III: Programmation en C++

Environnements de développement (intégrés)

Java Licence Professionnelle CISII,

Génie Logiciel I. Cours VI - Typage statique / dynamique, fonctions virtuelles et classes abstraites, flots d entrées / sorties, et string

TP3 : Manipulation et implantation de systèmes de fichiers 1

1. Structure d un programme C. 2. Commentaire: /*..texte */ On utilise aussi le commentaire du C++ qui est valable pour C: 3.

EPREUVE OPTIONNELLE d INFORMATIQUE CORRIGE

STS SE. FreeRTOS. Programmation réseau WIFI. Programmation réseau. Socket Tcp. FlyPort smart Wi-Fi module

30.avr.10 Présentation miniprojet. 9.mars.10 Cours 3 4.mai.10 Cours C mars.10 Cours 4 11.mai.10 Cours C++ 2

Le langage C. Séance n 4

Le langage C++ (partie I)

Cours 1: Java et les objets

COMPARAISONDESLANGAGESC, C++, JAVA ET

Développement Logiciel

Intergiciels pour la répartition CORBA : Common Object Request Broker. Patrice Torguet torguet@irit.fr Université Paul Sabatier

Claude Delannoy. 3 e édition C++

RAPPELS SUR LES METHODES HERITEES DE LA CLASSE RACINE Object ET LEUR SPECIALISATION (i.e. REDEFINITION)

Dossier. Développer en Java sur téléphone mobile. Benjamin Damécourt UFR SITEC Master 2 EESC 11 janvier 2012

Introduction à l algorithmique et à la programmation M1102 CM n 3

CSI351 Systèmes d exploitation Instructions pour rouler Linux avec Virtual PC dans la salle de labo 2052

Programmation Orientée Objet

INITIATION AU LANGAGE JAVA

Génération de code binaire pour application multimedia : une approche au vol

Package Java.util Classe générique

La programmation orientée objet Gestion de Connexions HTTP Manipulation de fichiers Transmission des données PHP/MySQL. Le langage PHP (2)

CONCOURS DE L AGRÉGATION INTERNE «ÉCONOMIE ET GESTION» SESSION 2014

Conventions d écriture et outils de mise au point

Calcul Parallèle. Cours 5 - JAVA RMI

Cours d Algorithmique-Programmation 2 e partie (IAP2): programmation 24 octobre 2007impérative 1 / 44 et. structures de données simples

HMI target Visu / PLC HMI. Pour réaliser une interface homme machine avec PLC control

Rafraichissement conditionné d'une page en.net

Déploiement de SAS Foundation

Notes de cours Practical BigData

Cours d initiation à la programmation en C++ Johann Cuenin

Développement d un logiciel de messagerie instantanée avec Dotnet (version simplifiée)

Auto-évaluation Programmation en Java

Votre premier projet Android

La base de données XML exist. A. Belaïd

Langage et Concepts de ProgrammationOrientée-Objet 1 / 40

Transcription:

Omnet++ Olivier FLAUZAC olivier.flauzac@univ-reims.fr http://www.flauzac.eu

Généralités

Omnet++ Simulateur à événement discret Simulation algorithmes distribués protocoles Mode d exécution mode graphique mode console

Ressources Site WEB http://www.omnetpp.org version actuelle 4.6 Extension de omnet++ par l intermédiaire de frameworks réseaux IP réseaux ad hoc réseaux pair-à-pair...

Projet Omnet++ Fichiers de description de topologie / réseau fichiers.ned Fichier d initialisation fichier.ini Fichiers de code fichiers d en tête :.h fichiers de code :.cc

Fichier.ned Description du réseau Description de chacun des composants qui forment le réseau Langage spécifique code source graphique

Fichier.ini Description du cas d application Initialisation de paramètres de simulation temps maximum d exécution nombre de noeuds identifiants des noeuds...

Un premier projet : Un Ping Pong

Ping Pong Principe : Deux sites se renvoient un message à l infini Réseau deux sites Un site un identifiant un «port» en sortie un «port» en entrée

Création d un projet Omnet++ Project name : Pp Empty project with src and simulations folders

Création du réseau Définition générale du réseau dossier simulation fichier.ned New Network Description File Pp.ned Empty NED file

simulations/pp.ned package pp.simulations; import pp.*; network Net { submodules: Ping:Site{ @display("p=50,50"); Pong:Site{ @display("p=200,50"); connections: Ping.out --> Pong.in; Pong.out --> Ping.in;

Définition du module site Module site : noeud + comportement (fichier.h et.cc) dans le répertoire src new Simple module name Site.ned création des trois fichiers Site.ned, Site.h, site.cc

Définition du comportement Fichiers.h et.cc Définition des éléments liés (id) Définition de l initialisation lecture des paramètres id de omnetpp.ini création d un message envoie d un message

Exécution A la réception d un message afficher le contenu créer un nouveau message envoyer le message

src/site.ned package pp; // // TODO auto-generated module // simple Site { parameters: int id; gates: input in; output out;

Fichier.h #ifndef PP_SITE_H_ #define PP_SITE_H_ #include <omnetpp.h> /** * TODO - Generated class */ class Site : public csimplemodule { private: int id; // rajouté protected: virtual void initialize(); virtual void handlemessage(cmessage *msg); ; #endif

Fichier.cc #include "Site.h" Define_Module(Site); using namespace std; void Site::initialize() { this->id = par("id").longvalue(); ev << "demarrage du site " << id << endl; if(id == 0){ cmessage *m = new cmessage("depuis Ping"); send(m,"out"); ev << "Message envoye depuis " << this->id << endl;

fichier.cc (fin) void Site::handleMessage(cMessage *msg) { ev << "Message recu au site : "<< this->id << endl; ev << "Contenu du message : " << msg->getname() << endl; delete msg; cmessage *m = NULL; if(id == 0){ m = new cmessage("depuis Ping"); else{ m = new cmessage("depuis Pong"); send(m,"out"); ev << "Message envoye depuis " << this->id << endl;

Création de l environnement (.ini) Création sur le projet new initialization file omnetpp.ini Empty ini File Select Network : pp.simulations.net

Eléments Temps de simulation Identifiant des éléments (id) Création : mode graphique mode console

Fichier omnetpp.ini [General] network = pp.simulations.net sim-time-limit=100s Net.Ping.id = 0 Net.Pong.id = 1

Compilation / exécution Compilation Sur le projet Build Project Exécution Sur le projet Run as - run Configurations création d une configuration au nom du projet exécution

Extension du Ping Pong

Extension Deux sites différents deux fichiers de description dans src deux classes de comportement Changement des couleurs des sites

simulations/pp2.ned package pp2.simulations; import pp2.*; network Pp2 { submodules: S1:Ping{ S2:Pong{ connections: S1.out --> S2.in; S2.out --> S1.in;

src/ping.ned & src/pong.ned package pp2; simple Ping { parameters: @display("i=misc/node_vs"); int id; gates: input in; output out; package pp2; simple Pong { parameters: @display("i=misc/node_vs"); int id; gates: input in; output out;

src/pong.h #ifndef PP2_PONG_H_ #define PP2_PONG_H_ #include <omnetpp.h> /** * TODO - Generated class */ class Pong : public csimplemodule { private: bool alternate; int id; protected: virtual void initialize(); virtual void handlemessage(cmessage *msg); ; #endif

src/ping.h #ifndef PP2_PING_H_ #define PP2_PING_H_ #include <omnetpp.h> /** * TODO - Generated class */ class Ping : public csimplemodule { private: bool alternate; int id; protected: virtual void initialize(); virtual void handlemessage(cmessage *msg); ; #endif

src/ping.cc #include "ping.h" Define_Module(Ping); using namespace std; void Ping::initialize() { this->id = par("id").longvalue(); ev << "Init in PING " << endl; getdisplaystring().settagarg("i",1,"red"); this->alternate = false; cmessage *m = new cmessage(); m->setkind(12); m->setname("from PING"); send(m,"out"); void Ping::handleMessage(cMessage *msg) { if(this->alternate == false){ getdisplaystring().settagarg("i",1,"blue"); this->alternate = true; else{ getdisplaystring().settagarg("i",1,"red"); this->alternate = false; ev << "Message name " << msg->getname() << " kind " << msg->getkind() << endl; delete msg; cmessage *m = new cmessage(); m->setkind(12); m->setname("from PING"); send(m,"out");

src/pong.cc #include "pong.h" Define_Module(Pong); using namespace std; void Pong::initialize() { this->id = par("id").longvalue(); ev << "Init in PONG " << endl; getdisplaystring().settagarg("i",1,"yellow"); void Pong::handleMessage(cMessage *msg) { if(this->alternate == false){ getdisplaystring().settagarg("i",1,"purple"); this->alternate = true; else{ getdisplaystring().settagarg("i",1,"yellow"); this->alternate = false; ev << "Message name " << msg->getname() << " kind " << msg->getkind() << endl; delete msg; cmessage *m = new cmessage(); m->setkind(12); m->setname("from PONG"); send(m,"out");

omnetpp.ini [General] network = pp2.simulations.pp2 **.S1.id = 1 **.S2.id = 2

Circulation de jeton sur un anneau

Objectif Création de topologie depuis un wizard Création d une topologie en anneau taille fixe Attention aux définition de module et de simple node

Création du projet Omnet++ Project name : Ring empty with src and simulations folder

Création du réseau Dans simulations création de Ring.ned network description file Choix d une topologie régulière

Wizard

Ring.ned package ring.simulations; import ned.idealchannel; module Node { parameters: @display("i=misc/node_vs"); gates: inout prev; inout next; connections allowunconnected: network Ring { submodules: node0: Node { @display("p=200,50"); node1: Node { @display("p=306,94"); node2: Node { @display("p=350,201"); node3: Node { @display(«p=306,307"); node4: Node { @display("p=199,350"); node5: Node { @display("p=93,307"); node6: Node { @display("p=50,200"); node7: Node { @display(«p=93,94"); connections: node0.next <--> IdealChannel <--> node1.prev; node1.next <--> IdealChannel <--> node2.prev; node2.next <--> IdealChannel <--> node3.prev; node3.next <--> IdealChannel <--> node4.prev; node4.next <--> IdealChannel <--> node5.prev; node5.next <--> IdealChannel <--> node6.prev; node6.next <--> IdealChannel <--> node7.prev; node7.next <--> IdealChannel <--> node0.prev;

Ring.ned modifié package ring.simulations; import ned.idealchannel; import ring.*; network Ring { submodules: node0: Node { @display("p=200,50"); node1: Node { @display(«p=306,94"); node2: Node { @display("p=350,201"); node3: Node { @display("p=306,307"); node4: Node { @display("p=199,350"); node5: Node { @display("p=93,307"); node6: Node { @display("p=50,200"); node7: Node { @display(«p=93,94»); connections: node0.next <--> IdealChannel <--> node1.prev; node1.next <--> IdealChannel <--> node2.prev; node2.next <--> IdealChannel <--> node3.prev; node3.next <--> IdealChannel <--> node4.prev; node4.next <--> IdealChannel <--> node5.prev; node5.next <--> IdealChannel <--> node6.prev; node6.next <--> IdealChannel <--> node7.prev; node7.next <--> IdealChannel <--> node0.prev;

src/node.ned package ring; // // TODO auto-generated module // simple Node { parameters: @display(«i=misc/node_vs"); int id; gates: inout prev; inout next;

Fichier.ini [General] network = ring.simulations.ring cpu-time-limit = 300s **.node0.id = 0 **.node1.id = 1 **.node2.id = 2 **.node3.id = 3 **.node4.id = 4 **.node5.id = 5 **.node6.id = 6 **.node7.id = 7

src/node.h #ifndef RING_NODE_H_ #define RING_NODE_H_ #include <omnetpp.h> /** * TODO - Generated class */ class Node : public csimplemodule { private: int id; protected: virtual void initialize(); virtual void handlemessage(cmessage *msg); ; #endif

src/node.cc #include "Node.h" Define_Module(Node); using namespace std; void Node::initialize() { this->id = par("id").longvalue(); ev << "Start in " << this->id << endl; if(this->id==0){ ev << "Send first message" << endl; cmessage *m = new cmessage("token"); send(m,"next$o"); void Node::handleMessage(cMessage *msg) { ev << "Message received in " << this->id << endl; delete msg; ev << "Send message in " << this->id << endl; cmessage *m = new cmessage("token"); send(m,"next$o");

Circulation de jeton sur un anneau (2)

Objectif Création de topologie depuis un wizard Création d une topologie en anneau taille dynamique définition d un tableau de ports Attention aux définitions de module et de simple node

simulation/ring2.ned package ring2.simulations; import ned.idealchannel; import ring2.*; // // A generated network with ring topology. // network Ring2 { parameters: int n = default(8); submodules: node[n]: Node { gates: g[2]; connections: for i=0..n-1 { node[i].g[0] <--> IdealChannel <--> node[(i+1)%n].g[1];

src/node.ned package ring2; // // TODO auto-generated module // simple Node { parameters: @display("i=misc/node_vs"); gates: inout g[];

omnetpp.ini [General] network = ring2.simulations.ring2 cpu-time-limit = 300s

src/node.h #ifndef RING2_NODE_H_ #define RING2_NODE_H_ #include <omnetpp.h> /** * TODO - Generated class */ class Node : public csimplemodule { private: int id; protected: virtual void initialize(); virtual void handlemessage(cmessage *msg); ; #endif

src/node.cc #include "Node.h" Define_Module(Node); void Node::initialize() { this->id = this->getindex(); ev << "Start in " << this->id << endl; if(this->id ==0){ ev << "send message in " << this->id << endl; cmessage *m = new cmessage("start"); send(m,"g$o",0); void Node::handleMessage(cMessage *msg) { ev << "Message in " << this->id << endl; ev << "Message : " << msg->getname() << endl; delete msg; ev << "send message in " << this->id << endl; cmessage *m = new cmessage("to next"); send(m,"g$o",0);

Graphe aléatoire : première approche

Protocole Création d un graphe aléatoire attention au germe! Création d un message spécifique héritage de la classe cmessage stockage dans le message des sites visités utilisation d un vector En chaque site, choix d un voisin aléatoirement mémorisation du site émission du message sauvegarde de l id du site dans un fichier texte

simulations/rnd.ned package rnd.simulations; import rnd.*; // // TODO auto-generated type // network Rnd { parameters: int n = default(10); double densite=default(0.70); submodules: node[n]: Site { connections: for i=0..n-1,for j=i+1..n-1, if(uniform(0,1) < densite) { node[i].neigh++ <--> node[j].neigh++;

src/site.ned package rnd; // // TODO auto-generated module // simple Site { parameters: @display("i=misc/node_vs"); gates: inout neigh[];

src/mymessage.h #ifndef MYMESSAGE_H_ #define MYMESSAGE_H_ #include <omnetpp.h> #include <vector> using namespace std; class MyMessage: public :: cmessage { private: vector<int> v; public: MyMessage(); virtual ~MyMessage(); ; void addsite(int); vector<int>& getsites(); #endif /* MYMESSAGE_H_ */

src/mymessage.cc #include "MyMessage.h" #include <vector> using namespace std; MyMessage::MyMessage() { v = vector<int>(); MyMessage::~MyMessage() { // TODO Auto-generated destructor stub void MyMessage::addSite(int i){ v.push_back(i); vector<int>& MyMessage::getSites(){ return v;

src/site.h #ifndef RND_SITE_H_ #define RND_SITE_H_ #include <omnetpp.h> #include <iostream> #include <fstream> #include <string> using namespace std; /** * TODO - Generated class */ class Site : public csimplemodule { private: int id; ofstream fileout; static const string filename; protected: virtual void initialize(); virtual void handlemessage(cmessage *msg); public: void savedata(string,int); ; const string Site::filename="./data.txt"; #endif

src/site.cc #include "Site.h" #include "MyMessage.h" #include <iostream> #include <fstream> #include <string> using namespace std; Define_Module(Site); void Site::initialize() { this->id = this->getindex(); if(this->id == 0){ this->savedata(site::filename.c_str(),this->id); MyMessage *m = new MyMessage(); m->addsite(this->id); int k = intuniform(0,gatesize("neigh")-1); send(m,"neigh$o",k);

src/site.cc void Site::handleMessage(cMessage *msg) { this->savedata(site::filename.c_str(),this->id); ev << "Message in " << this->id << endl; ((MyMessage *)msg)->addsite(this->id); ev << "Visited nodes : "; vector<int> v = ((MyMessage *)msg)->getsites(); for(unsigned int i=0; i< v.size() ; i++){ ev << v[i] << ";" ; ev << endl; int k = intuniform(0,gatesize("neigh")-1); send(msg,"neigh$o",k); void Site::saveData(string file,int data){ this->fileout.open(file.c_str(),ios::app); this->fileout << "in " << data << endl; this->fileout.flush(); this->fileout.close();

omnetpp.ini [General] network = rnd.simulations.rnd cpu-time-limit = 300s seed-0-mt=85685