|
@ -9,7 +9,7 @@ |
|
|
<entry key="config" type="String">#cloud-config
 |
|
|
<entry key="config" type="String">#cloud-config
 |
|
|
bootcmd:
 |
|
|
bootcmd:
 |
|
|
- ln -s -t /etc/rc.d /etc/rc.local
 |
|
|
- ln -s -t /etc/rc.d /etc/rc.local
 |
|
|
hostname: client
 |
|
|
|
|
|
|
|
|
hostname: client1
 |
|
|
manage_etc_hosts: true
 |
|
|
manage_etc_hosts: true
 |
|
|
runcmd:
 |
|
|
runcmd:
 |
|
|
- systemctl start rc-local
 |
|
|
- systemctl start rc-local
 |
|
@ -46,25 +46,48 @@ write_files:
 |
|
|
#!/bin/sh
 |
|
|
#!/bin/sh
 |
|
|
ifconfig eth1 up 10.0.0.20 netmask 255.255.0.0
 |
|
|
ifconfig eth1 up 10.0.0.20 netmask 255.255.0.0
 |
|
|
route add -host 192.168.0.1 gw 10.0.0.1 dev eth1
 |
|
|
route add -host 192.168.0.1 gw 10.0.0.1 dev eth1
 |
|
|
route add -net 10.0.0.0/16 gw 10.0.0.1 dev eth1
 |
|
|
|
|
|
route add default gw 10.0.0.1
 |
|
|
route add default gw 10.0.0.1
 |
|
|
echo "nameserver 8.8.8.8" >/etc/resolv.conf
 |
|
|
echo "nameserver 8.8.8.8" >/etc/resolv.conf
 |
|
|
|
|
|
chown -R cisco:cisco /home/cisco
 |
|
|
exit 0
 |
|
|
exit 0
 |
|
|
- path: /home/cisco/udpserver.py
 |
|
|
|
|
|
owner: cisco:cisco
 |
|
|
|
|
|
permissions: '0755'
 |
|
|
|
|
|
content: |-
 |
|
|
|
|
|
|
|
|
- path: /home/cisco/udp-client.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# Server-Adresse und Port
 |
|
|
|
|
|
serverName = "localhost"
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|

 |
|
|
|
|
|
# Client Socket (IP, UDP) oeffnen
 |
|
|
|
|
|
clientSocket = socket(AF_INET, SOCK_DGRAM)
 |
|
|
|
|
|

 |
|
|
|
|
|
# Nachricht vom Benutzer erfragen und versenden
 |
|
|
|
|
|
message = raw_input("UDP Nachricht in Kleinbuchstaben eingeben:")
 |
|
|
|
|
|
clientSocket.sendto(message,(serverName, serverPort))
 |
|
|
|
|
|

 |
|
|
|
|
|
# Antwort des Server aus Socket lesen und ausgeben
 |
|
|
|
|
|
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)
 |
|
|
|
|
|
print "Antwort des Servers: ", modifiedMessage
 |
|
|
|
|
|
raw_input("Fertig...")
 |
|
|
|
|
|

 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
clientSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/udp-server.py
 |
|
|
|
|
|
content: |
 |
|
|
#!/usr/bin/python
 |
|
|
#!/usr/bin/python
 |
|
|
from socket import *
 |
|
|
from socket import *
 |
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# UDP Port auf dem der Server lauschen soll...
 |
|
|
# UDP Port auf dem der Server lauschen soll...
 |
|
|
serverPort = 17000
 |
|
|
serverPort = 17000
 |
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# Server-Socket als Internet (INET) UDP (DGRAM) erzeugen und an o.g. Port binden
 |
|
|
# Server-Socket als Internet (INET) UDP (DGRAM) erzeugen und an o.g. Port binden
 |
|
|
serverSocket = socket(AF_INET, SOCK_DGRAM)
 |
|
|
serverSocket = socket(AF_INET, SOCK_DGRAM)
 |
|
|
serverSocket.bind(("", serverPort))
 |
|
|
serverSocket.bind(("", serverPort))
 |
|
|
print "UDP Server ist bereit fuer den Empfang von Daten..."
 |
|
|
print "UDP Server ist bereit fuer den Empfang von Daten..."
 |
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# Endlosschleife
 |
|
|
# Endlosschleife
 |
|
|
while 1:
 |
|
|
while 1:
 |
|
|
# Eingehende Nachrichten von Clients empfangen
 |
|
|
# Eingehende Nachrichten von Clients empfangen
 |
|
@ -73,38 +96,38 @@ write_files:
 |
|
|
# Client zuruecksenden
 |
|
|
# Client zuruecksenden
 |
|
|
modifiedMessage = message.upper()
 |
|
|
modifiedMessage = message.upper()
 |
|
|
serverSocket.sendto(modifiedMessage, clientAddress)
 |
|
|
serverSocket.sendto(modifiedMessage, clientAddress)
 |
|
|
- path: /home/cisco/udpclient.py
 |
|
|
|
|
|
owner: cisco:cisco
 |
|
|
|
|
|
permissions: '0755'
 |
|
|
|
|
|
content: |-
 |
|
|
|
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcp-client.py
 |
|
|
|
|
|
content: |
 |
|
|
#!/usr/bin/python
 |
|
|
#!/usr/bin/python
 |
|
|
from socket import *
 |
|
|
from socket import *
 |
|
|

 |
|
|
|
|
|
# Server-Adresse und Port
 |
|
|
|
|
|
|
|
|

 |
|
|
|
|
|
# Serveradresse und TCP Port auf den der Server hoert...
 |
|
|
serverName = "localhost"
 |
|
|
serverName = "localhost"
 |
|
|
serverPort = 17000
 |
|
|
serverPort = 17000
 |
|
|

 |
|
|
|
|
|
# Client Socket (IP, UDP) oeffnen
 |
|
|
|
|
|
clientSocket = socket(AF_INET, SOCK_DGRAM)
 |
|
|
|
|
|

 |
|
|
|
|
|
# Nachricht vom Benutzer erfragen und versenden
 |
|
|
|
|
|
message = raw_input("UDP Nachricht in Kleinbuchstaben eingeben:")
 |
|
|
|
|
|
clientSocket.sendto(message,(serverName, serverPort))
 |
|
|
|
|
|

 |
|
|
|
|
|
# Antwort des Server aus Socket lesen und ausgeben
 |
|
|
|
|
|
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)
 |
|
|
|
|
|
print "Antwort des Servers: ", modifiedMessage
 |
|
|
|
|
|
|
|
|
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren
 |
|
|
|
|
|
clientSocket = socket(AF_INET, SOCK_STREAM)
 |
|
|
|
|
|
clientSocket.connect((serverName,serverPort))
 |
|
|
|
|
|

 |
|
|
|
|
|
# Nachricht vom Benutzer abfragen und an den Server senden
 |
|
|
|
|
|
sentence = raw_input("TCP Nachricht in Kleinbuchstaben eingeben:")
 |
|
|
|
|
|
clientSocket.send(sentence)
 |
|
|
|
|
|

 |
|
|
|
|
|
# Antwort des Servers ausgeben
 |
|
|
|
|
|
modifiedSentence = clientSocket.recv(1024)
 |
|
|
|
|
|
print "Antwort des Servers:", modifiedSentence
 |
|
|
raw_input("Fertig...")
 |
|
|
raw_input("Fertig...")
 |
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# Verbindung schliessen
 |
|
|
# Verbindung schliessen
 |
|
|
clientSocket.close()
 |
|
|
clientSocket.close()
 |
|
|
- path: /home/cisco/tcpserver.py
 |
|
|
|
|
|
owner: cisco:cisco
 |
|
|
|
|
|
permissions: '0755'
 |
|
|
|
|
|
content: |-
 |
|
|
|
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcp-server.py
 |
|
|
|
|
|
content: |
 |
|
|
#!/usr/bin/python
 |
|
|
#!/usr/bin/python
 |
|
|
from socket import *
 |
|
|
from socket import *
 |
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# TCP Port auf dem der Server lauschen soll...
 |
|
|
# TCP Port auf dem der Server lauschen soll...
 |
|
|
serverPort = 17000
 |
|
|
serverPort = 17000
 |
|
|
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden
 |
|
|
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden
 |
|
@ -112,7 +135,7 @@ write_files:
 |
|
|
serverSocket.bind(("",serverPort))
 |
|
|
serverSocket.bind(("",serverPort))
 |
|
|
serverSocket.listen(1)
 |
|
|
serverSocket.listen(1)
 |
|
|
print "TCP Server ist bereit fuer den Empfang von Daten..."
 |
|
|
print "TCP Server ist bereit fuer den Empfang von Daten..."
 |
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# Endlosschleife
 |
|
|
# Endlosschleife
 |
|
|
while 1:
 |
|
|
while 1:
 |
|
|
# Eingehende Nachrichten akzeptieren und von Clients empfangen
 |
|
|
# Eingehende Nachrichten akzeptieren und von Clients empfangen
 |
|
@ -124,31 +147,61 @@ write_files:
 |
|
|
connectionSocket.send(capitalizedSentence)
 |
|
|
connectionSocket.send(capitalizedSentence)
 |
|
|
# Verbindung schliessen
 |
|
|
# Verbindung schliessen
 |
|
|
connectionSocket.close()
 |
|
|
connectionSocket.close()
 |
|
|
- path: /home/cisco/tcpclient.py
 |
|
|
|
|
|
owner: cisco:cisco
 |
|
|
|
|
|
permissions: '0755'
 |
|
|
|
|
|
content: |-
 |
|
|
|
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpdownload-client.py
 |
|
|
|
|
|
content: |
 |
|
|
#!/usr/bin/python
 |
|
|
#!/usr/bin/python
 |
|
|
from socket import *
 |
|
|
from socket import *
 |
|
|

 |
|
|
|
|
|
|
|
|
import time
 |
|
|
|
|
|

 |
|
|
# Serveradresse und TCP Port auf den der Server hoert...
 |
|
|
# Serveradresse und TCP Port auf den der Server hoert...
 |
|
|
serverName = "localhost"
 |
|
|
|
|
|
|
|
|
serverName = "10.0.0.30"
 |
|
|
serverPort = 17000
 |
|
|
serverPort = 17000
 |
|
|
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren
 |
|
|
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren
 |
|
|
clientSocket = socket(AF_INET, SOCK_STREAM)
 |
|
|
clientSocket = socket(AF_INET, SOCK_STREAM)
 |
|
|
clientSocket.connect((serverName,serverPort))
 |
|
|
clientSocket.connect((serverName,serverPort))
 |
|
|

 |
|
|
|
|
|
# Nachricht vom Benutzer abfragen und an den Server senden
 |
|
|
|
|
|
sentence = raw_input("TCP Nachricht in Kleinbuchstaben eingeben:")
 |
|
|
|
|
|
clientSocket.send(sentence)
 |
|
|
|
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# Antwort des Servers ausgeben
 |
|
|
# Antwort des Servers ausgeben
 |
|
|
modifiedSentence = clientSocket.recv(1024)
 |
|
|
|
|
|
print "Antwort des Servers:", modifiedSentence
 |
|
|
|
|
|
|
|
|
length = 0
 |
|
|
|
|
|
start = time.time()
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
data = clientSocket.recv(1024)
 |
|
|
|
|
|
if not data:
 |
|
|
|
|
|
break
 |
|
|
|
|
|
length += len(data)
 |
|
|
|
|
|
elapsed = time.time() - start
 |
|
|
|
|
|
print str(length) + " Bytes geladen in " + str(elapsed) + " secs (" + str(length / elapsed) + " bytes/s)"
 |
|
|
raw_input("Fertig...")
 |
|
|
raw_input("Fertig...")
 |
|
|

 |
|
|
|
|
|
|
|
|

 |
|
|
# Verbindung schliessen
 |
|
|
# Verbindung schliessen
 |
|
|
clientSocket.close()
 |
|
|
clientSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpdownload-server.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# TCP Port auf dem der Server lauschen soll...
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden
 |
|
|
|
|
|
serverSocket = socket(AF_INET,SOCK_STREAM)
 |
|
|
|
|
|
serverSocket.bind(("",serverPort))
 |
|
|
|
|
|
serverSocket.listen(1)
 |
|
|
|
|
|
downloadSize = raw_input("Download-Groesse: ")
 |
|
|
|
|
|
print "TCP Server ist bereit fuer den Download..."
 |
|
|
|
|
|

 |
|
|
|
|
|
# Endlosschleife
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
# Eingehende Nachrichten akzeptieren und von Clients empfangen
 |
|
|
|
|
|
connectionSocket, addr = serverSocket.accept()
 |
|
|
|
|
|
# Bytes an Client zuruecksenden
 |
|
|
|
|
|
connectionSocket.send("a" * int(downloadSize))
 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
connectionSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
</entry> |
|
|
</entry> |
|
|
</extensions> |
|
|
</extensions> |
|
|
<interface id="0" name="eth1" ipv4="10.0.0.2" netPrefixLenV4="16"/> |
|
|
<interface id="0" name="eth1" ipv4="10.0.0.2" netPrefixLenV4="16"/> |
|
@ -158,7 +211,7 @@ write_files:
 |
|
|
<entry key="config" type="String">#cloud-config
 |
|
|
<entry key="config" type="String">#cloud-config
 |
|
|
bootcmd:
 |
|
|
bootcmd:
 |
|
|
- ln -s -t /etc/rc.d /etc/rc.local
 |
|
|
- ln -s -t /etc/rc.d /etc/rc.local
 |
|
|
hostname: server
 |
|
|
|
|
|
|
|
|
hostname: server1
 |
|
|
manage_etc_hosts: true
 |
|
|
manage_etc_hosts: true
 |
|
|
runcmd:
 |
|
|
runcmd:
 |
|
|
- systemctl start rc-local
 |
|
|
- systemctl start rc-local
 |
|
@ -195,20 +248,225 @@ write_files:
 |
|
|
#!/bin/sh
 |
|
|
#!/bin/sh
 |
|
|
ifconfig eth1 up 10.0.0.30 netmask 255.255.0.0
 |
|
|
ifconfig eth1 up 10.0.0.30 netmask 255.255.0.0
 |
|
|
route add -host 192.168.0.1 gw 10.0.0.1 dev eth1
 |
|
|
route add -host 192.168.0.1 gw 10.0.0.1 dev eth1
 |
|
|
route add -net 10.0.0.0/16 gw 10.0.0.1 dev eth1
 |
|
|
|
|
|
route add default gw 10.0.0.1
 |
|
|
route add default gw 10.0.0.1
 |
|
|
echo "nameserver 8.8.8.8" >/etc/resolv.conf
 |
|
|
echo "nameserver 8.8.8.8" >/etc/resolv.conf
 |
|
|
|
|
|
chown -R cisco:cisco /home/cisco
 |
|
|
exit 0
 |
|
|
exit 0
 |
|
|
|
|
|
- path: /home/cisco/udpclient.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# Server-Adresse und Port
 |
|
|
|
|
|
serverName = "localhost"
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|

 |
|
|
|
|
|
# Client Socket (IP, UDP) oeffnen
 |
|
|
|
|
|
clientSocket = socket(AF_INET, SOCK_DGRAM)
 |
|
|
|
|
|

 |
|
|
|
|
|
# Nachricht vom Benutzer erfragen und versenden
 |
|
|
|
|
|
message = raw_input("UDP Nachricht in Kleinbuchstaben eingeben:")
 |
|
|
|
|
|
clientSocket.sendto(message,(serverName, serverPort))
 |
|
|
|
|
|

 |
|
|
|
|
|
# Antwort des Server aus Socket lesen und ausgeben
 |
|
|
|
|
|
modifiedMessage, serverAddress = clientSocket.recvfrom(2048)
 |
|
|
|
|
|
print "Antwort des Servers: ", modifiedMessage
 |
|
|
|
|
|
raw_input("Fertig...")
 |
|
|
|
|
|

 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
clientSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/udpserver.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# UDP Port auf dem der Server lauschen soll...
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|

 |
|
|
|
|
|
# Server-Socket als Internet (INET) UDP (DGRAM) erzeugen und an o.g. Port binden
 |
|
|
|
|
|
serverSocket = socket(AF_INET, SOCK_DGRAM)
 |
|
|
|
|
|
serverSocket.bind(("", serverPort))
 |
|
|
|
|
|
print "UDP Server ist bereit fuer den Empfang von Daten..."
 |
|
|
|
|
|

 |
|
|
|
|
|
# Endlosschleife
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
# Eingehende Nachrichten von Clients empfangen
 |
|
|
|
|
|
message, clientAddress = serverSocket.recvfrom(2048)
 |
|
|
|
|
|
# Alle Buchstaben der Nachricht in Grossbuchstaben umwandeln und an den
 |
|
|
|
|
|
# Client zuruecksenden
 |
|
|
|
|
|
modifiedMessage = message.upper()
 |
|
|
|
|
|
serverSocket.sendto(modifiedMessage, clientAddress)
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpclient.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# Serveradresse und TCP Port auf den der Server hoert...
 |
|
|
|
|
|
serverName = "localhost"
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren
 |
|
|
|
|
|
clientSocket = socket(AF_INET, SOCK_STREAM)
 |
|
|
|
|
|
clientSocket.connect((serverName,serverPort))
 |
|
|
|
|
|

 |
|
|
|
|
|
# Nachricht vom Benutzer abfragen und an den Server senden
 |
|
|
|
|
|
sentence = raw_input("TCP Nachricht in Kleinbuchstaben eingeben:")
 |
|
|
|
|
|
clientSocket.send(sentence)
 |
|
|
|
|
|

 |
|
|
|
|
|
# Antwort des Servers ausgeben
 |
|
|
|
|
|
modifiedSentence = clientSocket.recv(1024)
 |
|
|
|
|
|
print "Antwort des Servers:", modifiedSentence
 |
|
|
|
|
|
raw_input("Fertig...")
 |
|
|
|
|
|

 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
clientSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpserver.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# TCP Port auf dem der Server lauschen soll...
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden
 |
|
|
|
|
|
serverSocket = socket(AF_INET,SOCK_STREAM)
 |
|
|
|
|
|
serverSocket.bind(("",serverPort))
 |
|
|
|
|
|
serverSocket.listen(1)
 |
|
|
|
|
|
print "TCP Server ist bereit fuer den Empfang von Daten..."
 |
|
|
|
|
|

 |
|
|
|
|
|
# Endlosschleife
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
# Eingehende Nachrichten akzeptieren und von Clients empfangen
 |
|
|
|
|
|
connectionSocket, addr = serverSocket.accept()
 |
|
|
|
|
|
sentence = connectionSocket.recv(1024)
 |
|
|
|
|
|
# Alle Buchstaben der Nachricht in Grossbuchstaben umwandeln und an den
 |
|
|
|
|
|
# Client zuruecksenden
 |
|
|
|
|
|
capitalizedSentence = sentence.upper()
 |
|
|
|
|
|
connectionSocket.send(capitalizedSentence)
 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
connectionSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpclient-download.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|
import time
 |
|
|
|
|
|

 |
|
|
|
|
|
# Serveradresse und TCP Port auf den der Server hoert...
 |
|
|
|
|
|
serverName = "10.0.0.30"
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren
 |
|
|
|
|
|
clientSocket = socket(AF_INET, SOCK_STREAM)
 |
|
|
|
|
|
clientSocket.connect((serverName,serverPort))
 |
|
|
|
|
|

 |
|
|
|
|
|
# Antwort des Servers ausgeben
 |
|
|
|
|
|
length = 0
 |
|
|
|
|
|
start = time.time()
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
data = clientSocket.recv(1024)
 |
|
|
|
|
|
if not data:
 |
|
|
|
|
|
break
 |
|
|
|
|
|
length += len(data)
 |
|
|
|
|
|
elapsed = time.time() - start
 |
|
|
|
|
|
print str(length) + " Bytes geladen in " + str(elapsed) + " secs (" + str(length / elapsed) + " bytes/s)"
 |
|
|
|
|
|
raw_input("Fertig...")
 |
|
|
|
|
|

 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
clientSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpserver-download.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# TCP Port auf dem der Server lauschen soll...
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden
 |
|
|
|
|
|
serverSocket = socket(AF_INET,SOCK_STREAM)
 |
|
|
|
|
|
serverSocket.bind(("",serverPort))
 |
|
|
|
|
|
serverSocket.listen(1)
 |
|
|
|
|
|
downloadSize = raw_input("Download-Groesse: ")
 |
|
|
|
|
|
print "TCP Server ist bereit fuer den Download..."
 |
|
|
|
|
|

 |
|
|
|
|
|
# Endlosschleife
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
# Eingehende Nachrichten akzeptieren und von Clients empfangen
 |
|
|
|
|
|
connectionSocket, addr = serverSocket.accept()
 |
|
|
|
|
|
# Bytes an Client zuruecksenden
 |
|
|
|
|
|
connectionSocket.send("a" * int(downloadSize))
 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
connectionSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpdownload-client.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|
import time
 |
|
|
|
|
|

 |
|
|
|
|
|
# Serveradresse und TCP Port auf den der Server hoert...
 |
|
|
|
|
|
serverName = "10.0.0.30"
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|
# Socket fuer IP (INET) und TCP (STREAM) konfigurieren
 |
|
|
|
|
|
clientSocket = socket(AF_INET, SOCK_STREAM)
 |
|
|
|
|
|
clientSocket.connect((serverName,serverPort))
 |
|
|
|
|
|

 |
|
|
|
|
|
# Antwort des Servers ausgeben
 |
|
|
|
|
|
length = 0
 |
|
|
|
|
|
start = time.time()
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
data = clientSocket.recv(1024)
 |
|
|
|
|
|
if not data:
 |
|
|
|
|
|
break
 |
|
|
|
|
|
length += len(data)
 |
|
|
|
|
|
elapsed = time.time() - start
 |
|
|
|
|
|
print str(length) + " Bytes geladen in " + str(elapsed) + " secs (" + str(length / elapsed) + " bytes/s)"
 |
|
|
|
|
|
raw_input("Fertig...")
 |
|
|
|
|
|

 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
clientSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
|
|
|
- path: /home/cisco/tcpdownload-server.py
 |
|
|
|
|
|
content: |
 |
|
|
|
|
|
#!/usr/bin/python
 |
|
|
|
|
|
from socket import *
 |
|
|
|
|
|

 |
|
|
|
|
|
# TCP Port auf dem der Server lauschen soll...
 |
|
|
|
|
|
serverPort = 17000
 |
|
|
|
|
|
# Server-Socket als Internet (INET) TCP (STREAM) erzeugen und an o.g. Port binden
 |
|
|
|
|
|
serverSocket = socket(AF_INET,SOCK_STREAM)
 |
|
|
|
|
|
serverSocket.bind(("",serverPort))
 |
|
|
|
|
|
serverSocket.listen(1)
 |
|
|
|
|
|
downloadSize = raw_input("Download-Groesse: ")
 |
|
|
|
|
|
print "TCP Server ist bereit fuer den Download..."
 |
|
|
|
|
|

 |
|
|
|
|
|
# Endlosschleife
 |
|
|
|
|
|
while 1:
 |
|
|
|
|
|
# Eingehende Nachrichten akzeptieren und von Clients empfangen
 |
|
|
|
|
|
connectionSocket, addr = serverSocket.accept()
 |
|
|
|
|
|
# Bytes an Client zuruecksenden
 |
|
|
|
|
|
connectionSocket.send("a" * int(downloadSize))
 |
|
|
|
|
|
# Verbindung schliessen
 |
|
|
|
|
|
connectionSocket.close()
 |
|
|
|
|
|
owner: root:root
 |
|
|
|
|
|
permissions: '0777'
 |
|
|
</entry> |
|
|
</entry> |
|
|
</extensions> |
|
|
</extensions> |
|
|
<interface id="0" name="eth1" ipv4="10.0.0.3" netPrefixLenV4="16"/> |
|
|
<interface id="0" name="eth1" ipv4="10.0.0.3" netPrefixLenV4="16"/> |
|
|
</node> |
|
|
</node> |
|
|
<node name="switch1" type="SIMPLE" subtype="Unmanaged Switch" location="446,227"> |
|
|
|
|
|
|
|
|
<node name="switch1" type="SIMPLE" subtype="Unmanaged Switch" location="459,232"> |
|
|
<interface id="0" name="link1"/> |
|
|
<interface id="0" name="link1"/> |
|
|
<interface id="1" name="link2"/> |
|
|
<interface id="1" name="link2"/> |
|
|
<interface id="2" name="link3"/> |
|
|
<interface id="2" name="link3"/> |
|
|
</node> |
|
|
</node> |
|
|
<node name="router1" type="SIMPLE" subtype="IOSv" location="446,106"> |
|
|
|
|
|
|
|
|
<node name="router1" type="SIMPLE" subtype="IOSv" location="459,111"> |
|
|
<extensions> |
|
|
<extensions> |
|
|
<entry key="AutoNetkit.mgmt_ip" type="string"></entry> |
|
|
<entry key="AutoNetkit.mgmt_ip" type="string"></entry> |
|
|
<entry key="Auto-generate config" type="Boolean">false</entry> |
|
|
<entry key="Auto-generate config" type="Boolean">false</entry> |
|
|