diff -r -c -N BRITE/GUI/Brite.java BRITE.new/GUI/Brite.java *** BRITE/GUI/Brite.java Wed May 15 10:13:32 2002 --- BRITE.new/GUI/Brite.java Wed Nov 14 18:19:34 2007 *************** *** 47,55 **** HelpButton.setForeground(java.awt.Color.black); HelpButton.setFont(new Font("SansSerif", Font.PLAIN, 12)); //HelpButton.setBounds(24, 474, 50,21); ! HelpButton.setBounds(100,474,50,21); HelpButton.addActionListener(this); /*BEGIN: run C++ or Java exe choice*/ getContentPane().add(ExeChoicesComboBox); --- 47,65 ---- HelpButton.setForeground(java.awt.Color.black); HelpButton.setFont(new Font("SansSerif", Font.PLAIN, 12)); //HelpButton.setBounds(24, 474, 50,21); ! // HelpButton.setBounds(100,474,50,21); ! HelpButton.setBounds(85,474,50,21); HelpButton.addActionListener(this); + //BE: (begin) + ConvertButton.setText("Convert"); + ConvertButton.setBorder(lineBorder1); + getContentPane().add(ConvertButton); + ConvertButton.setForeground(java.awt.Color.black); + ConvertButton.setFont(new Font("SansSerif", Font.PLAIN, 12)); + ConvertButton.setBounds(145,474,60,21); + ConvertButton.addActionListener(this); + //BE: (end) /*BEGIN: run C++ or Java exe choice*/ getContentPane().add(ExeChoicesComboBox); *************** *** 117,122 **** --- 127,139 ---- hPanel.setVisible(true); return; } + //BE: (begin) + if (e.getSource().equals(ConvertButton)) { + FileConverter fc = new FileConverter(); + fc.setVisible(true); + return; + } + //BE: (end) if (e.getSource().equals(logo)) { aboutPanel.setVisible(true); return; *************** *** 256,261 **** --- 273,287 ---- sdLog.append("... DONE\n"); sdLog.paintImmediately(sdLog.getVisibleRect()); } + + if (ePanel.isOmnetppFormat()) { + sdLog.append("Converting to OMNeT++ format ..\n"); + sdLog.paintImmediately(sdLog.getVisibleRect()); + Export.OmnetppExport.convert(file, format); + sdLog.append("... DONE\n"); + sdLog.paintImmediately(sdLog.getVisibleRect()); + } + a = sdLog.getScrollableBlockIncrement(rect, SwingConstants.VERTICAL, 1); rect.setLocation((int)rect.getX(), (int)rect.getY()+a); sdLog.scrollRectToVisible(rect); *************** *** 278,284 **** runExecutable(args); if ( ((String)ExeChoicesComboBox.getSelectedItem()).equals(CPPEXE)) { ! if (ePanel.isOtterFormat() || ePanel.isNSFormat() || ePanel.isJavasimFormat() || ePanel.isDMLFormat()) try { ConvertBriteToExportFormat(file+".brite"); } --- 304,310 ---- runExecutable(args); if ( ((String)ExeChoicesComboBox.getSelectedItem()).equals(CPPEXE)) { ! if (ePanel.isOtterFormat() || ePanel.isNSFormat() || ePanel.isJavasimFormat() || ePanel.isOmnetppFormat() || ePanel.isDMLFormat()) try { ConvertBriteToExportFormat(file+".brite"); } *************** *** 353,358 **** --- 379,390 ---- else bw.write("0"); bw.write("\t #1/0=enable/disable output to Javasim"); bw.newLine(); + bw.write("\tOmnetpp = "); + if (ePanel.isOmnetppFormat()) + bw.write("1 "); + else bw.write("0"); + bw.write("\t #1/0=enable/disable output to OMNeT++"); + bw.newLine(); bw.write("EndOutput"); bw.newLine(); *************** *** 370,375 **** --- 402,408 ---- String outFile = ((String)ePanel.ExportLocation.getText()).trim(); String sep = System.getProperty("file.separator"); + //String cmdExe ="java -Xmx256M Main.Brite "; String cmdExe ="java -Xmx256M -classpath Java/:../:. Main.Brite "; boolean runC = false; *************** *** 538,543 **** --- 571,577 ---- JButton BuildTopology = new JButton(); JButton HelpButton = new JButton(); JButton LaunchBriana = new JButton(); + JButton ConvertButton = new JButton(); StatusDialog sd = new StatusDialog(this); JTextArea sdLog; diff -r -c -N BRITE/GUI/ExportPanel.java BRITE.new/GUI/ExportPanel.java *** BRITE/GUI/ExportPanel.java Mon Apr 22 18:05:54 2002 --- BRITE.new/GUI/ExportPanel.java Wed Nov 14 18:13:44 2007 *************** *** 15,21 **** JLabel JLabel30 = new JLabel(); JLabel JLabel31 = new JLabel(); ! JCheckBox otterFormat, briteFormat, dmlFormat,nsFormat, javasimFormat; JLabel JLabel32 = new JLabel(); JTextField ExportLocation = new JTextField(); JButton ExportLocationBrowse = new JButton(); --- 15,21 ---- JLabel JLabel30 = new JLabel(); JLabel JLabel31 = new JLabel(); ! JCheckBox otterFormat, briteFormat, dmlFormat,nsFormat, javasimFormat, omnetppFormat; JLabel JLabel32 = new JLabel(); JTextField ExportLocation = new JTextField(); JButton ExportLocationBrowse = new JButton(); *************** *** 37,42 **** --- 37,43 ---- public boolean isOtterFormat() { return otterFormat.isSelected(); } public boolean isDMLFormat() {return dmlFormat.isSelected(); } public boolean isJavasimFormat() { return javasimFormat.isSelected(); } + public boolean isOmnetppFormat() { return omnetppFormat.isSelected(); } public boolean isNSFormat() { return nsFormat.isSelected(); } void init() { *************** *** 57,88 **** briteFormat.setSelected(true); this.add(briteFormat); briteFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! briteFormat.setBounds(100, 60, 70, 24); //briteFormat.addActionListener(this); otterFormat = new JCheckBox("Otter"); this.add(otterFormat); otterFormat.setToolTipText("Export for visualization in Otter"); otterFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! otterFormat.setBounds(170,60,70,24); //otterFormat.addActionListener(this); dmlFormat = new JCheckBox("SSF"); this.add(dmlFormat); dmlFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! dmlFormat.setBounds(240, 60, 70, 24); dmlFormat.setToolTipText("Export for simulation in SSFNet"); //dmlFormat.addActionListener(this); nsFormat = new JCheckBox("NS"); this.add(nsFormat); nsFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! nsFormat.setBounds(310, 60, 50, 24); nsFormat.setToolTipText("Export for simulation in NS-2"); javasimFormat = new JCheckBox("JSim"); this.add(javasimFormat); javasimFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! javasimFormat.setBounds(360, 60, 70, 24); javasimFormat.setToolTipText("Export for simulation in Javasim"); JLabel32.setText("Location:"); this.add(JLabel32); JLabel32.setForeground(java.awt.Color.black); --- 58,95 ---- briteFormat.setSelected(true); this.add(briteFormat); briteFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! briteFormat.setBounds(80, 60, 60, 24); //briteFormat.addActionListener(this); otterFormat = new JCheckBox("Otter"); this.add(otterFormat); otterFormat.setToolTipText("Export for visualization in Otter"); otterFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! otterFormat.setBounds(140,60,60,24); //otterFormat.addActionListener(this); dmlFormat = new JCheckBox("SSF"); this.add(dmlFormat); dmlFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! dmlFormat.setBounds(200, 60, 50, 24); dmlFormat.setToolTipText("Export for simulation in SSFNet"); //dmlFormat.addActionListener(this); nsFormat = new JCheckBox("NS"); this.add(nsFormat); nsFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! nsFormat.setBounds(250, 60, 40, 24); nsFormat.setToolTipText("Export for simulation in NS-2"); javasimFormat = new JCheckBox("JSim"); this.add(javasimFormat); javasimFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); ! javasimFormat.setBounds(295, 60, 50, 24); javasimFormat.setToolTipText("Export for simulation in Javasim"); + omnetppFormat = new JCheckBox("OMNeT++"); + this.add(omnetppFormat); + omnetppFormat.setFont(new Font("SansSerif", Font.PLAIN, 12)); + omnetppFormat.setBounds(350, 60, 80, 24); + omnetppFormat.setToolTipText("Export for simulation in OMNeT++"); + JLabel32.setText("Location:"); this.add(JLabel32); JLabel32.setForeground(java.awt.Color.black); diff -r -c -N BRITE/GUI/FileConverter.java BRITE.new/GUI/FileConverter.java *** BRITE/GUI/FileConverter.java Thu Jan 1 01:00:00 1970 --- BRITE.new/GUI/FileConverter.java Wed Nov 14 18:13:44 2007 *************** *** 0 **** --- 1,773 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package GUI; + + import java.awt.*; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + import java.awt.event.ComponentListener; + import java.awt.event.ItemEvent; + import java.awt.event.ItemListener; + import java.io.File; + import java.util.ArrayList; + import java.util.List; + import java.util.regex.Matcher; + import java.util.regex.Pattern; + + import javax.swing.ButtonGroup; + import javax.swing.JButton; + import javax.swing.JFileChooser; + import javax.swing.JFrame; + import javax.swing.JLabel; + import javax.swing.JMenu; + import javax.swing.JMenuBar; + import javax.swing.JMenuItem; + import javax.swing.JOptionPane; + import javax.swing.JPanel; + import javax.swing.JRadioButton; + import javax.swing.JRadioButtonMenuItem; + import javax.swing.JTextField; + import javax.swing.border.LineBorder; + import javax.swing.filechooser.FileFilter; + + import Export.BriteExport; + import Export.OmnetppExport; + import Filter.FilterSettings; + import Import.SkitterImport; + import Model.FileModel; + import Model.ModelConstants; + import Topology.Topology; + import Util.Util; + + + + public class FileConverter extends JFrame{ + + private static int SKITTER = 1; + private static int BRITE = 2; + private static int OMNET = 3; + private static int DIMES = 4; + + private Main.FileConverter fileConverter; + private FilterSettings filterSettings; + + private JMenuBar menuBar; + + private JMenu fileMenu; + private JMenu helpMenu; + + private JPanel jPanel; + + private JLabel fileSrcLabel; + private JLabel fileDstLabel; + + + private JButton convertButton; + private JButton srcDirectoryButton; + private JButton dstDirectoryButton; + private JButton filterButton; + private JButton addSrc2ListButton; + private JButton removeSrcFromListButton; + + private JTextField srcTextField; + private JTextField dstTextField; + + private JRadioButton convertFormatRadioSkitter2brite; + private JRadioButton convertFormatRadioSkitter2omnet; + private JRadioButton convertFormatRadioBrite2omnet; + + private JRadioButton ASRadioButton; + private JRadioButton RTRadioButton; + + private ButtonGroup convertFormatGroup; + + private ButtonGroup ASorRTGroup; + + private Choice convertFormat; + private Choice srcListChoice; + + LineBorder lineBorder = new LineBorder(java.awt.Color.black); + + + private String srcFile; + private String dstFile; + private String selectedItem; + private int visibleSettings = SKITTER; + + private int srcFormat = SKITTER; + private int dstFormat = OMNET; + + private int ASorRT = ModelConstants.RT_FILE; + + private List srcList = new ArrayList(); + + + public FileConverter(){ + + + setJMenuBar(createJMenuBar()); + setContentPane(createJPanel()); + + setBounds(0, 0, 640, 260); + setTitle("FileConverter"); + setResizable(false); + filterSettings = new FilterSettings(); + } + + private JPanel createJPanel() { + + jPanel = new JPanel(); + jPanel.setBackground(new java.awt.Color(204,204,204)); + fileSrcLabel = new JLabel("Source file:"); + fileDstLabel = new JLabel("Destination file:"); + + jPanel.setLayout(null); + + fileSrcLabel.setBounds(20, 10, 70, 20); + fileDstLabel.setBounds(20, 60, 100, 20); + + jPanel.add(createSrcDirectoryButton(), null); + jPanel.add(createDstDirectoryButton(), null); + jPanel.add(createFilterButton(), null); + jPanel.add(fileSrcLabel, null); + jPanel.add(fileDstLabel, null); + jPanel.add(createSrcTextField(), null); + jPanel.add(createDstTextField(), null); + // createConvertFormat(); + // jPanel.add(convertFormatRadioSkitter2brite); + // jPanel.add(convertFormatRadioSkitter2omnet); + // jPanel.add(convertFormatRadioBrite2omnet); + jPanel.add(createConvertButton(), null); + createASorRTRadioButtons(); + jPanel.add(ASRadioButton); + jPanel.add(RTRadioButton); + jPanel.add(createConvertFormatChoice()); + jPanel.add(createAddSrc2ListButton()); + jPanel.add(createRemoveSrcFromListButton()); + jPanel.add(createSrcListChoice()); + + + + return jPanel; + } + + private JMenuBar createJMenuBar(){ + + menuBar = new JMenuBar(); + + menuBar.add(createJMenuFile()); + menuBar.add(createJMenuHelp()); + + return menuBar; + } + + + private JMenu createJMenuFile() { + + fileMenu = new JMenu("File"); + // JMenuItem menuSettings = new JMenuItem("Settings"); + JMenuItem menuExit = new JMenuItem("Exit"); + + // menuSettings.addActionListener(new ActionListener(){ + // + // public void actionPerformed(ActionEvent e) + // { + // settings(); + // } + // } + // ); + + menuExit.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) + { + // System.exit(0); + dispose(); + + } + } + ); + + // fileMenu.add(menuSettings); + fileMenu.add(menuExit); + + return fileMenu; + } + + private JMenu createJMenuHelp() { + + helpMenu = new JMenu("Help"); + JMenuItem menuAbout = new JMenuItem("About"); + menuAbout.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) + { + about(); + } + } + ); + helpMenu.add(menuAbout); + + return helpMenu; + } + + private JButton createSrcDirectoryButton(){ + + srcDirectoryButton = new JButton(); + srcDirectoryButton.setBorder(lineBorder); + srcDirectoryButton.setBounds(225, 35, 40, 20); + srcDirectoryButton.setText("..."); + srcDirectoryButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e){ + JFileChooser fc = new JFileChooser(); + fc.setFileFilter(new FileFilter() { + + public boolean accept(File f){ + if (getSrcFormat() == SKITTER){ + return f.isDirectory() || f.getName().toLowerCase().endsWith(".skitter"); + } + else if(getSrcFormat() == BRITE){ + return f.isDirectory() || f.getName().toLowerCase().endsWith(".brite"); + } + else if(getSrcFormat() == DIMES){ + return f.isDirectory() || f.getName().toLowerCase().endsWith(".csv"); + } + else{ + return false; + } + } + + public String getDescription(){ + if (getSrcFormat() == SKITTER){ + return "Skitter-Files (sk-analysis_dump file)"; + } + else if(getSrcFormat() == BRITE){ + return "Brite-Files"; + } + else if(getSrcFormat() == DIMES){ + return "DIMES-Files"; + } + else{ + return ""; + } + + } + + } + ); + int returnVal = fc.showOpenDialog(null); + if(returnVal == 0){ + File file = fc.getSelectedFile(); + srcFile = file.getPath(); + setSrcTextField(srcFile); + + } + } + + } + ); + + return srcDirectoryButton; + } + + private JButton createDstDirectoryButton(){ + + dstDirectoryButton = new JButton(); + dstDirectoryButton.setBorder(lineBorder); + dstDirectoryButton.setBounds(225, 85, 40, 20); + dstDirectoryButton.setText("..."); + dstDirectoryButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e){ + JFileChooser fc = new JFileChooser(); + + int returnVal = fc.showSaveDialog(null); + if(returnVal == 0){ + File file = fc.getSelectedFile(); + dstFile = file.getPath(); + setDstTextField(dstFile); + + } + } + + } + ); + + return dstDirectoryButton; + } + + private JButton createConvertButton(){ + + convertButton = new JButton(); + convertButton.setBorder(lineBorder); + // convertButton.setBounds(300, 35, 80, 20); + convertButton.setBounds(530, 145, 80, 40); + convertButton.setText("convert"); + convertButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + convert(); + } + + } + ); + + return convertButton; + } + + private JButton createFilterButton(){ + + filterButton = new JButton(); + filterButton.setBorder(lineBorder); + filterButton.setBounds(140, 165, 80, 20); + filterButton.setText("Filter"); + filterButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + filter(); + } + + } + ); + + return filterButton; + } + + private void createConvertFormat(){ + + convertFormatRadioSkitter2brite = new JRadioButton("skitter > brite"); + convertFormatRadioSkitter2omnet = new JRadioButton("skitter > omnet"); + convertFormatRadioBrite2omnet = new JRadioButton("brite > omnet"); + + convertFormatRadioSkitter2brite.setBounds(20, 125, 140, 20); + convertFormatRadioSkitter2brite.setBackground(new java.awt.Color(214,214,214)); + convertFormatRadioSkitter2omnet.setBounds(20, 145, 140, 20); + convertFormatRadioSkitter2omnet.setBackground(new java.awt.Color(214,214,214)); + convertFormatRadioBrite2omnet.setBounds(20, 165, 140, 20); + convertFormatRadioBrite2omnet.setBackground(new java.awt.Color(214,214,214)); + + convertFormatGroup = new ButtonGroup(); + convertFormatGroup.add(convertFormatRadioSkitter2brite); + convertFormatGroup.add(convertFormatRadioSkitter2omnet); + convertFormatGroup.add(convertFormatRadioBrite2omnet); + + convertFormatRadioSkitter2omnet.setSelected(true); + + convertFormatRadioSkitter2brite.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) + { + setSrcDstFormat(SKITTER, BRITE); + // ASRadioButton.setVisible(true); + // RTRadioButton.setVisible(true); + } + } + ); + + convertFormatRadioSkitter2omnet.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) + { + setSrcDstFormat(SKITTER, OMNET); + // ASRadioButton.setVisible(true); + // RTRadioButton.setVisible(true); + } + } + ); + + convertFormatRadioBrite2omnet.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) + { + setSrcDstFormat(BRITE, OMNET); + // ASRadioButton.setVisible(false); + // RTRadioButton.setVisible(false); + } + } + ); + + } + + private void createASorRTRadioButtons(){ + + ASRadioButton = new JRadioButton("AS"); + RTRadioButton = new JRadioButton("RT"); + + + // ASRadioButton.setBounds(170, 165, 50, 20); + ASRadioButton.setBounds(20, 165, 50, 20); + ASRadioButton.setBackground(new java.awt.Color(214,214,214)); + // RTRadioButton.setBounds(220, 165, 50, 20); + RTRadioButton.setBounds(70, 165, 50, 20); + RTRadioButton.setBackground(new java.awt.Color(214,214,214)); + + ASorRTGroup = new ButtonGroup(); + ASorRTGroup.add(ASRadioButton); + ASorRTGroup.add(RTRadioButton); + RTRadioButton.setSelected(true); + + ASRadioButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) + { + setASorRT(ModelConstants.AS_FILE); + } + } + ); + + RTRadioButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) + { + setASorRT(ModelConstants.RT_FILE); + } + } + ); + + } + + + private JTextField createSrcTextField(){ + srcTextField = new JTextField(); + srcTextField.setBorder(lineBorder); + srcTextField.setBounds(20, 35, 200, 20); + srcTextField.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + about(); + } + + } + ); + return srcTextField; + } + + private JTextField createDstTextField(){ + dstTextField = new JTextField(); + dstTextField.setBorder(lineBorder); + dstTextField.setBounds(20, 85, 200, 20); + dstTextField.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + about(); + } + + } + ); + return dstTextField; + } + + + private Choice createConvertFormatChoice(){ + + convertFormat = new Choice(); + convertFormat.setBounds(20, 125, 140, 20); + convertFormat.setBackground(new java.awt.Color(214,214,214)); + convertFormat.setForeground(new java.awt.Color(0,0,0)); + + final String skiter2brite = "skitter > brite"; + final String skiter2omnet = "skitter > omnet"; + final String brite2omnet = "brite > omnet"; + final String dimes2brite = "dimes > brite"; + final String dimes2omnet = "dimes > omnet"; + + convertFormat.add(skiter2brite); + convertFormat.add(skiter2omnet); + convertFormat.add(brite2omnet); + convertFormat.add(dimes2brite); + convertFormat.add(dimes2omnet); + + convertFormat.select(skiter2omnet); + + convertFormat.addItemListener(new ItemListener(){ + public void itemStateChanged(ItemEvent e){ + String selectedItem = (String) e.getItem(); + + if(selectedItem.equals(skiter2brite)){ + setSrcDstFormat(SKITTER, BRITE); + setVisibleSettings(SKITTER); + } + else if(selectedItem.equals(skiter2omnet)){ + setSrcDstFormat(SKITTER, OMNET); + setVisibleSettings(SKITTER); + } + else if(selectedItem.equals(brite2omnet)){ + setSrcDstFormat(BRITE, OMNET); + setVisibleSettings(BRITE); + } + else if(selectedItem.equals(dimes2brite)){ + setSrcDstFormat(DIMES, BRITE); + setVisibleSettings(DIMES); + } + else if(selectedItem.equals(dimes2omnet)){ + setSrcDstFormat(DIMES, OMNET); + setVisibleSettings(DIMES); + } + + } + } + ); + + return convertFormat; + } + + private JButton createAddSrc2ListButton(){ + + addSrc2ListButton = new JButton(); + addSrc2ListButton.setBorder(lineBorder); + addSrc2ListButton.setBounds(285, 35, 40, 20); + addSrc2ListButton.setText("add >"); + addSrc2ListButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + srcListChoice.add(getSrcFile()); + addSrc2List(getSrcFile()); + } + + } + ); + + return addSrc2ListButton; + } + + private JButton createRemoveSrcFromListButton(){ + + removeSrcFromListButton = new JButton(); + removeSrcFromListButton.setBorder(lineBorder); + removeSrcFromListButton.setBounds(565, 35, 40, 20); + removeSrcFromListButton.setText("< del"); + removeSrcFromListButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + removeSelectedItemFromList(selectedItem); + srcListChoice.remove(selectedItem); + } + + } + ); + + return removeSrcFromListButton; + } + + private Choice createSrcListChoice(){ + + srcListChoice = new Choice(); + srcListChoice.setBounds(345, 35, 200, 20); + srcListChoice.setBackground(new java.awt.Color(214,214,214)); + srcListChoice.setForeground(new java.awt.Color(0,0,0)); + + + + srcListChoice.addItemListener(new ItemListener(){ + public void itemStateChanged(ItemEvent e){ + selectedItem = (String) e.getItem(); + } + } + ); + + return srcListChoice; + } + + private void addSrc2List(String s){ + srcList.add(s); + } + + + private void setSrcTextField(String s){ + srcTextField.setText(s); + } + + private void setDstTextField(String s){ + dstTextField.setText(s); + } + + private void setSrcDstFormat(int s, int d){ + this.srcFormat = s; + this.dstFormat = d; + + } + + private void setASorRT(int i){ + this.ASorRT = i; + } + + private int getASorRT(){ + return this.ASorRT; + } + + public void settings(){ + String message = "Comming soon"; + JOptionPane.showMessageDialog(null, message); + } + + + private void about(){ + String message = "FileConverter - A BRITE Extension"; + JOptionPane.showMessageDialog(null, message); + } + + private void warning(String s){ + String message = s; + JOptionPane.showMessageDialog(null, message); + } + + public void filter(){ + Filter f = new Filter(this, filterSettings); + f.setVisible(true); + } + + private void removeSelectedItemFromList(String s){ + srcList.remove(s); + } + + private void convert(){ + boolean isOK; + srcFile = getSrcFile(); + dstFile = getDstFile(); + + + if (srcFile != null && !srcFile.equals("")){ + isOK = true; + } + else{ + isOK = false; + warning("please enter source path"); + } + + if (dstFile != null && !dstFile.equals("")){ + isOK = true; + } + else{ + isOK = false; + warning("please enter destination path"); + } + if((visibleSettings == SKITTER || visibleSettings == DIMES) && !srcList.isEmpty()){ + isOK = true; + } + else if((visibleSettings == SKITTER || visibleSettings == DIMES) && srcList.isEmpty()){ + isOK = false; + warning("please enter sourc paths"); + } + + if (isOK){ + //starte Anwendeung + if(getSrcFormat() == SKITTER && getDstFormat() == BRITE){ + + fileConverter = new Main.FileConverter(); + fileConverter.convertSkitter2Brite(srcList, getDstFile(), getASorRT(), getFilterSettings()); + } + + else if(getSrcFormat() == SKITTER && getDstFormat() == OMNET){ + + fileConverter = new Main.FileConverter(); + fileConverter.convertSkitter2Omnet(srcList, getDstFile(), getASorRT(), getFilterSettings()); + } + else if(getSrcFormat() == BRITE && getDstFormat() == OMNET){ + + fileConverter = new Main.FileConverter(); + fileConverter.convertBrite2Omnet(getSrcFile(), getDstFile(), getASorRT(), getFilterSettings()); + } + else if(getSrcFormat() == DIMES && getDstFormat() == BRITE){ + + fileConverter = new Main.FileConverter(); + fileConverter.convertDimes2Brite(srcList, getDstFile(), getASorRT(), getFilterSettings()); + } + else if(getSrcFormat() == DIMES && getDstFormat() == OMNET){ + + fileConverter = new Main.FileConverter(); + fileConverter.convertDimes2Omnet(srcList, getDstFile(), getASorRT(), getFilterSettings()); + } + } + } + + private void setVisibleSettings(int settings){ + if(settings == SKITTER){ + addSrc2ListButton.setVisible(true); + srcListChoice.setVisible(true); + removeSrcFromListButton.setVisible(true); + visibleSettings = SKITTER; + + } + else if(settings == DIMES){ + addSrc2ListButton.setVisible(true); + srcListChoice.setVisible(true); + removeSrcFromListButton.setVisible(true); + visibleSettings = DIMES; + } + else{ + addSrc2ListButton.setVisible(false); + srcListChoice.setVisible(false); + removeSrcFromListButton.setVisible(false); + visibleSettings = BRITE; + } + } + + private String getSrcFile(){ + return srcTextField.getText(); + } + + private String getDstFile(){ + return dstTextField.getText(); + } + + private int getSrcFormat(){ + return srcFormat; + } + + private int getDstFormat(){ + return dstFormat; + } + + private boolean checkForRegularExpression(String s) + { + Pattern p = Pattern.compile("[1-9]{1}[0-9]*"); + Matcher m = p.matcher(s); + return !m.matches(); + } + + protected void setFilterSettings(FilterSettings fs){ + this.filterSettings = fs; + } + + private FilterSettings getFilterSettings(){ + return filterSettings; + } + + public static void main(String argv[]) + { + FileConverter fc = new FileConverter(); + fc.setVisible(true); + + } + + } diff -r -c -N BRITE/GUI/Filter.java BRITE.new/GUI/Filter.java *** BRITE/GUI/Filter.java Thu Jan 1 01:00:00 1970 --- BRITE.new/GUI/Filter.java Wed Nov 14 18:13:44 2007 *************** *** 0 **** --- 1,418 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package GUI; + + import java.awt.Choice; + import java.awt.event.ActionEvent; + import java.awt.event.ActionListener; + import java.awt.event.ItemEvent; + import java.awt.event.ItemListener; + import java.util.regex.Matcher; + import java.util.regex.Pattern; + + import javax.swing.JButton; + import javax.swing.JFrame; + import javax.swing.JLabel; + import javax.swing.JOptionPane; + import javax.swing.JPanel; + import javax.swing.JTextField; + import javax.swing.border.LineBorder; + + import Filter.FilterConstants; + import Filter.FilterSettings; + import GUI.FileConverter; + + public class Filter extends JFrame { + + private FilterSettings filterSettings; + private FileConverter fc; + + private JPanel jPanel; + + private JLabel filterTypeLabel; + private JLabel maxHopLabel; + private JLabel searchedIDLabel; + private JLabel maxNodeLabel; + private JLabel meanDegreeLabel; + + private JTextField maxHopField; + private JTextField searchedIDField; + private JTextField maxNodeField; + private JTextField meanDegreeField; + + private JButton saveButton; + private JButton cancelButton; + + private Choice filterType; + + private int type; + private int nodeID; + private String ip; + private int maxHop; + private int maxNodes; + private double meanDegree; + + LineBorder lineBorder = new LineBorder(java.awt.Color.black); + + + public Filter(FileConverter fc, FilterSettings filterSettings){ + this.fc = fc; + this.filterSettings = filterSettings; + setFilterType(filterSettings.getFilterType()); + setNodeID(filterSettings.getNodeID()); + setIP(filterSettings.getIP()); + setMaxHop(filterSettings.getMaxHop()); + + setContentPane(createJPanel()); + + setBounds(0, 0, 280, 195); + setTitle("FileConverter"); + setResizable(false); + } + + private JPanel createJPanel() { + + jPanel = new JPanel(); + jPanel.setBackground(new java.awt.Color(204,204,204)); + filterTypeLabel = new JLabel("Filter type:"); + maxHopLabel = new JLabel("radius:"); + searchedIDLabel = new JLabel("IP or NodeID:"); + meanDegreeLabel = new JLabel("mean degree:"); + maxNodeLabel = new JLabel("max nodes:"); + + jPanel.setLayout(null); + + filterTypeLabel.setBounds(20, 20, 90, 20); + searchedIDLabel.setBounds(20, 60, 90, 20); + maxHopLabel.setBounds(20, 90, 60, 20); + maxNodeLabel.setBounds(20, 60, 90, 20); + meanDegreeLabel.setBounds(20, 90, 90, 20); + + + jPanel.add(filterTypeLabel); + jPanel.add(searchedIDLabel); + jPanel.add(maxHopLabel); + jPanel.add(maxNodeLabel); + jPanel.add(meanDegreeLabel); + jPanel.add(createSaveButton()); + jPanel.add(createCancelButton()); + jPanel.add(createFilterTypeChoice(), null); + jPanel.add(createMaxHopTextField()); + jPanel.add(createSearchedIDTextField()); + jPanel.add(createMaxNodesTextField()); + jPanel.add(createMeanDegreeTextField()); + + if(filterSettings.getFilterType() == FilterConstants.NONE){ + setMaxHopFilterOptions(false); + setMapSamplingFilterOptions(false); + } + else if(filterSettings.getFilterType() == FilterConstants.MAX_HOP_FILTER){ + setMaxHopFilterOptions(true); + setMapSamplingFilterOptions(false); + } + else if(filterSettings.getFilterType() == FilterConstants.MAP_SAMPLING_FILTER){ + setMaxHopFilterOptions(false); + setMapSamplingFilterOptions(true); + } + + setMaxHopTextField(new Integer(filterSettings.getMaxHop()).toString()); + if(filterSettings.getNodeID() == -1){ + setSearchedIDTextField(ip); + } + else{ + setSearchedIDTextField(new Integer(filterSettings.getNodeID()).toString()); + } + setMaxNodesTextField(new Integer(filterSettings.getMaxNodes()).toString()); + setMeanDegreeTextField(new Double(filterSettings.getMeanDegree()).toString()); + + return jPanel; + } + + + + private Choice createFilterTypeChoice(){ + + filterType = new Choice(); + filterType.setBounds(110, 20, 140, 20); + filterType.setBackground(new java.awt.Color(214,214,214)); + filterType.setForeground(new java.awt.Color(0,0,0)); + + final String none = "None"; + final String maxHopFilter = "MaxHopFilter"; + final String mapSamplingFilter = "MapSamplingFilter"; + + filterType.add(none); + filterType.add(maxHopFilter); + filterType.add(mapSamplingFilter); + + if (type == FilterConstants.NONE){ + filterType.select(0); + } + else if(type == FilterConstants.MAX_HOP_FILTER){ + filterType.select(1); + } + else if(type == FilterConstants.MAP_SAMPLING_FILTER){ + filterType.select(2); + } + + filterType.addItemListener(new ItemListener(){ + public void itemStateChanged(ItemEvent e){ + String selectedItem = (String) e.getItem(); + + if(selectedItem.equals(none)){ + setFilterType(FilterConstants.NONE); + setMaxHopFilterOptions(false); + setMapSamplingFilterOptions(false); + } + else if(selectedItem.equals(maxHopFilter)){ + setFilterType(FilterConstants.MAX_HOP_FILTER); + setMaxHopFilterOptions(true); + setMapSamplingFilterOptions(false); + } + else if(selectedItem.equals(mapSamplingFilter)){ + setFilterType(FilterConstants.MAP_SAMPLING_FILTER); + setMaxHopFilterOptions(false); + setMapSamplingFilterOptions(true); + } + + } + } + ); + + return filterType; + } + + private JButton createSaveButton(){ + + saveButton = new JButton(); + saveButton.setBorder(lineBorder); + saveButton.setBounds(110, 130, 60, 20); + saveButton.setText("save"); + saveButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + save(); + } + + } + ); + + return saveButton; + } + + private JButton createCancelButton(){ + + cancelButton = new JButton(); + cancelButton.setBorder(lineBorder); + cancelButton.setBounds(190, 130, 60, 20); + cancelButton.setText("cancel"); + cancelButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + cancel(); + } + + } + ); + + return cancelButton; + } + + private JTextField createMaxHopTextField(){ + maxHopField = new JTextField(); + maxHopField.setBorder(lineBorder); + maxHopField.setBounds(110, 90, 40, 20); + + return maxHopField; + } + + private JTextField createSearchedIDTextField(){ + searchedIDField = new JTextField(); + searchedIDField.setBorder(lineBorder); + searchedIDField.setBounds(110, 60, 140, 20); + + return searchedIDField; + } + + private JTextField createMeanDegreeTextField(){ + meanDegreeField = new JTextField(); + meanDegreeField.setBorder(lineBorder); + meanDegreeField.setBounds(110, 90, 40, 20); + + return meanDegreeField; + } + + private JTextField createMaxNodesTextField(){ + maxNodeField = new JTextField(); + maxNodeField.setBorder(lineBorder); + maxNodeField.setBounds(110, 60, 80, 20); + + return maxNodeField; + } + + private void setFilterType(int type){ + this.type = type; + } + + private void setMaxNodes(int maxNodes){ + this.maxNodes = maxNodes; + } + + private void setMeanDegree(double md){ + this.meanDegree = md; + } + + private void setMaxHop(int maxHop){ + this.maxHop = maxHop; + } + + private void setIP(String ip){ + this.ip = ip; + } + + private void setNodeID(int id){ + this.nodeID = id; + } + + private void setMaxHopTextField(String s){ + maxHopField.setText(s); + } + + private void setSearchedIDTextField(String s){ + searchedIDField.setText(s); + } + + private void setMaxNodesTextField(String s){ + maxNodeField.setText(s); + } + + private void setMeanDegreeTextField(String s){ + meanDegreeField.setText(s); + } + + private void setMaxHopFilterOptions(boolean b){ + maxHopLabel.setVisible(b); + maxHopField.setVisible(b); + searchedIDLabel.setVisible(b); + searchedIDField.setVisible(b); + } + + private void setMapSamplingFilterOptions(boolean b){ + maxNodeLabel.setVisible(b); + maxNodeField.setVisible(b); + meanDegreeLabel.setVisible(b); + meanDegreeField.setVisible(b); + } + + private void save(){ + String hop = getMaxHopField(); + String node = getSearchedIDField(); + + String maxNodes = getMaxNodeField(); + String meanDegree = getMeanDegreeField(); + + if(getFilterType() == FilterConstants.MAX_HOP_FILTER){ + + if(checkForDigits(hop)){ + warning("Only Digits allowed"); + } + else{ + setMaxHop(Integer.parseInt(hop)); + filterSettings.setMaxHop(Integer.parseInt(hop)); + } + + if(node.contains(".")){ + setIP(node); + filterSettings.setIP(node); + } + else{ + if(checkForDigits(node)){ + warning("Please enter an IP or a node ID"); + } + else{ + setNodeID(Integer.parseInt(node)); + filterSettings.setNodeID(Integer.parseInt(node)); + } + } + } + + else if(getFilterType() == FilterConstants.MAP_SAMPLING_FILTER){ + + if(checkForDigits(maxNodes)){ + warning("Only Digits allowed"); + } + else{ + setMaxNodes(Integer.parseInt(maxNodes)); + filterSettings.setMaxNodes(Integer.parseInt(maxNodes)); + } + setMeanDegree(Double.parseDouble(meanDegree)); + filterSettings.setMeanDegree(Double.parseDouble(meanDegree)); + } + + + filterSettings.setFilterType(type); + fc.setFilterSettings(filterSettings); + dispose(); + } + + private void cancel(){ + dispose(); + } + + private String getMaxHopField(){ + return maxHopField.getText(); + } + + private String getSearchedIDField(){ + return searchedIDField.getText(); + } + + private String getMaxNodeField(){ + return maxNodeField.getText(); + } + + private String getMeanDegreeField(){ + return meanDegreeField.getText(); + } + + private int getFilterType(){ + return this.type; + } + + private boolean checkForDigits(String s) + { + Pattern p = Pattern.compile("[0-9]{1}[0-9]*"); + Matcher m = p.matcher(s); + return !m.matches(); + } + + private void warning(String s){ + String message = s; + JOptionPane.showMessageDialog(null, message); + } + } diff -r -c -N BRITE/Java/Export/BriteExport.java BRITE.new/Java/Export/BriteExport.java *** BRITE/Java/Export/BriteExport.java Wed Apr 24 12:22:33 2002 --- BRITE.new/Java/Export/BriteExport.java Wed Nov 14 18:19:34 2007 *************** *** 18,32 **** /****************************************************************************/ /* */ /* Author: Alberto Medina */ ! /* Anukool Lakhina */ /* Title: BRITE: Boston university Representative Topology gEnerator */ /* Revision: 2.0 4/02/2001 */ /****************************************************************************/ package Export; import Topology.*; import Model.*; import Graph.*; import Util.*; --- 18,38 ---- /****************************************************************************/ /* */ /* Author: Alberto Medina */ ! /* Anukool Lakhina */ ! /* Waldemar Spaet */ /* Title: BRITE: Boston university Representative Topology gEnerator */ /* Revision: 2.0 4/02/2001 */ + /* 2.1 8/16/2007 (-new constructor for filterSettings) */ + /* (-added boolean to distinguish between*/ + /* generated and imported topologies) */ /****************************************************************************/ package Export; import Topology.*; import Model.*; + import Filter.Filter; + import Filter.FilterSettings; import Graph.*; import Util.*; *************** *** 64,69 **** --- 70,80 ---- private BufferedWriter bw; private Graph g; private String modelStr; + //BE: (begin) + private boolean isCreatedTopolgy; + private FilterSettings fs; + private boolean isFilterSettingsActive = false; + //BE: (end) /** Class Constructor: Returns a BriteExport object which your code my keep around. Does not actually write the topology to the *************** *** 74,98 **** @param outFile the destination file to write the topology to. */ public BriteExport(Topology t, File outFile) { ! this.t = t; ! ! try { ! bw = new BufferedWriter(new FileWriter(outFile)); ! } ! catch (IOException e) { ! Util.ERR(" Error creating BufferedWriter in BriteExport: " + e); ! } ! g = t.getGraph(); ! modelStr = t.getModel().toString(); } /** Writes the contents of the topolgy in the BRITE format to the destination file specified in the constructor. */ public void export() { ! Util.MSG("Exporting to BRITE..."); try { bw.write("Topology: ( " + g.getNumNodes() + " Nodes, " + g.getNumEdges()+ " Edges )"); bw.newLine(); --- 85,135 ---- @param outFile the destination file to write the topology to. */ public BriteExport(Topology t, File outFile) { ! this.t = t; ! ! try { ! bw = new BufferedWriter(new FileWriter(outFile)); ! } ! catch (IOException e) { ! Util.ERR(" Error creating BufferedWriter in BriteExport: " + e); ! } ! //BE: (begin) ! g = t.getGraph(); ! modelStr = t.getModel().toString(); ! this.isCreatedTopolgy = g.getIsCreatedGraph(); ! //BE: (end) } + //BE: (begin) + public BriteExport(Topology t, File outFile, FilterSettings fs) { + this.t = t; + + try { + bw = new BufferedWriter(new FileWriter(outFile)); + } + catch (IOException e) { + Util.ERR(" Error creating BufferedWriter in BriteExport: " + e); + } + g = t.getGraph(); + modelStr = t.getModel().toString(); + this.isCreatedTopolgy = g.getIsCreatedGraph(); + this.fs = fs; + isFilterSettingsActive = true; + } + //BE: (end) /** Writes the contents of the topolgy in the BRITE format to the destination file specified in the constructor. */ public void export() { ! //BE: (begin) ! if (isFilterSettingsActive) { ! Filter filter = new Filter(g, fs); ! g = filter.filter(); ! } ! //BE: (end) ! Util.MSG("Exporting to BRITE..."); try { bw.write("Topology: ( " + g.getNumNodes() + " Nodes, " + g.getNumEdges()+ " Edges )"); bw.newLine(); *************** *** 171,177 **** Node src = e.getSrc(); Node dst = e.getDst(); double dist = e.getEuclideanDist(); ! double delay = e.getDelay(); int asFrom= src.getID(); int asTo = dst.getID(); if (src.getNodeConf() instanceof RouterNodeConf) --- 208,222 ---- Node src = e.getSrc(); Node dst = e.getDst(); double dist = e.getEuclideanDist(); ! //BE: (begin) ! double delay; ! if(isCreatedTopolgy){ ! delay = e.getDelay(); ! } ! else{ ! delay = e.getMeasuredDelay(); ! } ! //BE: (end) int asFrom= src.getID(); int asTo = dst.getID(); if (src.getNodeConf() instanceof RouterNodeConf) *************** *** 180,186 **** asTo =((RouterNodeConf) dst.getNodeConf()).getCorrAS(); bw.write(e.getID() + "\t" + src.getID() + "\t" + dst.getID()); ! bw.write("\t"+ dist + "\t" +delay+ "\t" + e.getBW()); bw.write("\t"+ asFrom + "\t" + asTo); --- 225,231 ---- asTo =((RouterNodeConf) dst.getNodeConf()).getCorrAS(); bw.write(e.getID() + "\t" + src.getID() + "\t" + dst.getID()); ! bw.write("\t"+ dist + "\t" + delay + "\t" + e.getBW()); bw.write("\t"+ asFrom + "\t" + asTo); *************** *** 195,201 **** else bw.write("\tE_AS"); } ! else /*we have a router*/{ int specificEdgeType = ((RouterEdgeConf)e.getEdgeConf()).getType(); if (specificEdgeType == ModelConstants.E_RT_STUB) bw.write("\tE_RT_STUB"); --- 240,247 ---- else bw.write("\tE_AS"); } ! ! else /*we have a router*/{ int specificEdgeType = ((RouterEdgeConf)e.getEdgeConf()).getType(); if (specificEdgeType == ModelConstants.E_RT_STUB) bw.write("\tE_RT_STUB"); diff -r -c -N BRITE/Java/Export/OmnetppExport.java BRITE.new/Java/Export/OmnetppExport.java *** BRITE/Java/Export/OmnetppExport.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Export/OmnetppExport.java Wed Nov 14 18:19:34 2007 *************** *** 0 **** --- 1,242 ---- + package Export; + + import Topology.*; + import Filter.Filter; + import Filter.FilterConstants; + import Filter.FilterSettings; + import Filter.MaxHopFilter; + import Graph.*; + import Model.*; + import Util.*; + + import java.io.*; + import java.util.*; + + + /** + * Export filter for OMNeT++ + */ + public class OmnetppExport { + + private Topology t; + private BufferedWriter bw; + private BufferedReader br; + private Graph g; + //BE: (begin) + private boolean isCreatedTopolgy; + private FilterSettings fs; + private boolean isFilterSettingsActive = false; + //BE: (end) + + public OmnetppExport(Topology t, File outFile) { + this.t = t; + try { + bw = new BufferedWriter(new FileWriter(outFile)); + } + catch (IOException e) { + Util.ERR("Error creating BufferedWriter in OmnetppExport: " +e); + } + g = t.getGraph(); + this.isCreatedTopolgy = g.getIsCreatedGraph(); + } + + //BE: (begin) + // Constructor + public OmnetppExport(Topology t, File outFile, FilterSettings fs) { + this.t = t; + try { + bw = new BufferedWriter(new FileWriter(outFile)); + } + catch (IOException e) { + Util.ERR("Error creating BufferedWriter in OmnetppExport: " +e); + } + g = t.getGraph(); + this.isCreatedTopolgy = g.getIsCreatedGraph(); + this.fs = fs; + isFilterSettingsActive = true; + } + //BE: (end) + + public void export() throws Exception { + //BE: (begin) + if (isFilterSettingsActive) { + Filter filter = new Filter(g, fs); + g = filter.filter(); + } + //BE: (end) + Util.MSG("Producing export file for OMNeT++ "); + + Node[] nodes = g.getNodesArray(); + + Arrays.sort(nodes, Node.IDcomparator); + Edge[] edges = g.getEdgesArray(); + Arrays.sort(edges, Edge.SrcIDComparator); + + + int maxid=0; + for (int i=0; imaxid) + maxid = id; + } + int in_lastused[] = new int[maxid+1]; + int out_lastused[] = new int[maxid+1]; + for (int i=0; i"); + // bw.write(" delay "+e.getDelay()+"ms datarate "+e.getBW()*1000000+" -->"); + bw.write(" delay " + delay + "ms datarate " + datarate + " -->"); + bw.write(" node" + destID + ".in[" + dstGateIndex + "];\n"); + + if (e.getDirection() != GraphConstants.DIRECTED) + { + // duplex + srcGateIndex = out_lastused[e.getSrc().getID()]++; + dstGateIndex = in_lastused[e.getDst().getID()]++; + //BE: (begin) + if(isCreatedTopolgy){ + delay = e.getDelay(); + } + else{ + delay = e.getMeasuredDelay(); + } + //BE: (end) + datarate = e.getBW() * 1000000; + bw.write(" node" + srcID + ".in[" + srcGateIndex + "] <--"); + bw.write(" delay " + delay + "ms datarate " + datarate + " <--"); + bw.write(" node" + destID + ".out[" + dstGateIndex + "];\n"); + } + } + bw.write("endmodule\n"); + bw.write("\n"); + + bw.write("//\n"); + bw.write("// Example network that instantiates BRITENetwork. For actual simulation,\n"); + bw.write("// provide a module type called InetNode with the same interface as\n"); + bw.write("// BRITENode above.\n"); + bw.write("//\n"); + bw.write("network aBRITENetwork: BRITENetwork\n"); + bw.write(" parameters:\n"); + bw.write(" nodetype = \"InetNode\";\n"); + bw.write("endnetwork\n"); + bw.write("\n"); + + bw.close(); + Util.MSG("... DONE."); + } + + + public static void convert(String briteFile, int format) throws Exception { + FileModel f = new FileModel(Import.ImportConstants.BRITE_FORMAT, briteFile, format); + Topology t = new Topology(f); + OmnetppExport oe = new OmnetppExport(t, new File(briteFile+"_omnetpp.ned")); + oe.export(); + } + + + public static void main(String args[]) throws Exception { + String briteFile = ""; + String routeroras = ""; + try { + briteFile = args[0]; + routeroras = args[1]; + } + catch (Exception e) { + Util.ERR("Usage: java Export.OmnetppExport RT {| AS}"); + } + + int format = ModelConstants.RT_FILE; + if (routeroras.equalsIgnoreCase("as")) + format = ModelConstants.AS_FILE; + + FileModel f = new FileModel(Import.ImportConstants.BRITE_FORMAT, briteFile, format); + + Topology t = new Topology(f); + OmnetppExport oe = new OmnetppExport(t, new File(briteFile+"_omnetpp.ned")); + oe.export(); + } + + } + diff -r -c -N BRITE/Java/Filter/Filter.java BRITE.new/Java/Filter/Filter.java *** BRITE/Java/Filter/Filter.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Filter/Filter.java Wed Nov 14 18:13:44 2007 *************** *** 0 **** --- 1,126 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + + package Filter; + + import com.sun.org.apache.bcel.internal.generic.NEW; + + import Graph.Graph; + import Topology.Topology; + + public class Filter { + + Graph g; + Graph gNew = new Graph(); + int filterType; + String ip = ""; + int nodeID = -1; + int maxHops; + int maxNodes; + double meanDegree; + Filter f; + + public Filter(Graph g){ + this.g = g; + + } + + /** Filter constructor to initialize a search for a known ip + @param g the Graph + @param ip the searched IP + @param maxHops the Integer create a "radius" around the IP + @param type the type of the Filter. See FilterConstants + */ + public Filter(Graph g, String ip, int maxHops, int type){ + this.g = g; + this.ip = ip; + this.maxHops = maxHops; + this.filterType = type; + createFilter(); + } + + /** Filter constructor to initialize a search for a node id + @param g the Graph + @param id the searched node-Id + @param maxHops the Integer create a "radius" around the id + @param type the type of the Filter. See FilterConstants + */ + public Filter(Graph g, int id, int maxHops, int type){ + this.g = g; + this.nodeID = id; + this.maxHops = maxHops; + this.filterType = type; + createFilter(); + } + + /** Filter constructor + @param g the Graph + @param fs the used Filtersettings + */ + public Filter(Graph g, FilterSettings fs){ + this.g = g; + this.nodeID = fs.getNodeID(); + this.maxHops = fs.getMaxHop(); + this.filterType = fs.getFilterType(); + this.meanDegree = fs.getMeanDegree(); + this.maxNodes = fs.getMaxNodes(); + createFilter(); + } + + /** method to create a Filter, depending on the filterType + */ + private void createFilter(){ + + if (filterType == FilterConstants.NONE){ + f = null; + } + + else if (filterType == FilterConstants.MAX_HOP_FILTER){ + if(nodeID == -1){ + f = new MaxHopFilter(g, ip, maxHops); + } + else{ + f = new MaxHopFilter(g, nodeID, maxHops); + } + + } + else if (filterType == FilterConstants.MAP_SAMPLING_FILTER){ + f = new MapSamplingFilter(g, maxNodes, meanDegree); + } + } + + /** returns the filtered Graph or the original GRap, depending on filterType + */ + public Graph filter(){ + if(f != null){ + return f.filter(); + } + else { + return g; + } + } + + } diff -r -c -N BRITE/Java/Filter/FilterConstants.java BRITE.new/Java/Filter/FilterConstants.java *** BRITE/Java/Filter/FilterConstants.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Filter/FilterConstants.java Wed Nov 14 18:13:44 2007 *************** *** 0 **** --- 1,34 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package Filter; + + public final class FilterConstants { + + public static int NONE = 0; + public static int MAX_HOP_FILTER = 1; + public static int MAP_SAMPLING_FILTER = 2; + + } diff -r -c -N BRITE/Java/Filter/FilterSettings.java BRITE.new/Java/Filter/FilterSettings.java *** BRITE/Java/Filter/FilterSettings.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Filter/FilterSettings.java Wed Nov 14 18:13:44 2007 *************** *** 0 **** --- 1,103 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package Filter; + + public class FilterSettings { + String ip; + int nodeID; + int maxHop; + int filterType; + int maxNodes; + double meanDegree; + + + public FilterSettings(){ + this.ip = ""; + this.nodeID = -1; + this.maxHop = 0; + this.maxNodes = 4000; + this.meanDegree = 2.4; + this.filterType = FilterConstants.NONE; + } + + // zum testen + // public FilterSettings(){ + // this.ip = ""; + // this.nodeID = -1; + // this.maxHop = 0; + // this.maxNodes = 4000; + // this.meanDegree = 2.4; + // this.filterType = FilterConstants.MAP_SAMPLING_FILTER; + // } + + public void setIP(String ip){ + this.ip = ip; + } + + public void setNodeID(int id){ + this.nodeID = id; + } + + public void setMaxHop(int maxHop){ + this.maxHop = maxHop; + } + + public void setMaxNodes(int i){ + this.maxNodes = i; + } + + public void setMeanDegree(double d){ + this.meanDegree = d; + } + + public void setFilterType(int type){ + this.filterType = type; + } + + public String getIP(){ + return this.ip; + } + + public int getNodeID(){ + return this.nodeID; + } + + public int getMaxHop(){ + return this.maxHop; + } + + public int getMaxNodes(){ + return this.maxNodes; + } + + public double getMeanDegree(){ + return this.meanDegree; + } + + public int getFilterType(){ + return this.filterType; + } + } diff -r -c -N BRITE/Java/Filter/MapSamplingFilter.java BRITE.new/Java/Filter/MapSamplingFilter.java *** BRITE/Java/Filter/MapSamplingFilter.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Filter/MapSamplingFilter.java Wed Nov 14 18:13:45 2007 *************** *** 0 **** --- 1,339 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package Filter; + + import java.util.ArrayList; + import java.util.Arrays; + import java.util.HashMap; + import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Random; + import java.util.Set; + + import javax.swing.text.html.HTMLEditorKit.LinkController; + + import Graph.Graph; + import Graph.Node; + import Graph.Edge; + import Util.Util; + + public class MapSamplingFilter extends Filter{ + + int maxNodes; + double md; + + int filterCandidateSize = 10; + double filterExponent = 1.1; + + Node[] nodeAdjList; + Edge[] edges; + int node_count; + int edge_count; + Set test_edge_set = new HashSet(); + List candidates; + List red_links; + Set edgeSet; + Map fullEdgeMap; + Set nodeSet; + + /** MaxHopFilter constructor to initialize a search for a node-id + @param g the Graph + @param i # of nodes in new graph + @param md mean degree + */ + public MapSamplingFilter(Graph g, int i, double md) { + super(g); + this.maxNodes = i; + this.md = md; + this.candidates = new ArrayList(); + this.red_links = new ArrayList(); + this.node_count = 0; + this.edge_count = 0; + this.edgeSet = new HashSet(); + this.nodeSet = new HashSet(); + this.fullEdgeMap = new HashMap(); + + } + + /** returns an ArrayList, containing the neigbors of node n + @param n node + */ + private List getNodeNeigborList(int n){ + return (ArrayList) fullEdgeMap.get(n); + } + + /** initialize chooses the first node of the graph + */ + private void init(){ + nodeAdjList = g.getNodesArray(); + Arrays.sort(nodeAdjList, Node.IDcomparator); + edges = g.getEdgesArray(); + Arrays.sort(edges, Edge.SrcIDComparator); + + + for(int i = 0; i < nodeAdjList.length; i++){ + fullEdgeMap.put(nodeAdjList[i].getID(), new ArrayList()); + } + + + for(int i = 0; i < edges.length; i++){ + int tempIdx = 0; + int idx1 = edges[i].getSrc().getID(); + int idx2 = edges[i].getDst().getID(); + + ((List)fullEdgeMap.get(idx1)).add(edges[i]); + ((List)fullEdgeMap.get(idx2)).add(edges[i]); + + } + + if ( maxNodes > (nodeAdjList.length * 0.3 )){ + // Util.ERR("sampled network maxNodes > 0.3 * source network size\n"); + } + Util.MSG("creating from source (sampling)...\n"); + Util.MSG("start of sampling algorithm: "); + + Random rand = new Random(); + int roll = rand.nextInt(nodeAdjList.length - 1); + + Node first_chosen = nodeAdjList[roll]; + // first_chosen.setCandidate(true); + first_chosen.setSelected(true); + node_count++; + nodeSet.add(first_chosen); + + List tempNeigbors = getNodeNeigborList(first_chosen.getID()); + Iterator it = tempNeigbors.iterator(); + Edge neighbors; + Node neighbor; + while(it.hasNext()){ + neighbors = (Edge)it.next(); + if(first_chosen.getID() == neighbors.getSrc().getID()){ + neighbor = neighbors.getDst(); + } + else{ + neighbor = neighbors.getSrc(); + } + neighbor.setCandidate(true); + neighbor.setConnecting_edge(neighbors); + candidates.add(neighbor); + } + } + + /** chooses other nodes and edges for the new graph + */ + private void TreeExtraction(){ + + // while(node_count < maxNodes){ + while(nodeSet.size() < maxNodes){ + Random rand = new Random(); + int roll; + if(candidates.size() > 1){ + roll = rand.nextInt(candidates.size() - 1); + } + else{ + roll = 0; + } + Node chosen = (Node) candidates.get(roll); + chosen.setSelected(true); + node_count++; + nodeSet.add(chosen); + Edge e = (Edge) chosen.getConnecting_edge(); + e.setSelected(true); + test_edge_set.add(e); + edge_count++; + + List tempNeigbors = getNodeNeigborList(chosen.getID()); + Iterator it = tempNeigbors.iterator(); + Edge neighbors; + Node neighbor; + while(it.hasNext()){ + neighbors = (Edge)it.next(); + if(chosen.getID() == neighbors.getSrc().getID()){ + neighbor = neighbors.getDst(); + } + else{ + neighbor = neighbors.getSrc(); + } + // Edge ee = (Edge) chosen.getConnecting_edge(); + Edge ee = (Edge) neighbors; + + if(!neighbor.getSelected()){ + if(!neighbor.getCandidate()){ + if(/* candidates.size() > filterCandidateSize && */ !filterCandidate(neighbor)){ + // continue; + neighbor.setCandidate(true); + neighbor.setConnecting_edge(ee); + candidates.add(neighbor); + } + + } + else if(rand.nextInt(99)+1 > 50){ + neighbor.setConnecting_edge(ee); + } + + } + else if(neighbor != ee.getSrc() || neighbor != ee.getDst()){ + // red_links.add(chosen.getConnecting_edge()); + red_links.add(ee); + } + } + + + + } + + + } + + /** adds egdes from the red_link list + */ + private void RedundancyLinkCreation(){ + edge_count = maxNodes - 1; + int same_link = 0; + int new_size = 0; + int old_size = 0; + + Util.MSG("Edge_Count: = " + test_edge_set.size()); + + while(true){ + Random rand = new Random(); + + int roll; + if(red_links.size() > 1){ + roll = rand.nextInt(red_links.size() - 1); + } + else{ + roll = 0; + } + + Edge chosen = (Edge) red_links.get(roll); + chosen.setSelected(true); + edgeSet.add(chosen); + red_links.remove(roll); + old_size = test_edge_set.size(); + test_edge_set.add(chosen); + new_size = test_edge_set.size(); + edge_count++; + + if(old_size != new_size){ + Iterator itt = test_edge_set.iterator(); + while (itt.hasNext()){ + Edge next = (Edge) itt.next(); + + if(chosen.getSrc() == next.getDst() && chosen.getDst() == next.getSrc()){ + same_link ++; + break; + } + } + } + + + // if(red_links.isEmpty() || test_edge_set.size() * 2 >= (md * maxNodes) /*/ 2*/){ + // break; + // } + if(red_links.isEmpty()){ + Util.MSG("red_links finsihed (md size not successful)"); + break; + } + else if( (test_edge_set.size() - same_link) * 2 >= ((md + 0.2) * maxNodes) /*/ 2*/){ + Util.MSG("red_links finsihed (md size successful)"); + break; + } + } + } + + /** discarding some of the candidate nodes + */ + private boolean filterCandidate(Node n){ + Random rand = new Random(); + int roll = rand.nextInt(99) + 1; + double exponent = filterExponent; + + + if(candidates.size() < 10 || roll < (100 - Math.pow(g.getNeighborsOf(n).length, exponent))){ + return false; + } + else{ + return true; + } + } + + /** adds chosen nodes and edges into the new graph + */ + private void buildNewGraph(){ + + Iterator iter = nodeSet.iterator(); + + while(iter.hasNext()){ + + Node n = (Node) iter.next(); + + /* This Method is very slow, in order to imporve the speed, you have to change the + * public Edge getEdge(Node src, Node dst) method from the Graph-class. This method returns + * the same id for an edge a > b and b > a, this is false. To improve the speed change this and use + * this method insteed of the iteration below. + */ + if(n.getConnecting_edge() != null){ + if(n.getConnecting_edge().getSelected()){ + Node src = n.getConnecting_edge().getSrc(); + Node dst = n.getConnecting_edge().getDst(); + for(int i = 0; i < edges.length; i++){ + if(edges[i].getSrc().getID() == src.getID() && edges[i].getDst().getID() == dst.getID()){ + edgeSet.add(edges[i]); + } + if(edges[i].getSrc().getID() == dst.getID() && edges[i].getDst().getID() == src.getID()){ + edgeSet.add(edges[i]); + } + } + edgeSet.add(n.getConnecting_edge()); + } + } + + gNew.addNode(n); + } + + Iterator it2 = edgeSet.iterator(); + + while(it2.hasNext()){ + gNew.addEdge((Edge) it2.next()); + } + } + + /** returns the new created graph + */ + public Graph filter(){ + init(); + TreeExtraction(); + RedundancyLinkCreation(); + buildNewGraph(); + Util.MSG("|V| = " + nodeSet.size() + " and |E| = " + edgeSet.size()); + + return gNew; + + } + } diff -r -c -N BRITE/Java/Filter/MaxHopFilter.java BRITE.new/Java/Filter/MaxHopFilter.java *** BRITE/Java/Filter/MaxHopFilter.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Filter/MaxHopFilter.java Wed Nov 14 18:13:45 2007 *************** *** 0 **** --- 1,348 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package Filter; + + + + import java.util.ArrayList; + import java.util.Arrays; + import java.util.HashMap; + import java.util.HashSet; + import java.util.Iterator; + import java.util.List; + import java.util.Map; + import java.util.Set; + + import Graph.Edge; + import Graph.Graph; + import Graph.GraphConstants; + import Graph.Node; + import Topology.Topology; + import Util.Util; + + public class MaxHopFilter extends Filter { + + private static int MAX_EDGES_PER_NODE = 200; + int maxHop; + int currentHop; + + int maxID; + int lowID; + + String id; + int searchedNodeID = -1; + + Node[] nodes; + Edge[] edges; + + Edge[][] edgeMatrix; + + Set edgeSet = new HashSet(); + List tempEdgeList = new ArrayList(); + Set nodeSet = new HashSet(); + + Map edgeMap = new HashMap(); + + + boolean firstRun = true; + + + /** MaxHopFilter constructor to initialize a search for a node-id + @param g the Graph + @param id the searched node-id + @param i the Integer create a "radius" around the id + */ + public MaxHopFilter(Graph g, String id, int i) { + super(g); + this.maxHop = i; + this.currentHop = i; + this.id = id; + + } + /** MaxHopFilter constructor to initialize a search for a node-ip + @param g the Graph + @param ip the searched node-ip + @param i the Integer create a "radius" around the ip + */ + public MaxHopFilter(Graph g, int id, int i) { + super(g); + this.maxHop = i; + this.currentHop = i; + this.id = Integer.toString(id); + this.searchedNodeID = id; + + } + + /** search for a node-id, if found, then this node will be added into the edgeSet + @param id the searched node-id + */ + public void searchHops(int id){ + + if(edgeMap.get(id) != null){ + Iterator it = ((ArrayList) edgeMap.get(id)).iterator(); + + while(it.hasNext()){ + edgeSet.add(it.next()); + } + } + else if(edgeMap.get(id) == null && firstRun){ + Util.MSG("Node" + id + " not found"); + } + + + } + + + /** filters the Graph + */ + public Graph filter(){ + nodes = g.getNodesArray(); + Arrays.sort(nodes, Node.IDcomparator); + edges = g.getEdgesArray(); + Arrays.sort(edges, Edge.SrcIDComparator); + + + for(int i = 0; i < nodes.length; i++){ + if(maxID < nodes[i].getID()){ + maxID = nodes[i].getID(); + } + if(lowID > nodes[i].getID()){ + lowID = nodes[i].getID(); + } + edgeMap.put(nodes[i].getID(), new ArrayList()); + } + + + for(int i = 0; i < edges.length; i++){ + int tempIdx = 0; + int idx1 = edges[i].getSrc().getID(); + int idx2 = edges[i].getDst().getID(); + + if(searchedNodeID == -1){ + if(edges[i].getSrc().getAddrS().equals(id)){ + searchedNodeID = edges[i].getSrc().getID(); + } + if(edges[i].getDst().getAddrS().equals(id)){ + searchedNodeID = edges[i].getDst().getID(); + } + } + + ((List)edgeMap.get(idx1)).add(edges[i]); + ((List)edgeMap.get(idx2)).add(edges[i]); + + } + + + Edge e; + + if (firstRun){ + searchHops(this.searchedNodeID); + maxHop--; + firstRun = false; + tempEdgeList.addAll(edgeSet); + } + + while (maxHop > 0){ + + Iterator it = tempEdgeList.iterator(); + + while (it.hasNext()){ + e = (Edge) it.next(); + + searchHops(e.getSrc().getID()); + searchHops(e.getDst().getID()); + + } + tempEdgeList.clear(); + tempEdgeList.addAll(edgeSet); + maxHop--; + } + + Iterator edgeIterator = edgeSet.iterator(); + + while(edgeIterator.hasNext()){ + e = (Edge) edgeIterator.next(); + gNew.addEdge(e); + nodeSet.add((e.getSrc())); + nodeSet.add((e.getDst())); + } + + Iterator nodeIterator = nodeSet.iterator(); + + while(nodeIterator.hasNext()){ + gNew.addNode((Node) nodeIterator.next()); + } + + Util.MSG("created new filtered graph, |V| = " + gNew.getNumNodes() + " and |E| = " + gNew.getNumEdges()); + + + return gNew; + } + + + // public void searchHops(int id){ + // + // int tempIdx = 0; + // + // while(edgeMatrix[id][tempIdx] != null){ + // edgeSet.add(edgeMatrix[id][tempIdx]); + // tempIdx++; + // } + // + // } + // + // + // public Graph filter(){ + // nodes = g.getNodesArray(); + // Arrays.sort(nodes, Node.IDcomparator); + // edges = g.getEdgesArray(); + // Arrays.sort(edges, Edge.SrcIDComparator); + // + // + // for(int i = 0; i < nodes.length; i++){ + // if(maxID < nodes[i].getID()){ + // maxID = nodes[i].getID(); + // } + // if(lowID > nodes[i].getID()){ + // lowID = nodes[i].getID(); + // } + // } + // edgeMatrix = new Edge[maxID + 1][MAX_EDGES_PER_NODE]; + // + // for(int i = 0; i <= maxID; i++){ + // for (int j = 0; j < MAX_EDGES_PER_NODE; j++){ + // edgeMatrix[i][j] = null; + // } + // } + // + // for(int i = 0; i < edges.length; i++){ + // int tempIdx = 0; + // int idx1 = edges[i].getSrc().getID(); + // int idx2 = edges[i].getDst().getID(); + // + // if(searchedNodeID == -1){ + // if(edges[i].getSrc().getAddrS().equals(id)){ + // searchedNodeID = edges[i].getSrc().getID(); + // } + // if(edges[i].getDst().getAddrS().equals(id)){ + // searchedNodeID = edges[i].getDst().getID(); + // } + // } + // + // while(edgeMatrix[idx1][tempIdx] != null){ + // tempIdx++; + // } + // edgeMatrix[idx1][tempIdx] = edges[i]; + // + // tempIdx = 0; + // while(edgeMatrix[idx2][tempIdx] != null){ + // tempIdx++; + // } + // edgeMatrix[idx2][tempIdx] = edges[i]; + // + // } + // + // + // Edge e; + // + // if (firstRun){ + // searchHops(this.searchedNodeID); + // maxHop--; + // firstRun = false; + // tempEdgeList.addAll(edgeSet); + // } + // + // while (maxHop > 0){ + // + // Iterator it = tempEdgeList.iterator(); + // + // while (it.hasNext()){ + // e = (Edge) it.next(); + // + // searchHops(e.getSrc().getID()); + // searchHops(e.getDst().getID()); + // + // } + // tempEdgeList.clear(); + // tempEdgeList.addAll(edgeSet); + // maxHop--; + // } + // + // Iterator edgeIterator = edgeSet.iterator(); + // + // while(edgeIterator.hasNext()){ + // e = (Edge) edgeIterator.next(); + // gNew.addEdge(e); + // nodeSet.add((e.getSrc())); + // nodeSet.add((e.getDst())); + // } + // + // Iterator nodeIterator = nodeSet.iterator(); + // + // while(nodeIterator.hasNext()){ + // gNew.addNode((Node) nodeIterator.next()); + // } + // + // Util.MSG("created new filtered graph, |V| = " + gNew.getNumNodes() + " and |E| = " + gNew.getNumEdges()); + // + // + // return gNew; + // } + + + public void checkEdges(){ + + List testList = new ArrayList(); + List testList2 = new ArrayList(); + + String oldSrc; + String oldDst; + String src; + String dst; + String srcID; + String dstID; + + for (int i = 0; i < edges.length; i++){ + testList.add(edges[i]); + } + Iterator it = testList.iterator(); + while(it.hasNext()){ + Edge e = (Edge) it.next(); + + for (int i = 0; i < edges.length; i++){ + srcID = edges[i].getSrc().getAddrS(); + dstID = edges[i].getDst().getAddrS(); + + if ((srcID.equals(e.getSrc().getAddrS())) && (dstID.equals(e.getDst().getAddrS())) ){ + testList2.add(e); + } + + } + + } + } + + } diff -r -c -N BRITE/Java/Graph/Edge.java BRITE.new/Java/Graph/Edge.java *** BRITE/Java/Graph/Edge.java Wed Apr 24 04:03:39 2002 --- BRITE.new/Java/Graph/Edge.java Wed Nov 14 18:13:45 2007 *************** *** 19,32 **** --- 19,40 ---- /* */ /* Author: Alberto Medina */ /* Anukool Lakhina */ + /* Waldemar Spaet */ /* Title: BRITE: Boston university Representative Topology gEnerator */ /* Revision: 2.0 4/02/2001 */ + /* 2.1 8/16/2007 (-new functions to support */ + /* MapSamplingFilter) */ + /* (-new method to set the readed delay) */ + /* (-new method to set more than one */ + /* delay for an edge */ /****************************************************************************/ package Graph; import java.lang.*; + import java.util.ArrayList; import java.util.Comparator; + import java.util.List; *************** *** 68,73 **** --- 76,85 ---- EdgeConf e; double delay = -1; static double SPEEDOFLIGHT = 299792458.0; + //BE: (begin) + List delays = new ArrayList(); + boolean selected = false; + //BE: (end) static int edgeCount=-1; public static EdgeIDComparator IDcomparator = new EdgeIDComparator(); *************** *** 221,227 **** --- 233,253 ---- delay = (1000.0*1000.0* (double)dist)/SPEEDOFLIGHT; return delay; } + //BE: (begin) + public double getMeasuredDelay() { + return delay; + } + + public void addDelay(double d) { + delays.add(d); + } + + public List getDelayList(){ + return delays; + } + //BE: (end) + /*get methods*/ public Node getSrc() { return src; } public Node getDst() { return dst; } *************** *** 238,243 **** --- 264,274 ---- public void setEdgeConf(EdgeConf e) { this.e = e; } public void setBW(double bw) { this.BW = bw; } public void setEuclideanDist(double d) { this.dist = d;} + public void setDelay(double d) { this.delay = d;} + //BE: (begin) + public boolean getSelected() { return this.selected; } + public void setSelected(boolean b) { this.selected = b; } + //BE: (end) } diff -r -c -N BRITE/Java/Graph/Graph.java BRITE.new/Java/Graph/Graph.java *** BRITE/Java/Graph/Graph.java Tue Apr 23 17:49:48 2002 --- BRITE.new/Java/Graph/Graph.java Wed Nov 14 18:13:45 2007 *************** *** 18,26 **** /****************************************************************************/ /* */ /* Author: Alberto Medina */ ! /* Anukool Lakhina */ /* Title: BRITE: Boston university Representative Topology gEnerator */ /* Revision: 2.0 4/02/2001 */ /****************************************************************************/ package Graph; --- 18,29 ---- /****************************************************************************/ /* */ /* Author: Alberto Medina */ ! /* Anukool Lakhina */ ! /* Waldemar Spaet */ /* Title: BRITE: Boston university Representative Topology gEnerator */ /* Revision: 2.0 4/02/2001 */ + /* 2.1 8/16/2007 (-added boolean to distinguish between*/ + /* generated and imported topologies) */ /****************************************************************************/ package Graph; *************** *** 71,76 **** --- 74,85 ---- protected HashMap adjList; /*this is adjaceny list representation of the graph with nodeIDs */ + //BE: (begin) + // BRITE calculates the delay by using x, y- coordinates. By turning this value to false + // you will use the existing delays in the file. + private boolean isCreatedGraph; + //BE: (end) + protected Node[] nodesArray; protected Edge[] edgesArray; *************** *** 792,798 **** } } ! } --- 801,815 ---- } } ! //BE: (begin) ! public void setIsCreatedGraph(boolean b){ ! this.isCreatedGraph = b; ! } ! ! public boolean getIsCreatedGraph(){ ! return this.isCreatedGraph; ! } ! //BE: (end) } diff -r -c -N BRITE/Java/Graph/Node.java BRITE.new/Java/Graph/Node.java *** BRITE/Java/Graph/Node.java Tue Apr 23 04:23:20 2002 --- BRITE.new/Java/Graph/Node.java Wed Nov 14 18:13:45 2007 *************** *** 19,26 **** --- 19,29 ---- /* */ /* Author: Alberto Medina */ /* Anukool Lakhina */ + /* Waldemar Spaet */ /* Title: BRITE: Boston university Representative Topology gEnerator */ /* Revision: 2.0 4/02/2001 */ + /* 2.1 8/16/2007 (-new functions to support */ + /* MapSamplingFilter) */ /****************************************************************************/ package Graph; *************** *** 49,60 **** int id; int addr; ! String addrS; int indegree; int outdegree; int color; NodeConf n; public String toString() { return (new Integer(id)).toString(); } --- 52,70 ---- int id; int addr; ! String addrS; int indegree; int outdegree; int color; NodeConf n; + //BE: (begin) + // map sampling + boolean candidate; + boolean selected; + Edge connecting_edge; + //BE: (end) + public String toString() { return (new Integer(id)).toString(); } *************** *** 74,79 **** --- 84,95 ---- this.color = GraphConstants.COLOR_WHITE; indegree=0; outdegree=0 ; + //BE: (begin) + // map sampling + this.candidate = false; + this.selected = false; + this.connecting_edge = null; + //BE: (end) } *************** *** 120,125 **** --- 136,151 ---- public void incrementInDegree() { ++this.indegree; } public void incrementOutDegree() { ++this.outdegree; } + + //BE: (begin) + // used for map sampling + public boolean getSelected(){ return this.selected; } + public boolean getCandidate(){ return this.candidate; } + public Edge getConnecting_edge(){ return this.connecting_edge; } + public void setSelected(boolean b){ this.selected = b; } + public void setCandidate(boolean b){ this.candidate = b; } + public void setConnecting_edge(Edge e){ this.connecting_edge = e; } + //BE: (end) } diff -r -c -N BRITE/Java/Graph/RouterNodeConf.java BRITE.new/Java/Graph/RouterNodeConf.java *** BRITE/Java/Graph/RouterNodeConf.java Mon Apr 22 00:06:49 2002 --- BRITE.new/Java/Graph/RouterNodeConf.java Wed Nov 14 18:13:45 2007 *************** *** 56,62 **** } ! //used by GTITM-Transit Stub import public RouterNodeConf(int x, int y, int z, int asID) { super(); this.x = x;this.y=y; this.z=z;this.asID = asID; --- 56,62 ---- } ! //used by GTITM-Transit Stub import; also used by Dimes-Import public RouterNodeConf(int x, int y, int z, int asID) { super(); this.x = x;this.y=y; this.z=z;this.asID = asID; diff -r -c -N BRITE/Java/Import/BriteImport.java BRITE.new/Java/Import/BriteImport.java *** BRITE/Java/Import/BriteImport.java Wed Apr 24 12:10:27 2002 --- BRITE.new/Java/Import/BriteImport.java Wed Nov 14 18:13:45 2007 *************** *** 19,26 **** --- 19,29 ---- /* */ /* Author: Alberto Medina */ /* Anukool Lakhina */ + /* Waldemar Spaet */ /* Title: BRITE: Boston university Representative Topology gEnerator */ /* Revision: 2.0 4/02/2001 */ + /* 2.1 8/16/2007 (-added boolean to distinguish between*/ + /* generated and imported topologies) */ /****************************************************************************/ package Import; *************** *** 60,65 **** --- 63,71 ---- Graph g; String formatParams=""; private HashMap id2id; + //BE: (begin) + private boolean isCreatedTopolgy; + //BE: (end) /** Class Constructor: Creates a constructor to import either a *************** *** 80,85 **** --- 86,94 ---- else isAS=false; g = new Graph(); id2id = new HashMap(); + //BE: (begin) + this.isCreatedTopolgy = g.getIsCreatedGraph(); + //BE: (end) } /** *************** *** 207,212 **** --- 216,226 ---- Edge e = new Edge(g.getNodeFromID(src), g.getNodeFromID(dst)); e.setBW(bw); e.setEuclideanDist(eucDist); + //BE: (begin) + if(!isCreatedTopolgy){ + e.setDelay(delay); + } + //BE: (end) int type =-1; if (isAS) { if (typeS.equals("E_AS_BORDER")) type = ModelConstants.E_AS_BORDER; diff -r -c -N BRITE/Java/Import/DimesImport.java BRITE.new/Java/Import/DimesImport.java *** BRITE/Java/Import/DimesImport.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Import/DimesImport.java Wed Nov 14 18:13:45 2007 *************** *** 0 **** --- 1,553 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package Import; + + import java.io.*; + import java.lang.*; + import java.util.*; + + import Topology.*; + import Model.*; + import Graph.*; + import Export.*; + import Util.*; + + public class DimesImport { + private BufferedReader br, br2; + + Graph g; + boolean isAS; + Set nodePositions = new HashSet(); + + int x; + int y; + + private static int AVG_DELAY = 10; + + List srcFileList; + Map ip2node; + Map srcDst; + + public DimesImport(File inFile, File inFile2, int type) { + try { + br = new BufferedReader(new FileReader(inFile)); + br2 = new BufferedReader(new FileReader(inFile2)); + } catch (IOException e) { + Util.ERR("Error reading from file " + e); + } + if (type == ModelConstants.AS_FILE) { + isAS = true; + } else { + isAS = false; + } + g = new Graph(); + ip2node = new HashMap(); + srcDst = new HashMap(); + } + + /** new constructor in order to import more than one file + */ + public DimesImport(List inFileList, int type) { + + srcFileList = inFileList; + if (type == ModelConstants.AS_FILE) { + isAS = true; + } else { + isAS = false; + } + g = new Graph(); + ip2node = new HashMap(); + srcDst = new HashMap(); + } + + /** create random x-, y- coordinates for a node + */ + private void getXYforNode() { + RandomGenManager rm = new RandomGenManager(); + Random PlaceRandom = rm.PLACE_NODES(); + int HS = 1000; + + x = (int) (Distribution.getUniformRandom(PlaceRandom) * HS); + y = (int) (Distribution.getUniformRandom(PlaceRandom) * HS); + + /* check for collisions */ + while (true) { + Integer id = new Integer(Util.Encode(x, y)); + if (nodePositions.contains(id)) { + x = (int) (Distribution.getUniformRandom(PlaceRandom) * HS); + y = (int) (Distribution.getUniformRandom(PlaceRandom) * HS); + } else { + nodePositions.add(id); + break; + } + } + + } + + + + /** + Method to calculate the delay between two nodes in one edge. + It is necessary to use this method, because there are more than one delay in an edge and to get the + average delay you need to iterate through every edge and set each one the average time. + */ + private void calculateDelay(){ + double sum; + int delaySize; + + Edge e; + + Edge[] edges = g.getEdgesArray(); + + for(int i = 0; i < edges.length; i++){ + sum = 0; + e = edges[i]; + + delaySize = e.getDelayList().size(); + + Iterator it = e.getDelayList().iterator(); + while(it.hasNext()){ + double next = (Double) it.next(); + if(next > 0){ + sum += next; + } + else if(next <= 0){ + delaySize--; + } + } + if (delaySize > 0){ + e.setDelay(sum / delaySize); + } + else{ + //TODO: Fuer den Fall, dass es keine richtige zeit gibt, einen Wert setzen + e.setDelay(AVG_DELAY); + } + } + + + } + + /** returns a AS-Node to a given id, if node does not exists, then a new Node is createt + with key: id, value: node + @param id node AS-Number + */ + private Node getASNode(int id) { + + if (ip2node.containsKey(id)) { + return (Node) ip2node.get(id); + } + + else { + getXYforNode(); + Node n = new Node(); + + n.setNodeConf(new ASNodeConf(x, y, 0)); + + n.setAddr(id); + ip2node.put(id,n); + g.addNode(n); + return n; + } + + } + /** returns a RT-Node to a given ip, if node does not exists, then a new Node is createt + with key: ip, value: node + @param ip node ip + @param ASNumber AS-Number of the node + */ + private Node getRTNode(String ip, int ASNumber) { + if (ip2node.containsKey(ip)) { + return (Node) ip2node.get(ip); + } + else { + getXYforNode(); + Node n = new Node(); + + n.setNodeConf(new RouterNodeConf(x, y, 0, ASNumber)); + + n.setAddr(ip); + ip2node.put(ip, n); + g.addNode(n); + return n; + } + } + + /** returns a RT-Node to a given ip, if node does not exists, then a new Node is createt + with key: ip, value: node + @param ip node ip + */ + private Node getRTNode(String ip) { + if (ip2node.containsKey(ip)) { + return (Node) ip2node.get(ip); + } + else { + getXYforNode(); + Node n = new Node(); + + n.setNodeConf(new RouterNodeConf(x, y, 0)); + + n.setAddr(ip); + ip2node.put(ip, n); + g.addNode(n); + return n; + } + } + /** create a new AS-Edge between frmAS and toAS, if this edge exists, only the delay + will be added to the edge DelayList + @param frmAS the source AS-Number of an edge + @param toAS the destination AS-Number of an edge + @param delay the delay betwen frmAS and toAS + */ + private void makeASEdge(int frmAS, int toAS, double delay) { + Node frmNode = getASNode(frmAS); + Node toNode = getASNode(toAS); + if (!g.hasEdge(frmNode, toNode)) { + Edge e = new Edge(frmNode, toNode); + + e.setEdgeConf(new ASEdgeConf()); + e.setDirection(GraphConstants.DIRECTED); + e.setDelay(delay); + e.setBW(1); + g.addEdge(e); + } + + } + + /** create a new RT-Edge between frmIP and toIP, if this edge exists, only the delay + will be added to the edge DelayList + @param frmIP the source IP of an edge + @param toIP the destination IP of an edge + @param delay the delay betwen frmIP and toIP + */ + private void makeRTEdge(String frmIP, String toIP, double delay) { + Node frmNode = getRTNode(frmIP); + Node toNode = getRTNode(toIP); + + Edge e; + String compare = ""; + if((compare = (String)srcDst.get(frmIP)) == null){ + compare = ""; + } + + if (compare.indexOf(";"+toIP+";") == -1) { + e = new Edge(frmNode, toNode); + e.addDelay(delay); + e.setEdgeConf(new RouterEdgeConf()); + e.setDirection(GraphConstants.DIRECTED); + e.setDelay(delay); + e.setBW(1); + g.addEdge(e); + + srcDst.put(frmIP, (compare + ";" + toIP + ";")); + } + else { + + if( (e = g.getEdge(frmNode, toNode) ) != null){ + e.addDelay(delay); + } + } + } + + /** convert the importet Graph into BRITE-format + @param briteFile the export filename + */ + public void convert(String briteFile) { + Graph g = parse(); + Topology t = new Topology(g); + BriteExport be = new BriteExport(t, new File(briteFile)); + be.export(); + } + + + /** convert the importet Graph into OMNeT-format + @param omnetppFile the export filename + */ + public void convertToOmnetpp(String omnetppFile) { + Graph g = parse(); + Topology t = new Topology(g); + OmnetppExport oe = new OmnetppExport(t, new File(omnetppFile)); + try { + oe.export(); + } catch (Exception e) { + Util.ERR("Error while exporting to omnetpp: " + e); + } + } + + /** returns the created Graph + */ + public Graph parse() { + + Iterator it = srcFileList.iterator(); + if(it.hasNext()){ + try { + br = new BufferedReader(new FileReader( new File((String) it.next()))); + } catch (FileNotFoundException e) { + Util.ERR("Error reading from file " + e); + } + + } + if(it.hasNext()){ + try { + br2 = new BufferedReader(new FileReader( new File((String) it.next()))); + } catch (FileNotFoundException e) { + Util.ERR("Error reading from file " + e); + } + + } + + if(isAS){ + parseASFile(); + } + else{ + parseRTFile(); + calculateDelay(); + } + + return g; + } + + /** the main parse-method for an AS-File + */ + private void parseASFile() { + String line = ""; + int paths = 0; + try { + // Node File + while ((line = br.readLine()) != null) { + if ((line.trim().startsWith("#")) || line.trim().equals("")) + continue; + StringTokenizer st = new StringTokenizer(line,","); + + String ASNumber = st.nextToken(); + String ASName = st.nextToken(); + String DateDis = st.nextToken(); + //String DateDisTime = st.nextToken(); + String DateVal = st.nextToken(); + //String DateValTime = st.nextToken(); + String IN = st.nextToken(); + String OUT = st.nextToken(); + String maxRadius = st.nextToken(); + + getASNode(Integer.parseInt(ASNumber)); + + ++paths; + if (paths % 2000 == 0) + System.out.print("."); + } + Util.MSG("Node-File done"); + // Edge File + while ((line = br2.readLine()) != null) { + if ((line.trim().startsWith("#")) || line.trim().equals("")) + continue; + StringTokenizer st = new StringTokenizer(line,","); + + String SourceAS = st.nextToken(); + String DestAS = st.nextToken(); + String DateDis2 = st.nextToken(); + //String DateDisTime2 = st.nextToken(); + String minDelay = st.nextToken(); + String maxDelay = st.nextToken(); + String DateVal2 = st.nextToken(); + //String DateValTime2 = st.nextToken(); + + double delay = ((Double.parseDouble(minDelay) + Double + .parseDouble(maxDelay) / 2)); + + makeASEdge(Integer.parseInt(SourceAS), + Integer.parseInt(DestAS), delay); + + ++paths; + if (paths % 2000 == 0) + System.out.print("."); + } + Util.MSG("created graph from DIMES file, |V| = " + g.getNumNodes() + + " and |E| = " + g.getNumEdges()); + } catch (IOException e) { + Util.ERR("Error building graph from Skitter file.", e); + } + + } + + /** the main parse-method for a RT-File + */ + private void parseRTFile() { + String line = ""; + int paths = 0; + try { + // Node File + + String IP; + String HostName; + String DateDisNode; + //String DateDisTimeNode; + String DateValNode; + //String DateValTimeNode; + String ASNumber; + String ASPrefix; + String IsUnknown; + String IN; + String OUT; + + while ((line = br.readLine()) != null) { + if ((line.trim().startsWith("#")) || line.trim().equals("")) + continue; + StringTokenizer st = new StringTokenizer(line,","); + + IP = st.nextToken(); + HostName = st.nextToken(); + DateDisNode = st.nextToken(); + //DateDisTimeNode = st.nextToken(); + DateValNode = st.nextToken(); + //DateValTimeNode = st.nextToken(); + ASNumber = st.nextToken(); + ASPrefix = st.nextToken(); + IsUnknown = st.nextToken(); + IN = st.nextToken(); + OUT = st.nextToken(); + + // String IP = st.nextToken(); + // String HostName = st.nextToken(); + // String DateDisNode = st.nextToken(); + // String DateDisTimeNode = st.nextToken(); + // String DateValNode = st.nextToken(); + // String DateValTimeNode = st.nextToken(); + // String ASNumber = st.nextToken(); + // String ASPrefix = st.nextToken(); + // String IsUnknown = st.nextToken(); + // String IN = st.nextToken(); + // String OUT = st.nextToken(); + + if(Integer.parseInt(IN) > 0 && Integer.parseInt(OUT) > 0){ + getRTNode(IP, Integer.parseInt(ASNumber)); + } + ++paths; + if (paths % 2000 == 0) + System.out.print("."); + } + + Util.MSG("Node-File done"); + + // Edge File + + String SourceIP; + String DestIP; + String DateDisEdge; + //String DateDisTimeEdge; + String DateValEdge; + //String DateValTimeEdge; + String InterAS; + String IsUnknownEdge; + String minDelay; + String avgDelay; + String delayVariance; + + while ((line = br2.readLine()) != null) { + if ((line.trim().startsWith("#")) || line.trim().equals("")) + continue; + StringTokenizer st = new StringTokenizer(line,","); + + SourceIP = st.nextToken(); + DestIP = st.nextToken(); + DateDisEdge = st.nextToken(); + //DateDisTimeEdge = st.nextToken(); + DateValEdge = st.nextToken(); + //DateValTimeEdge = st.nextToken(); + InterAS = st.nextToken(); + IsUnknownEdge = st.nextToken(); + minDelay = st.nextToken(); + avgDelay = st.nextToken(); + delayVariance = st.nextToken(); + + // String SourceIP = st.nextToken(); + // String DestIP = st.nextToken(); + // String DateDisEdge = st.nextToken(); + // String DateDisTimeEdge = st.nextToken(); + // String DateValEdge = st.nextToken(); + // String DateValTimeEdge = st.nextToken(); + // String InterAS = st.nextToken(); + // String IsUnknownEdge = st.nextToken(); + // String minDelay = st.nextToken(); + // String avgDelay = st.nextToken(); + // String delayVariance = st.nextToken(); + + + double delay = Double.parseDouble(avgDelay); + + makeRTEdge(SourceIP, DestIP, delay); + makeRTEdge(DestIP, SourceIP, delay); + + ++paths; + if (paths % 2000 == 0) + System.out.print("."); + } + Util.MSG("created graph from DIMES file, |V| = " + g.getNumNodes() + + " and |E| = " + g.getNumEdges()); + } catch (IOException e) { + Util.ERR("Error building graph from Skitter file.", e); + } + + } + + public static void main(String args[]) throws Exception { + List srcFileList = new ArrayList(); + boolean isCreatedGraph = false; + String fileToRead = ""; + String fileToRead2 = ""; + String fileToWrite = ""; + String asOrRouter = ""; + String briteOrOmnet = ""; + try { + fileToRead = args[0]; + fileToRead2 = args[1]; + fileToWrite = args[2]; + asOrRouter = args[3]; + briteOrOmnet = args[4]; + } catch (Exception e) { + Util.ERR("usage: java Import.DimesImport RT {|AS} BRITE {|OMNET}"); + } + srcFileList.add(fileToRead); + srcFileList.add(fileToRead2); + Util.MSG("Importing DIMES .."); + FileModel f; + if (asOrRouter.equals("AS")) + f = new FileModel(ImportConstants.DIMES_FORMAT, srcFileList, ModelConstants.AS_FILE, isCreatedGraph); + else + f = new FileModel(ImportConstants.DIMES_FORMAT, srcFileList, ModelConstants.RT_FILE, isCreatedGraph); + + Topology t = new Topology(f); + if (briteOrOmnet.equalsIgnoreCase("OMNET")) { + Util.MSG("Writing to OMNETPP format .."); + OmnetppExport oe = new OmnetppExport(t, new File(fileToWrite)); + oe.export(); + } else if (briteOrOmnet.equalsIgnoreCase("BRITE")) { + Util.MSG("Writing to BRITE format .."); + BriteExport be = new BriteExport(t, new File(fileToWrite)); + be.export(); + } + + } + + } diff -r -c -N BRITE/Java/Import/ImportConstants.java BRITE.new/Java/Import/ImportConstants.java *** BRITE/Java/Import/ImportConstants.java Mon Apr 22 14:12:25 2002 --- BRITE.new/Java/Import/ImportConstants.java Wed Nov 14 18:13:45 2007 *************** *** 38,43 **** --- 38,46 ---- public static int GTITMts_FORMAT = 5; public static int INET_FORMAT = 6; public static int SKITTER_FORMAT = 7; + //BE: (begin) + public static int DIMES_FORMAT = 8; + //BE: (end) } diff -r -c -N BRITE/Java/Import/SkitterImport.java BRITE.new/Java/Import/SkitterImport.java *** BRITE/Java/Import/SkitterImport.java Tue Apr 23 02:26:21 2002 --- BRITE.new/Java/Import/SkitterImport.java Wed Nov 14 18:13:45 2007 *************** *** 1,3 **** --- 1,28 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + package Import; import java.io.*; *************** *** 18,23 **** --- 43,61 ---- HashMap ip2node; boolean isAS; + //BE: (begin) + Map srcDst; + Map edgeMap; + boolean connectReceiver = false; // Turn this option to true in order to connect the last Hop with destination + private static int AVG_DELAY = 10; + List srcFileList; + private boolean isOneFile; + + Set nodePositions = new HashSet(); + int x; + int y; + //BE: (end) + public SkitterImport(File inFile, int type) { try { br = new BufferedReader(new FileReader(inFile)); *************** *** 25,44 **** catch (IOException e) { Util.ERR("Error reading from file " + e); } ! if (type == ModelConstants.AS_FILE) isAS=true; ! else isAS=false; g = new Graph(); ip2node = new HashMap(); } private Node getNodeFromMap(String ip) { if (ip2node.containsKey(ip)) return (Node) ip2node.get(ip); else { Node n = new Node(); ! if (isAS) n.setNodeConf(new ASNodeConf()); ! else n.setNodeConf(new RouterNodeConf()); n.setAddr(ip); ip2node.put(ip,n); g.addNode(n); --- 63,214 ---- catch (IOException e) { Util.ERR("Error reading from file " + e); } ! if (type == ModelConstants.AS_FILE){ isAS=true; ! } ! else{ ! isAS=false; ! } g = new Graph(); ip2node = new HashMap(); + //BE: (begin) + srcDst = new HashMap(); + edgeMap = new HashMap(); + isOneFile = true; + //BE: (end) + } + + //BE: (begin) + /** new constructor in order to import more than one file + */ + public SkitterImport(List inFileList, int type) { + + srcFileList = inFileList; + if (type == ModelConstants.AS_FILE){ + isAS=true; + } + else{ + isAS=false; + } + g = new Graph(); + ip2node = new HashMap(); + srcDst = new HashMap(); + edgeMap = new HashMap(); + isOneFile = false; + } + + + /** create random x-, y- coordinates for a node + */ + private void getXYforNode(){ + RandomGenManager rm = new RandomGenManager(); + Random PlaceRandom = rm.PLACE_NODES(); + int HS = 1000; + + x = (int) ( Distribution.getUniformRandom(PlaceRandom)*HS); + y = (int) ( Distribution.getUniformRandom(PlaceRandom)*HS); + + + /*check for collisions*/ + while (true) { + Integer id = new Integer(Util.Encode(x,y)); + if (nodePositions.contains(id)) { + x = (int) ( Distribution.getUniformRandom(PlaceRandom)*HS); + y = (int) ( Distribution.getUniformRandom(PlaceRandom)*HS); + } + else { + nodePositions.add(id); + break; + } + } + + } + /** + Method to calculate the delay between two nodes in one edge. + It is necessary to use this method, because there are more than one delay in an edge and to get the + average delay you need to iterate through every edge and set each one the average time. + */ + private void calculateDelay(){ + double sum; + int delaySize; + + Edge e; + + Edge[] edges = g.getEdgesArray(); + + for(int i = 0; i < edges.length; i++){ + sum = 0; + e = edges[i]; + + delaySize = e.getDelayList().size(); + + Iterator it = e.getDelayList().iterator(); + while(it.hasNext()){ + double next = (Double) it.next(); + if(next > 0){ + sum += next; + } + else if(next <= 0){ + delaySize--; + } + } + if (delaySize > 0){ + e.setDelay(sum / delaySize); + } + else{ + //TODO: Fuer den Fall, dass es keine richtige zeit gibt, einen Wert setzen + e.setDelay(AVG_DELAY); + } + } + + } + + private void fixDelay(){ + + Double delay; + + Edge e; + + Edge[] edges = g.getEdgesArray(); + + for(int i = 0; i < edges.length; i++){ + + e = edges[i]; + + delay = e.getMeasuredDelay(); + + if (delay <= 0){ + e.setDelay(AVG_DELAY); + } + } + + + } + + //BE: (end) + + /** returns a node to a given ip, if node does not exists, then a new Node is createt + with key: ip, value: node + @param ip node ip + */ private Node getNodeFromMap(String ip) { if (ip2node.containsKey(ip)) return (Node) ip2node.get(ip); else { + //BE: (begin) + getXYforNode(); Node n = new Node(); ! if (isAS) { ! // n.setNodeConf(new ASNodeConf()); ! n.setNodeConf(new ASNodeConf(x, y, 0)); ! } ! else { ! // n.setNodeConf(new RouterNodeConf()); ! n.setNodeConf(new RouterNodeConf(x, y, 0)); ! } ! //BE: (end) n.setAddr(ip); ip2node.put(ip,n); g.addNode(n); *************** *** 46,62 **** } } ! private void makeEdge(String frmIP, String toIP) { ! Node frmNode = getNodeFromMap(frmIP); ! Node toNode = getNodeFromMap(toIP); ! if (!g.hasEdge(frmNode, toNode)) { ! Edge e = new Edge(frmNode, toNode); ! e.setDirection(GraphConstants.DIRECTED); ! g.addEdge(e); ! } ! } public void convert(String briteFile) { Graph g = parse(); Topology t = new Topology(g); --- 216,349 ---- } } ! //BE: (begin) ! /** create a new Edge between frmIP and toIP, if this edge exists, only the delay ! will be added to the edge DelayList ! @param frmIP the source IP of an edge ! @param toIP the destination IP of an edge ! @param delay the delay betwen frmIP and toIP ! */ ! private void makeEdge(String frmIP, String toIP, double delay) { ! Node frmNode = getNodeFromMap(frmIP); ! Node toNode = getNodeFromMap(toIP); ! Edge e; ! String compare = ""; ! if((compare = (String)srcDst.get(frmIP)) == null){ ! compare = ""; ! } ! ! if (compare.indexOf(";"+toIP+";") == -1) { ! ! if(!frmIP.equals(toIP)){ ! e = new Edge(frmNode, toNode); ! ! e.addDelay(delay); ! if (isAS) { ! e.setEdgeConf(new ASEdgeConf()); ! } ! else { ! e.setEdgeConf(new RouterEdgeConf()); ! } ! ! e.setDirection(GraphConstants.DIRECTED); ! e.setDelay(delay); ! e.setBW(1); ! g.addEdge(e); ! srcDst.put(frmIP, (compare + ";" + toIP + ";")); ! ! // wird benutzt um nicht jedesmal bei dem Graphen abzupruefen ob die Kante existiert ! edgeMap.put((frmIP + ";" + toIP), new ArrayList()); ! List l = (ArrayList) edgeMap.get((frmIP + ";" + toIP)); ! l.add(delay); ! } ! ! } ! else { ! ! List l = (ArrayList) edgeMap.get((frmIP + ";" + toIP)); ! l.add(delay); ! ! } ! ! } ! //BE: (end) ! ! ! ! //BE: (begin) ! private void addDelay2Edges(){ ! Iterator edgeIterator = edgeMap.keySet().iterator(); ! int delaySize; ! Double sum; ! double finalDelay = 0.0; ! ! while(edgeIterator.hasNext()){ ! sum = 0.0; ! String nodes = (String) edgeIterator.next(); ! ! Node frmNode = getNodeFromMap(nodes.substring(0, nodes.indexOf(";"))); ! Node toNode = getNodeFromMap(nodes.substring(nodes.indexOf(";") + 1 , nodes.length())); ! Edge e = g.getEdge(frmNode, toNode); ! ! if (e != null){ ! ! List l = (ArrayList) edgeMap.get(nodes); ! ! ! delaySize = l.size(); ! ! Iterator it = l.iterator(); ! while(it.hasNext()){ ! double next = (Double) it.next(); ! if(next > 0){ ! sum += next; ! } ! else if(next <= 0){ ! delaySize--; ! } ! } ! if (delaySize > 0){ ! finalDelay = sum / delaySize; ! e.setDelay(finalDelay); ! } ! else{ ! //TODO: Fuer den Fall, dass es keine richtige zeit gibt, einen Wert setzen ! e.setDelay(AVG_DELAY); ! } ! } ! ! String compare = ""; ! if((compare = (String) srcDst.get(toNode.getAddrS())) == null){ ! compare = ""; ! } ! ! if (compare.indexOf(";"+frmNode.getAddrS()+";") == -1) { ! Edge e2 = new Edge(toNode, frmNode); ! ! e2.addDelay(finalDelay); ! if (isAS) { ! e2.setEdgeConf(new ASEdgeConf()); ! } ! else { ! e2.setEdgeConf(new RouterEdgeConf()); ! } ! ! e2.setDirection(GraphConstants.DIRECTED); ! e2.setDelay(finalDelay); ! e2.setBW(1); ! g.addEdge(e2); ! } ! ! } ! } + //BE: (end) + + + /** convert the imported Graph into BRITE-format + @param briteFile the export filename + */ public void convert(String briteFile) { Graph g = parse(); Topology t = new Topology(g); *************** *** 64,112 **** be.export(); } public Graph parse() { ! String line=""; ! int paths=0; ! try { ! while ( (line=br.readLine())!=null) { ! if ( (line.trim().startsWith("#")) || line.trim().equals("")) continue; ! StringTokenizer st = new StringTokenizer(line); ! String stat = st.nextToken(); ! String src = st.nextToken(); ! String dst = st.nextToken(); ! st.nextToken(); st.nextToken(); ! if (!st.hasMoreTokens()) continue; ! String frmIP = st.nextToken(); ! makeEdge(src, frmIP); //connect src to first hop ! while (st.hasMoreTokens()) { ! String toIP = st.nextToken(); ! makeEdge(frmIP, toIP); ! frmIP = toIP; ! } ! if (stat.equals("C")) makeEdge(frmIP, dst); ! ++paths; ! if (paths%1000==0) System.out.print("."); ! } ! Util.MSG("created graph from skitter file, |V| = " + g.getNumNodes()+ " and |E| = " + g.getNumEdges()); ! } ! catch (IOException e) { ! Util.ERR("Error building graph from Skitter file.", e); ! } ! return g; } //todebug: public static void main(String args[]) throws Exception { String fileToRead=""; String fileToWrite=""; String asOrRouter=""; try { fileToRead= args[0]; fileToWrite=args[1]; asOrRouter=args[2]; } catch (Exception e) { ! Util.ERR("usage: java Import.SkitterImport RT {|AS}"); } Util.MSG("Importing Skitter .."); --- 351,731 ---- be.export(); } + /** convert the imported Graph into OMNeT-format + @param omnetppFile the export filename + */ + public void convertToOmnetpp(String omnetppFile) { + Graph g = parse(); + Topology t = new Topology(g); + OmnetppExport oe = new OmnetppExport(t, new File(omnetppFile)); + try { + oe.export(); + } catch (Exception e) { + Util.ERR("Error while exporting to omnetpp: " +e); + } + } + + + //BE: (begin) + /** returns the created Graph + */ public Graph parse() { ! String line=""; ! int paths=0; ! if(!isOneFile){ ! Iterator it = srcFileList.iterator(); ! while(it.hasNext()){ ! try { ! br = new BufferedReader(new FileReader( new File((String) it.next()))); ! } catch (FileNotFoundException e) { ! Util.ERR("Error reading from file " + e); ! } ! if(isAS){ ! parseASFile(); ! } ! else{ ! parseRTFile(); ! } ! } ! // calculateDelay(); ! ! addDelay2Edges(); ! fixDelay(); ! // addEdges(); ! Util.MSG("created graph from skitter file, |V| = " + g.getNumNodes()+ " and |E| = " + g.getNumEdges()); ! } ! else{ ! if(isAS){ ! parseASFile(); ! } ! else{ ! parseRTFile(); ! } ! // calculateDelay(); ! ! addDelay2Edges(); ! fixDelay(); ! // addEdges(); ! Util.MSG("created graph from skitter file, |V| = " + g.getNumNodes()+ " and |E| = " + g.getNumEdges()); ! } ! ! return g; ! } ! /** methode to parse an AS-File ! */ ! public void parseASFile(){ ! String line=""; ! int paths=0; ! ! try { ! ! while ( (line=br.readLine())!=null) { ! if ( (line.trim().startsWith("#")) || line.trim().equals("")){ ! continue; ! } ! double delay = AVG_DELAY; ! String line_status = ""; ! String time_stamp_earliest = ""; ! String time_stamp_latest = ""; ! String monitor_ip = ""; ! String mointor_as; ! int monitor_key; ! String as_from; ! String as_to; ! int gap_length; ! List mointor_keys = new ArrayList(); ! ! StringTokenizer st = new StringTokenizer(line); ! ! line_status = st.nextToken(); ! ! if(line_status.equalsIgnoreCase("T")){ ! time_stamp_earliest = st.nextToken(); ! time_stamp_latest = st.nextToken(); ! } ! else if(line_status.equalsIgnoreCase("M")){ ! monitor_ip = st.nextToken(); ! mointor_as = st.nextToken(); ! monitor_key = Integer.parseInt(st.nextToken()); ! } ! else if(line_status.equalsIgnoreCase("D")){ ! as_from = st.nextToken(); ! as_to = st.nextToken(); ! while(st.hasMoreTokens()){ ! mointor_keys.add(Integer.parseInt(st.nextToken())); ! } ! if(!as_from.contains("_") || !as_from.contains(",") || !as_to.contains("_") || !as_to.contains(",") || !as_from.contains("null") || !as_to.contains("null") || !as_from.contains("MCAST") || !as_to.contains("MCAST")){ ! makeEdge(as_from, as_to, delay); ! } ! } ! else if(line_status.equalsIgnoreCase("I")){ ! as_from = st.nextToken(); ! as_to = st.nextToken(); ! gap_length = Integer.parseInt(st.nextToken()); ! while(st.hasMoreTokens()){ ! mointor_keys.add(Integer.parseInt(st.nextToken())); ! } ! } ! ! ++paths; ! if (paths%1000==0) { ! System.out.print("."); ! } ! } ! } ! catch (IOException e) { ! Util.ERR("Error building graph from Skitter file.", e); ! } ! } ! ! /* ! public void parseASFile(){ ! String line=""; ! int paths=0; ! ! try { ! while ( (line=br.readLine())!=null) { ! if ( (line.trim().startsWith("#")) || line.trim().equals("")){ ! continue; ! } ! String first = ""; ! String second = ""; ! String temp = ""; ! StringTokenizer st = new StringTokenizer(line); ! String key = st.nextToken(); ! ! String src = st.nextToken(); ! first = src.substring(0, src.indexOf(".")); ! temp = src.substring(src.indexOf(".") + 1, src.length()); ! second = temp.substring(0, temp.indexOf(".")); ! src = first + "." + second; ! ! String dst = st.nextToken(); ! first = dst.substring(0, dst.indexOf(".")); ! temp = dst.substring(dst.indexOf(".") + 1, dst.length()); ! second = temp.substring(0, temp.indexOf(".")); ! dst = first + "." + second; ! ! String listID = st.nextToken(); ! String cycleID = st.nextToken(); ! String timestamp = st.nextToken(); ! String destReplied = st.nextToken(); ! String destRTT = st.nextToken(); ! String requestTTL = st.nextToken(); ! String replyTTL = st.nextToken(); ! String haltReason = st.nextToken(); ! String haltReasonData = st.nextToken(); ! String stat = st.nextToken(); ! ! if (!st.hasMoreTokens()) { ! continue; ! } ! String perHopData = st.nextToken(); ! String perHopData2 = perHopData; ! String frmIP = ""; ! String RTT = ""; ! Double delay = 0.0; ! String tries = ""; ! Double lastDelay = 0.0; ! ! if (!perHopData.equalsIgnoreCase("q")){ ! ! frmIP = perHopData.substring(0, perHopData.indexOf(",")); ! ! first = frmIP.substring(0, frmIP.indexOf(".")); ! temp = frmIP.substring(frmIP.indexOf(".") + 1, frmIP.length()); ! second = temp.substring(0, temp.indexOf(".")); ! frmIP = first + "." + second; ! ! RTT = perHopData.substring(perHopData.indexOf(",") + 1,perHopData.lastIndexOf(",")); ! delay = (Double.parseDouble(RTT) / 2) - lastDelay; ! // delay = Double.parseDouble(RTT) / 2; ! tries = perHopData.substring(perHopData.lastIndexOf(",") + 1, perHopData.length()); ! makeEdge(src, frmIP, delay); //connect src to first hop ! lastDelay = delay; ! ! } ! while (st.hasMoreTokens()) { ! perHopData = st.nextToken(); ! perHopData2 = perHopData; ! if (!perHopData.equalsIgnoreCase("q")){ ! ! if(perHopData2.contains(";")){ ! while(perHopData2.contains(";")){ ! int firstSemi = perHopData2.indexOf(";"); ! perHopData = perHopData.substring(0, firstSemi); ! perHopData2 = perHopData2.substring(firstSemi+1, perHopData2.length()); ! ! String toIP = perHopData.substring(0, perHopData.indexOf(",")); ! ! first = toIP.substring(0, toIP.indexOf(".")); ! temp = toIP.substring(toIP.indexOf(".") + 1, toIP.length()); ! second = temp.substring(0, temp.indexOf(".")); ! toIP = first + "." + second; ! ! RTT = perHopData.substring(perHopData.indexOf(",") + 1,perHopData.lastIndexOf(",")); ! delay = (Double.parseDouble(RTT) / 2) - lastDelay; ! tries = perHopData.substring(perHopData.lastIndexOf(",") + 1, perHopData.length()); ! makeEdge(frmIP, toIP, delay); ! frmIP = toIP; ! lastDelay = delay; ! } ! } ! else{ ! String toIP = perHopData.substring(0, perHopData.indexOf(",")); ! ! first = toIP.substring(0, toIP.indexOf(".")); ! temp = toIP.substring(toIP.indexOf(".") + 1, toIP.length()); ! second = temp.substring(0, temp.indexOf(".")); ! toIP = first + "." + second; ! ! RTT = perHopData.substring(perHopData.indexOf(",") + 1,perHopData.lastIndexOf(",")); ! delay = (Double.parseDouble(RTT) / 2) - lastDelay; ! // delay = Double.parseDouble(RTT) / 2; ! tries = perHopData.substring(perHopData.lastIndexOf(",") + 1, perHopData.length()); ! makeEdge(frmIP, toIP, delay); ! frmIP = toIP; ! lastDelay = delay; ! } ! } ! } ! if (stat.equals("C")) { ! delay = (Double.parseDouble(destRTT) / 2) - lastDelay; ! // delay = Double.parseDouble(destRTT) / 2; ! makeEdge(frmIP, dst, delay); ! } ! ++paths; ! if (paths%1000==0) { ! System.out.print("."); ! } ! } ! } ! catch (IOException e) { ! Util.ERR("Error building graph from Skitter file.", e); ! } ! } ! */ ! ! /** methode to parse a RT-File ! */ ! public void parseRTFile(){ ! String line=""; ! int paths=0; ! ! try { ! while ( (line=br.readLine())!=null) { ! if ( (line.trim().startsWith("#")) || line.trim().equals("")){ ! continue; ! } ! StringTokenizer st = new StringTokenizer(line); ! String key = st.nextToken(); ! String src = st.nextToken(); ! String dst = st.nextToken(); ! String listID = st.nextToken(); ! String cycleID = st.nextToken(); ! String timestamp = st.nextToken(); ! String destReplied = st.nextToken(); ! String destRTT = st.nextToken(); ! String requestTTL = st.nextToken(); ! String replyTTL = st.nextToken(); ! String haltReason = st.nextToken(); ! String haltReasonData = st.nextToken(); ! String stat = st.nextToken(); ! ! if (!st.hasMoreTokens()) { ! continue; ! } ! String perHopData = st.nextToken(); ! String perHopData2 = perHopData; ! String frmIP = ""; ! String RTT = ""; ! Double delay = 0.0; ! String tries = ""; ! Double lastDelay = 0.0; ! ! if(!stat.equals("I") && !haltReasonData.equals("G")){ ! if (!perHopData.equalsIgnoreCase("q")){ ! ! frmIP = perHopData.substring(0, perHopData.indexOf(",")); ! RTT = perHopData.substring(perHopData.indexOf(",") + 1,perHopData.lastIndexOf(",")); ! delay = (Double.parseDouble(RTT) / 2) - lastDelay; ! // delay = Double.parseDouble(RTT) / 2; ! tries = perHopData.substring(perHopData.lastIndexOf(",") + 1, perHopData.length()); ! makeEdge(src, frmIP, delay); //connect src to first hop ! // makeEdge(frmIP, src, delay); ! lastDelay = delay; ! ! } ! while (st.hasMoreTokens()) { ! perHopData = st.nextToken(); ! perHopData2 = perHopData; ! if (!perHopData.equalsIgnoreCase("q")){ ! ! if(perHopData2.contains(";")){ ! while(perHopData2.contains(";")){ ! int firstSemi = perHopData2.indexOf(";"); ! perHopData = perHopData.substring(0, firstSemi); ! perHopData2 = perHopData2.substring(firstSemi+1, perHopData2.length()); ! ! String toIP = perHopData.substring(0, perHopData.indexOf(",")); ! RTT = perHopData.substring(perHopData.indexOf(",") + 1,perHopData.lastIndexOf(",")); ! delay = (Double.parseDouble(RTT) / 2) - lastDelay; ! tries = perHopData.substring(perHopData.lastIndexOf(",") + 1, perHopData.length()); ! makeEdge(frmIP, toIP, delay); ! // makeEdge(toIP, frmIP, delay); ! frmIP = toIP; ! lastDelay = delay; ! } ! } ! else{ ! String toIP = perHopData.substring(0, perHopData.indexOf(",")); ! RTT = perHopData.substring(perHopData.indexOf(",") + 1,perHopData.lastIndexOf(",")); ! delay = (Double.parseDouble(RTT) / 2) - lastDelay; ! // delay = Double.parseDouble(RTT) / 2; ! tries = perHopData.substring(perHopData.lastIndexOf(",") + 1, perHopData.length()); ! makeEdge(frmIP, toIP, delay); ! // makeEdge(toIP, frmIP, delay); ! frmIP = toIP; ! lastDelay = delay; ! } ! } ! } ! } ! if(connectReceiver){ ! if (stat.equals("C")) { ! delay = (Double.parseDouble(destRTT) / 2) - lastDelay; ! // delay = Double.parseDouble(destRTT) / 2; ! makeEdge(frmIP, dst, delay); ! // makeEdge(dst, frmIP, delay); ! } ! } ! ++paths; ! if (paths%1000==0) { ! System.out.print("."); ! } ! } ! ! } ! catch (IOException e) { ! Util.ERR("Error building graph from Skitter file.", e); ! } } + //BE: (end) //todebug: public static void main(String args[]) throws Exception { String fileToRead=""; String fileToWrite=""; String asOrRouter=""; + String briteOrOmnet =""; try { fileToRead= args[0]; fileToWrite=args[1]; asOrRouter=args[2]; + briteOrOmnet=args[3]; } catch (Exception e) { ! Util.ERR("usage: java Import.SkitterImport RT {|AS} BRITE {|OMNET}"); } Util.MSG("Importing Skitter .."); *************** *** 117,125 **** f = new FileModel(ImportConstants.SKITTER_FORMAT, fileToRead, ModelConstants.RT_FILE); Topology t = new Topology(f); ! Util.MSG("Writing to BRITE format .."); ! BriteExport be = new BriteExport(t, new File(fileToWrite)); ! be.export(); } --- 736,751 ---- f = new FileModel(ImportConstants.SKITTER_FORMAT, fileToRead, ModelConstants.RT_FILE); Topology t = new Topology(f); ! if (briteOrOmnet.equalsIgnoreCase("OMNET")){ ! Util.MSG("Writing to OMNETPP format .."); ! OmnetppExport oe = new OmnetppExport(t, new File(fileToWrite)); ! oe.export(); ! } ! else if (briteOrOmnet.equalsIgnoreCase("BRITE")){ ! Util.MSG("Writing to BRITE format .."); ! BriteExport be = new BriteExport(t, new File(fileToWrite)); ! be.export(); ! } } diff -r -c -N BRITE/Java/Main/Brite.java BRITE.new/Java/Main/Brite.java *** BRITE/Java/Main/Brite.java Mon Apr 22 19:35:40 2002 --- BRITE.new/Java/Main/Brite.java Wed Nov 14 18:13:45 2007 *************** *** 107,124 **** NSExport ne = new NSExport(t, new File(outFile+".tcl")); ne.export(); } - /*export to NS format outFile*/ - if (exportFormats.contains("NS")) { - Util.MSG("Exporting Topology in NS Format to: " + outFile+".dml"); - NSExport ne = new NSExport(t, new File(outFile+".tcl")); - ne.export(); - } if (exportFormats.contains("Javasim")) { Util.MSG("Exporting Topology in Javasim Format to: " + outFile+"_jsim.xml"); JSimExport ne = new JSimExport(t, new File(outFile+"_jsim.xml")); ne.export(); } /*outputting seed file*/ Util.MSG("Exporting random number seeds to seedfile"); rgm.export("last_seed_file", "seed_file"); --- 107,126 ---- NSExport ne = new NSExport(t, new File(outFile+".tcl")); ne.export(); } + /*export to Javasim format outFile*/ if (exportFormats.contains("Javasim")) { Util.MSG("Exporting Topology in Javasim Format to: " + outFile+"_jsim.xml"); JSimExport ne = new JSimExport(t, new File(outFile+"_jsim.xml")); ne.export(); } + /*export to OMNeT++ format outFile*/ + if (exportFormats.contains("Omnetpp")) { + Util.MSG("Exporting Topology in OMNeT++ Format to: " + outFile+".ned"); + OmnetppExport oe = new OmnetppExport(t, new File(outFile+".ned")); + oe.export(); + } + /*outputting seed file*/ Util.MSG("Exporting random number seeds to seedfile"); rgm.export("last_seed_file", "seed_file"); diff -r -c -N BRITE/Java/Main/FileConverter.java BRITE.new/Java/Main/FileConverter.java *** BRITE/Java/Main/FileConverter.java Thu Jan 1 01:00:00 1970 --- BRITE.new/Java/Main/FileConverter.java Wed Nov 14 18:13:45 2007 *************** *** 0 **** --- 1,313 ---- + /****************************************************************************/ + /* Copyright 2007, HAW Hamburg. */ + /* All Rights Reserved. */ + /* */ + /* Permission to use, copy, or modify this software and its documentation */ + /* for educational and research purposes only and without fee is hereby */ + /* granted, provided that this copyright notice appear on all copies and */ + /* supporting documentation. For any other uses of this software, in */ + /* original or modified form, including but not limited to distribution in */ + /* whole or in part, specific prior permission must be obtained from HAW */ + /* Hamburg. These programs shall not be used, rewritten, or adapted as */ + /* the basis of a commercial software or hardware product without first */ + /* obtaining appropriate licenses from HAW Hamburg. HAW Hamburg and the */ + /* author(s) make no representations about the suitability of this software */ + /* for any purpose. It is provided "as is" without express or implied */ + /* warranty. */ + /* */ + /* Please, refer to http://www.realmv6.org. */ + /* */ + /****************************************************************************/ + /* */ + /* Author: Waldemar Spaet */ + /* Revision: 1.0 8/16/2007 */ + /****************************************************************************/ + + package Main; + + import java.io.BufferedReader; + import java.io.File; + import java.io.FileNotFoundException; + import java.io.FileReader; + import java.io.FileWriter; + import java.io.IOException; + import java.util.ArrayList; + import java.util.List; + import java.util.StringTokenizer; + + import Export.BriteExport; + import Export.OmnetppExport; + import Filter.FilterConstants; + import Filter.FilterSettings; + import Model.FileModel; + import Model.ModelConstants; + import Topology.Topology; + import Util.Util; + + public class FileConverter { + + private boolean isCreatedTopology; + private FilterSettings filterSettings; + + public FileConverter(){ + this.isCreatedTopology = false; + this.filterSettings = new FilterSettings(); + } + + /** method to convert a skitter-file into a brite-file + @param srcFileList an arraylist, containing the skitter-source-filenames + @param dstFile the destination filename + @param asOrRT Integer for an autonome system type or router type; see ModelConstans + @param fs the used filtersettings + */ + public void convertSkitter2Brite(List srcFileList, String dstFile, int asOrRT, FilterSettings fs){ + FileModel f1 = new FileModel(Import.ImportConstants.SKITTER_FORMAT, srcFileList, asOrRT, isCreatedTopology); + Topology t1 = new Topology(f1); + + BriteExport be = new BriteExport(t1, new File(dstFile), fs); + be.export(); + + } + + /** method to convert a skitter-file into an OMNeT-file + @param srcFileList an arraylist, containing the skitter-source-filenames + @param dstFile the destination filename + @param asOrRT Integer for an autonome system type or router type; see ModelConstans + @param fs the used filtersettings + */ + public void convertSkitter2Omnet(List srcFileList, String dstFile, int asOrRT, FilterSettings fs){ + FileModel f2 = new FileModel(Import.ImportConstants.SKITTER_FORMAT, srcFileList, asOrRT, isCreatedTopology); + Topology t2 = new Topology(f2); + + OmnetppExport oe = new OmnetppExport(t2, new File(dstFile), fs); + try { + oe.export(); + } catch (Exception e) { + Util.ERR("Error while exporting from skitter to OMNet++"); + } + } + + /** method to convert a brite-file into an OMNeT-file + @param srcFile the source filename + @param dstFile the destination filename + @param asOrRT Integer for an autonome system type or router type; see ModelConstans + @param fs the used filtersettings + */ + public void convertBrite2Omnet(String srcFile, String dstFile, int asOrRT, FilterSettings fs){ + FileModel f3 = new FileModel(Import.ImportConstants.BRITE_FORMAT, srcFile, asOrRT, isCreatedTopology); + Topology t3 = new Topology(f3); + + OmnetppExport oe = new OmnetppExport(t3, new File(dstFile), fs); + try { + oe.export(); + } catch (Exception e) { + Util.ERR("Error while exporting from brite to OMNet++"); + } + } + + /** method to convert a dimes-file into a brite-file + @param srcFileList an arraylist, containing the dimes-source-filenames + @param dstFile the destination filename + @param asOrRT Integer for an autonome system type or router type; see ModelConstans + @param fs the used filtersettings + */ + public void convertDimes2Brite(List srcFileList, String dstFile, int asOrRT, FilterSettings fs){ + FileModel f4 = new FileModel(Import.ImportConstants.DIMES_FORMAT, srcFileList, asOrRT, isCreatedTopology); + Topology t4 = new Topology(f4); + + BriteExport be = new BriteExport(t4, new File(dstFile), fs); + be.export(); + + } + + /** method to convert a dimes-file into an OMNeT-file + @param srcFileList an arraylist, containing the dimes-source-filenames + @param dstFile the destination filename + @param asOrRT Integer for an autonome system type or router type; see ModelConstans + @param fs the used filtersettings + */ + public void convertDimes2Omnet(List srcFileList, String dstFile, int asOrRT, FilterSettings fs){ + FileModel f5 = new FileModel(Import.ImportConstants.DIMES_FORMAT, srcFileList, asOrRT, isCreatedTopology); + Topology t5 = new Topology(f5); + + OmnetppExport oe = new OmnetppExport(t5, new File(dstFile), fs); + try { + oe.export(); + } catch (Exception e) { + Util.ERR("Error while exporting from dimes to OMNet++"); + } + } + + // just for debugging + public void convertGTITM2Omnet(List srcFileList, String dstFile, int asOrRT, FilterSettings fs){ + FileModel f6 = new FileModel(Import.ImportConstants.GTITM_FORMAT, srcFileList, asOrRT, isCreatedTopology); + Topology t6 = new Topology(f6); + + OmnetppExport oe = new OmnetppExport(t6, new File(dstFile), fs); + try { + oe.export(); + } catch (Exception e) { + Util.ERR("Error while exporting from dimes to OMNet++"); + } + } + + // just for debugging + public void convertBrite2Brite(List srcFileList, String dstFile, int asOrRT, FilterSettings fs){ + FileModel f7 = new FileModel(Import.ImportConstants.BRITE_FORMAT, srcFileList, asOrRT, isCreatedTopology); + Topology t7 = new Topology(f7); + + BriteExport be = new BriteExport(t7, new File(dstFile), fs); + be.export(); + + } + + public void getFiltersettings(String fN){ + BufferedReader cfg = null; + String readLine = ""; + String parameter = ""; + StringTokenizer st; + String temp1; + String temp2; + String fileName = fN; + + String line1 = "// This file is only readed if you dont use the Gui\n"; + String line2 = "// If you choose for example map_sampling, there is no need to enter the parameter for max_hop_filter\n"; + String line3 = "filterType 0; // 0 = NONE, 1 = MAX_HOP_FILTER, 2 = MAP_SAMPLING\n"; + String line4 = "searchedNode -1; // searched node, enter the node ID or the node IP. used by max_hop_filter\n"; + String line5 = "maxHop 0; // max radius around searched node/ip. used by max_hop_filter\n"; + String line6 = "maxNodes 4000; // number of nodes in new graph. used by map_sampling\n"; + String line7 = "meanDegree 2.4; // mean Degree in new graph. used by map_sampling\n"; + + + try{ + //cfg = new BufferedReader(new FileReader("filterSettings.conf")); + cfg = new BufferedReader(new FileReader(fileName)); + } + catch(FileNotFoundException filenotfoundexception) { + FileWriter wStream = null; + try { + wStream = new FileWriter("filterSettings.conf"); + } catch (IOException e) { + e.printStackTrace(); + } + try { + wStream.write(line1 + line2 + line3 + line4 + line5 + line6 + line7); + } catch (IOException e) { + e.printStackTrace(); + } + try { + wStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + try{ + while ( (readLine = cfg.readLine()) != null) { + if(readLine.contains(";")){ + parameter = readLine.substring(0, readLine.indexOf(";")); + st = new StringTokenizer(parameter); + temp1 = st.nextToken(); + temp2 = st.nextToken(); + if(temp1.equals("filterType")){ + this.filterSettings.setFilterType(Integer.parseInt(temp2)); + } + else if(temp1.equals("searchedNode")){ + if(temp2.contains(".")){ + this.filterSettings.setIP(temp2); + }else{ + this.filterSettings.setNodeID(Integer.parseInt(temp2)); + } + } + else if(temp1.equals("maxHop")){ + this.filterSettings.setMaxHop(Integer.parseInt(temp2)); + } + else if(temp1.equals("maxNodes")){ + this.filterSettings.setMaxNodes(Integer.parseInt(temp2)); + } + else if(temp1.equals("meanDegree")){ + this.filterSettings.setMeanDegree(Double.parseDouble(temp2)); + } + } + + } + + } + catch(IOException ioexception) { } + + } + + + + public static void main(String[] args) { + List srcList = new ArrayList(); + String srcFile = ""; + String dstFile = ""; + String format = ""; + String asOrRT = ""; + + int ASorRT; + + FileConverter fc = new FileConverter(); + + + if(args.length == 5){ + dstFile = args[0]; + asOrRT = args[1]; + format = args[2]; + fc.getFiltersettings(args[3]); + srcFile = args[4]; + srcList.add(srcFile); + } + + else if(args.length > 5){ + dstFile = args[0]; + asOrRT = args[1]; + format = args[2]; + fc.getFiltersettings(args[3]); + + for (int i = 4; i < args.length; i++){ + srcList.add(args[i]); + System.out.println(args[i]); + } + } + + else if(args.length < 4){ + Util.ERR("usage: java Main.FileConverter RT {|AS} skitter2brite {|skitter2omnet} {|brite2omnet} {|dimes2brite} {|dimes2omnet} * "); + } + if (asOrRT.equalsIgnoreCase("AS")){ + ASorRT = ModelConstants.AS_FILE; + } + else if (asOrRT.equalsIgnoreCase("RT")){ + ASorRT = ModelConstants.RT_FILE; + } + else { + ASorRT = 0; + } + + if (format.equalsIgnoreCase("skitter2brite")){ + fc.convertSkitter2Brite(srcList, dstFile, ASorRT, fc.filterSettings); + } + else if (format.equalsIgnoreCase("skitter2omnet")){ + fc.convertSkitter2Omnet(srcList, dstFile, ASorRT, fc.filterSettings); + } + else if (format.equalsIgnoreCase("brite2omnet")){ + fc.convertBrite2Omnet(srcFile, dstFile, ASorRT, fc.filterSettings); + } + else if (format.equalsIgnoreCase("dimes2brite")){ + fc.convertDimes2Brite(srcList, dstFile, ASorRT, fc.filterSettings); + } + else if (format.equalsIgnoreCase("dimes2omnet")){ + fc.convertDimes2Omnet(srcList, dstFile, ASorRT, fc.filterSettings); + } + // just for debugging + else if (format.equalsIgnoreCase("gtitm2omnet")){ + fc.convertGTITM2Omnet(srcList, dstFile, ASorRT, fc.filterSettings); + } + else if (format.equalsIgnoreCase("brite2brite")){ + fc.convertBrite2Brite(srcList, dstFile, ASorRT, fc.filterSettings); + } + + } + + } diff -r -c -N BRITE/Java/Model/ASModel.java BRITE.new/Java/Model/ASModel.java *** BRITE/Java/Model/ASModel.java Mon Apr 22 00:25:22 2002 --- BRITE.new/Java/Model/ASModel.java Wed Nov 14 18:13:45 2007 *************** *** 58,64 **** Random ConnectRandom = rm.CONNECT_NODES(); ! /** --- 58,111 ---- Random ConnectRandom = rm.CONNECT_NODES(); ! // Code zum Testen ! public Node PlaceNodes(Graph g, int nodeType /*meta or non-meta node*/, int c) { ! Random PlaceRandom = rm.PLACE_NODES(); ! int numSquares = HS/LS; ! int totalSquares = numSquares * numSquares; ! ! if (nodePlacement == ModelConstants.NP_RANDOM) { ! for (int i=0; i RT {|AS} skitter2brite {|skitter2omnet} {|brite2omnet} {|dimes2brite} {|dimes2omnet} * + + RT {|AS}: Choose IP-level or AS-level graph as input. + + filterSettings-filename: Name of file, which turn on or off the filter. + + input-filename(s): + For Skitter: + For Dimes: + + + 3.1 More Documentation: + ---------------------- + + Import and Conversion of Dimes and Skitter Data: + + The BRITE Extension supports the import of an IP- or AS-level graph + created by Skitter or Dimes. According to your Skitter/Dimes data, you + have to select at CMD and GUI RT for an IP-level graph or AS for an + autonomous system view. + + Note, that the BRITE Extension supposes symmetric routing, such that + every edge between node A and B automatically generates an edge between + B and A. + + DIMES: Dimes splits nodes and edges information into two files. The + order for input files regarding the BRITE Extension is the following: + . + + SKITTER: The raw IP-level Skitter measurements will be provided in a + specific DB format by CAIDA. To import the files to BRITE, first you + need to convert the data into readable ASCII using the + sk_analysis_dump-2.0.5 tool. + + The BRITE Extension decomposes the traceroute path in separate edges. + The import routine creates a complete graph over all passed Skitter + files, i.e., all edges will be extracted from all input files to shape + the graph. Consequently, more monitor point data provides probably more + visible connections. If there are two or more edges connecting the same + vertices, e.g., resulting from different monitor files, the mean value + of the delay will be assigned as link weight. In case that the delay + between nodes cannot be calculated based on the RTT (that can happen + for Skitter data) a preconfigured default value of 10ms will be used. + + The AS adjacency matrix is computed daily from observed skitter + measurements. In contrast to the IP-level graph the data are available + in plain ASCII summarized over all monitor points. As noted at + + * http://www.caida.org/tools/measurement/skitter/as_adjacencies.xml + + the graph can contain AS-sets, multi-origin ASs and no ASs. Edges + affected by one of these effects will be *discarded* by the import + routine to avoid ambiguities. Skitter's AS-level data set does not + imply any link weights, such that a homogeneous link weight of 10ms + will be assumed. + + Filter Schemas: + + The BRITE Extension provides two filter schemas: + + MAP SAMPLING: This algorithm by Magoni and Pansiot ("Internet Topology + Modeler Based on Map Sampling", 2002) allows you to create a subgraph + with a predefined number of nodes and mean degree based on your input + topology. + + RADIUS VIEW: Using the radius view, you can create a subgraph, which + includes all nodes with a predefined maximum hop distance starting from + a particular node. Let G=(V,E) the origin topology and v \in V the + choosen node, than is G'=(V',E') the subgraph with V'={v' \in V | + dist(v,v') <= maxHop}. + + The filters will be configured for the CMD by a configuration file. A + sample file can be found in the patched BRITE root directory called + filterSettings.conf. + + Java Error: + + If you get the error message: "Error: Java heap space", you need to + increase the memory allocation with "java -Xmx ..." + + 4. Contact Us: + ---------------- + + If you find bugs or if you have further questions as well as suggestions + for improvements, please contact us: mw@link-lab.net. + + September 2th, 2007 diff -r -c -N BRITE/filterSettings.conf BRITE.new/filterSettings.conf *** BRITE/filterSettings.conf Thu Jan 1 01:00:00 1970 --- BRITE.new/filterSettings.conf Wed Nov 14 18:13:45 2007 *************** *** 0 **** --- 1,7 ---- + // This file is only readed if you dont use the Gui + // If you choose for example map_sampling, there is no need to enter the parameter for max_hop_filter + filterType 0; // 0 = NONE, 1 = MAX_HOP_FILTER, 2 = MAP_SAMPLING + searchedNode -1; // searched node, enter the node ID or the node IP. used by max_hop_filter + maxHop 0; // max radius around searched node/ip. used by max_hop_filter + maxNodes 4000; // number of nodes in new graph. used by map_sampling + meanDegree 2.4; // mean Degree in new graph. used by map_sampling