Skip to content

Commit

Permalink
added terminal prompts to server code
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaansathaye committed Aug 14, 2020
1 parent 0b41b56 commit c312cf5
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 155 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

testing.py
71 changes: 71 additions & 0 deletions INT Output Files/OUTint
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Packet: 4e41500000114e415000000108004500004ed9980000ff119af40c0104020c010401200012b5002000000100040500007b00010009030002100390000000000030030000006200003002000002800000300180000505

Ethernet Frame: 4e4150000011 4e4150000001 0800
DMAC: 4e:41:50:00:00:11
SMAC: 4e:41:50:00:00:01
EType: 0800

IP Frame: 45 00 004e d998 0000 ff 11 9af4 0c010402 0c010401
Version: 45
Type of Service: 00
Total Length: 004e
Identification: d998
Flags: 0000
Time to Live: ff
Protocol: 11
Header Checksum: 9af4
Source: 2.4.1.12
Destination: 1.4.1.12

UDP Frame: 2000 12b5 0020 0000
Source: 2000
Destination: 12b5
Length: 0020
UDP Checksum: 0000

VXLAN Frame: 01 0004 05 00007b 00
Flags: 01
Reserved: 0004
Next Protocol: 05
VNI: 00007b
Reserved: 00

INT Frame: 01 00 09 03
Type: 01
Reserved: 00
Length: 09
Next Protocol: 03

INT Metadata Header: 00000000000 2 10 03 1001000000000000 0000
Flags(Bits): 00 00 0 0 00000
Version(Bits): 00
Replication(Bits): 00
Copy(Bits): 0
Max Hop Count Exceeded(Bits): 0
Reserved Bits(Bits): 00000
Instruction Count: 2
Max Hop Count: 10
Total Hop Count: 03
Instruction Bitmap(Bits): 1001 0000 0000 0000
Bit 0 Switch ID: 1
Bit 1 Ingress Port ID: 0
Bit 2 Hop Latency: 0
Bit 3 Queue Occupancy: 1
Bit 4 Ingress Timestamp: 0
Bit 5 Egress Port ID: 0
Bit 6 Queue Congestion Status: 0
Bit 7 Egress Port TX Utilization: 0
Bit 8-16 Reserved Bits: 00000000
Reserved: 0000

INT Metadata Stack: 000030030000006200003002000002800000300180000505
Hop 3:
Switch ID: 00003003
Queue Occupancy: 00000062
Hop 2:
Switch ID: 00003002
Queue Occupancy: 00000280
Hop 1:
Switch ID: 00003001
Queue Occupancy: 80000505

71 changes: 0 additions & 71 deletions INT Output Files/OUTint.txt
Original file line number Diff line number Diff line change
@@ -1,71 +0,0 @@
Packet: 4e41500000114e415000000108004500004ed9980000ff119af40c0104020c010401200012b5002000000100040500007b00010009030002100390000000000030030000006200003002000002800000300180000505

Ethernet Frame: 4e4150000011 4e4150000001 0800
DMAC: 4e:41:50:00:00:11
SMAC: 4e:41:50:00:00:01
EType: 0800

IP Frame: 45 00 004e d998 0000 ff 11 9af4 0c010402 0c010401
Version: 45
Type of Service: 00
Total Length: 004e
Identification: d998
Flags: 0000
Time to Live: ff
Protocol: 11
Header Checksum: 9af4
Source: 2.4.1.12
Destination: 1.4.1.12

UDP Frame: 2000 12b5 0020 0000
Source: 2000
Destination: 12b5
Length: 0020
UDP Checksum: 0000

VXLAN Frame: 01 0004 05 00007b 00
Flags: 01
Reserved: 0004
Next Protocol: 05
VNI: 00007b
Reserved: 00

INT Frame: 01 00 09 03
Type: 01
Reserved: 00
Length: 09
Next Protocol: 03

INT Metadata Header: 00000000000 2 10 03 1001000000000000 0000
Flags(Bits): 00 00 0 0 00000
Version(Bits): 00
Replication(Bits): 00
Copy(Bits): 0
Max Hop Count Exceeded(Bits): 0
Reserved Bits(Bits): 00000
Instruction Count: 2
Max Hop Count: 10
Total Hop Count: 03
Instruction Bitmap(Bits): 1001 0000 0000 0000
Bit 0 Switch ID: 1
Bit 1 Ingress Port ID: 0
Bit 2 Hop Latency: 0
Bit 3 Queue Occupancy: 1
Bit 4 Ingress Timestamp: 0
Bit 5 Egress Port ID: 0
Bit 6 Queue Congestion Status: 0
Bit 7 Egress Port TX Utilization: 0
Bit 8-16 Reserved Bits: 00000000
Reserved: 0000

INT Metadata Stack: 000030030000006200003002000002800000300180000505
Hop 3:
Switch ID: 00003003
Queue Occupancy: 00000062
Hop 2:
Switch ID: 00003002
Queue Occupancy: 00000280
Hop 1:
Switch ID: 00003001
Queue Occupancy: 80000505

26 changes: 14 additions & 12 deletions INTCollector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import socket
from bitstring import BitArray, __version__
import struct
import argparse

#Color-coding
class bcolors:
Expand Down Expand Up @@ -48,17 +49,19 @@ def hex2dotted(hexWord):
endingINTMetadataHeader = 0
startingStack = 0
nextProtocolINT = '05'
transport = input("What mode of transport?(UDP-1, TCP-2, Other-3): ")

if transport == '1':
print()
localPort = int(input("Enter UDP Port Number: "))
startHeader = input("What is the starting header?(Eth-1, IP-2, UDP-3, VXLAN-4, INT-5): ")
file_out = input("Output Filename(No extension): ")
if file_out == None:
file_out == "output_INT"
file_out = file_out + ".txt"

parser = argparse.ArgumentParser(description='INT Collector Input Parameters:')
parser.add_argument('-t', type=str, help='transport for INT frames: u - UDP, t - TCP (default: u)', default='u')
parser.add_argument('-p', type=int, help='transport port number: (default: 20001)', default=20001)
parser.add_argument('-start', type=str, help='starting header: (Eth-1, IP-2, UDP-3, VXLAN-4, INT-5)', default='1')
parser.add_argument('-outFile', type=str, help='name of file for output (without extension .txt)', default='OUTint')
args = parser.parse_args()
transport = args.t
localPort = args.p
startHeader = args.start
file_out = args.outFile

if transport == 'u':
#Server
localIP = "127.0.0.1"
# localPort = 20001
Expand All @@ -67,7 +70,6 @@ def hex2dotted(hexWord):
UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
# Bind to address and ip
UDPServerSocket.bind((localIP, localPort))
print()
print("Searching...")
hexStream = ""
if startHeader == '1':
Expand Down Expand Up @@ -486,7 +488,7 @@ def __init__(self):
INTMetadata.__init__(self)

# Listen for incoming datagrams
if transport == '1':
if transport == 'u':
while(True):
bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
message = bytesAddressPair[0]
Expand Down
72 changes: 0 additions & 72 deletions bitManipulation.py

This file was deleted.

0 comments on commit c312cf5

Please sign in to comment.