merge conflit
This commit is contained in:
commit
2d871bc4f6
12
.classpath
12
.classpath
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="main"/>
|
||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
</classpath>
|
@ -10,7 +10,10 @@ plugins {
|
||||
id 'application'
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = 'fr.ntr.Main'
|
||||
run {
|
||||
args = ["5000", "2"]
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = 'fr.ntr.Main'
|
||||
}
|
@ -2,6 +2,7 @@ package fr.ntr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import fr.ntr.scheduler.Scheduler;
|
||||
|
||||
@ -13,7 +14,7 @@ public class AccessPoint {
|
||||
*/
|
||||
private static int timeSlotNb;
|
||||
/**
|
||||
* nombre de sous-porteuses
|
||||
* Nombre de sous-porteuses
|
||||
*/
|
||||
private static int subCarrierNb;
|
||||
/**
|
||||
@ -21,37 +22,75 @@ public class AccessPoint {
|
||||
*/
|
||||
private ResourceBlock[][] frame;
|
||||
/**
|
||||
* reste pour la prochaine source
|
||||
* Reste pour la prochaine source
|
||||
*/
|
||||
private double leftForNextSource;
|
||||
/**
|
||||
* Portée minimum et maximum de l'antenne
|
||||
*/
|
||||
private final double min, max;
|
||||
|
||||
|
||||
public AccessPoint(Scheduler scheduler) {
|
||||
this.users = new ArrayList<User>();
|
||||
public AccessPoint(Scheduler scheduler, double min, double max) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.users = new ArrayList<>();
|
||||
this.scheduler = scheduler;
|
||||
this.frame = new ResourceBlock[timeSlotNb][subCarrierNb];
|
||||
}
|
||||
|
||||
public void startSimulation(int duration){
|
||||
|
||||
/**
|
||||
* Lancer la simulation
|
||||
* @param duration
|
||||
*/
|
||||
public void startSimulation(int duration, int nbUsers) {
|
||||
for (int ticks = 0; ticks < duration; ++ticks) {
|
||||
// Simulation
|
||||
reset();
|
||||
init(nbUsers);
|
||||
schedule();
|
||||
// traite les données et les enregistre dans un fichier
|
||||
analyseData();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Génération du débit et des paquets
|
||||
*/
|
||||
private void init(){
|
||||
|
||||
private void init(int nbUsers) {
|
||||
double[] distance = { 200d, 500d };
|
||||
for (int i = 0; i < nbUsers; i++) {
|
||||
User user = new User(distance[i], timeSlotNb, subCarrierNb);
|
||||
user.generateBandwidth();
|
||||
user.createPackets();
|
||||
this.users.add(user);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataAnalysis(){
|
||||
private void schedule() {
|
||||
|
||||
}
|
||||
|
||||
private void reset(){
|
||||
private void analyseData() {
|
||||
|
||||
}
|
||||
|
||||
public int getFrameSize(){
|
||||
private void plotData() {
|
||||
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
|
||||
}
|
||||
|
||||
public int getFrameSize() {
|
||||
return this.timeSlotNb * this.subCarrierNb;
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceBlock[][] getFrame() {
|
||||
return frame;
|
||||
}
|
||||
public void setFrame(ResourceBlock[][] frame) {
|
||||
this.frame = frame;
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,30 @@
|
||||
package fr.ntr;
|
||||
|
||||
import fr.ntr.scheduler.RoundRobin;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
/**
|
||||
* nombre de ticks de la simulation
|
||||
* -> durée de la simulation
|
||||
*/
|
||||
int numberOfTicks = 5000;
|
||||
|
||||
/**
|
||||
* nombre maximal d'utilisateurs dans le système
|
||||
*/
|
||||
int maximumLoad = 20;
|
||||
|
||||
|
||||
//TODO ajouter accès à AccessPoint
|
||||
|
||||
System.out.println("Hello World");
|
||||
if(args.length == 2) {
|
||||
int numberOfTicks; // Nombre de ticks de la simulation -> durée de la simulation
|
||||
int maximumLoad; // Nombre maximal d'utilisateurs dans le système
|
||||
try {
|
||||
numberOfTicks = Integer.parseInt(args[0]);
|
||||
maximumLoad = Integer.parseInt(args[1]);
|
||||
System.out.println("ticks: " + numberOfTicks + ", users: " + maximumLoad);
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("Cannot parse launch argument to integer");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
AccessPoint accessPoint = new AccessPoint(new RoundRobin("round robin", 0), 0, 50);
|
||||
accessPoint.startSimulation(numberOfTicks, maximumLoad);
|
||||
} else {
|
||||
System.err.println("Please give launch arguments");
|
||||
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,16 +10,25 @@ public class User {
|
||||
private final List<Packets> packetsToSend;
|
||||
private final List<Packets> packetsSent;
|
||||
|
||||
public User(double distance) {
|
||||
public User(double distance, int timeSlotNb, int subCarrierNb) {
|
||||
this.distance = distance;
|
||||
this.bandwidthTable = new double[1][1]; // TODO: 03/03/2023 Changer valeurs
|
||||
this.bandwidthTable = new double[timeSlotNb][subCarrierNb];
|
||||
this.packetsToSend = new ArrayList<>();
|
||||
this.packetsSent = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public void generateBandwidth() {
|
||||
|
||||
double random = Math.random();
|
||||
for(int i = 0; i < bandwidthTable.length; i++) {
|
||||
for(int j = 0; j < bandwidthTable[i].length; j++) {
|
||||
double h = 8 * Math.sqrt(-2 * Math.log(1 - random));
|
||||
double gain = h * Math.pow(10, random*8/10) * Math.pow(1/this.distance, 3.5);
|
||||
double spectralEfficiency = (43 * gain)/(15000*(-174));
|
||||
double mkn = Math.log1p(spectralEfficiency);
|
||||
this.bandwidthTable[i][j] = mkn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void createPackets() {
|
||||
|
@ -1,26 +1,39 @@
|
||||
package fr.ntr.scheduler;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import fr.ntr.User;
|
||||
|
||||
|
||||
public class RoundRobin extends Scheduler {
|
||||
|
||||
private String name;
|
||||
private int index;
|
||||
|
||||
public RoundRobin(String name, int index) {
|
||||
this.name = name;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduling() {
|
||||
}
|
||||
|
||||
//Ts = Time Slot
|
||||
//Sp =sous porteuse
|
||||
private void selectionUtilisateur(int Ts, int Sp, List<User> Users) {
|
||||
int random = new Random().nextInt(0, Users.size()-1);
|
||||
private String name;
|
||||
private int index;
|
||||
|
||||
public RoundRobin(String name, int index) {
|
||||
this.name = name;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry
|
||||
* Return
|
||||
*/
|
||||
@Override
|
||||
public void scheduling() {
|
||||
index = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry Time slot (int), Sous porteuse(int), and users ( List<User>)
|
||||
* Return the user in function of TS and SP selected
|
||||
*/
|
||||
private User UserSelection(int Ts, int Sp, List<User> Users) {
|
||||
for (int i = 0; i < Ts; i++) {
|
||||
for (int j = 0; j < Sp; j++) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return Users.get(index%(Users.size() - 1));
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user