Cisco Network Modules

In a nutshell:
NM-4T, has 4 serial ports for WAN connections- i believe the T stands for T1
NM-1FE-TX has 1 fast ethernet port
NM-1E has 1 ethernet port
The NM-16ESW is a switching module with 16 fast ethernet ports and provides some basic switching functionality

References :

https://community.gns3.com/thread/4665
http://www.cisco.com/c/en/us/td/docs/routers/access/interfaces/nm/hardware/installation/guide/OvrNetM.html

Calculate IP


Address: 192.168.0.1 11000000.10101000.00000000 .00000001
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111 .00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000 .11111111
=>
Network: 192.168.0.0/24 11000000.10101000.00000000 .00000000 (Class C)
Broadcast: 192.168.0.255 11000000.10101000.00000000 .11111111
HostMin: 192.168.0.1 11000000.10101000.00000000 .00000001
HostMax: 192.168.0.254 11000000.10101000.00000000 .11111110
Hosts/Net: 254 (Private Internet)

References :

http://jodies.de/ipcalc

Cisco Router IP Traffic Export

R1>enable
R1#configure terminal
R1(config)# ip traffic-export profile MyProfile
R1(conf-rite)# interface f0/0
R1(conf-rite)# mac-address 0001.0203.0405
R1(conf-rite)# bidirectional
R1(conf-rite)# exit

R1(config)# interface s0/0
R1(config-if)# ip traffic-export apply MyProfile

R1# show ip traffic-export

References :

http://www.cisco.com/c/en/us/td/docs/ios/12_4t/12_4t11/ht_rawip.html http://packetlife.net/blog/2009/oct/26/capturing-serial-traffic-ethernet-rite/
http://keepingitclassless.net/2010/10/raw-ip-traffic-export-rite-on-cisco-ios/

Join bytes in Python

def run_server():
    HOST = ''
    PORT = 11000
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((HOST, PORT))
    s.listen(10)

    while True:
        conn, addr = s.accept()
        print("{0} - ".format(get_counter()) + 'Connection from : {0}'.format(addr))

        data_recv=conn.recv(1024)
        data=bytearray()

        conn.settimeout(1)

        while len(data_recv)>0:
            data.extend(data_recv)
            try:
                data_recv=conn.recv(1024)
            except socket.timeout:
                break

        data=str(data)
        if data=="1":
            message=get_message1()
            conn.sendall(message)
        conn.close()

References :

http://stackoverflow.com/questions/9099145/where-are-python-bytearrays-used

Bytes stream in Python

    @staticmethod
    def from_bin(dataB):
        reader=io.BytesIO(dataB)
        length1= reader.read(4)
        length2=reader.read(4)
        length3=reader.read(4)
        macs=reader.read(length1)
        uid=reader.read(length2)
        signature=reader.read(length3)
        reader.close()

        message=Message(macs,uid,signature)
        return message

References :
https://docs.python.org/3/library/io.html#io.BytesIO http://chimera.labs.oreilly.com/books/1230000000393/ch05.html#_solution_78
https://docs.python.org/2/library/io.html

Serialize memory objects to binary in Python

try:
    import cPickle as pickle
except:
    import pickle
import pprint

data1 = [ { 'a':'A', 'b':2, 'c':3.0 } ]
print 'BEFORE:',
pprint.pprint(data1)

data1_string = pickle.dumps(data1)

data2 = pickle.loads(data1_string)
print 'AFTER:',
pprint.pprint(data2)

print 'SAME?:', (data1 is data2)
print 'EQUAL?:', (data1 == data2)

References:

https://docs.python.org/3/library/pickle.html
https://docs.python.org/2/library/pickle.html
https://pymotw.com/2/pickle/

Broadcast address

IP

The broadcast address for an IPv4 host can be obtained by performing a bitwise OR operation between the bit complement of the subnet mask and the host’s IP address. In other words, take the host’s IP address, and set to ‘1’ any bit positions which hold a ‘0’ in the subnet mask.

Example: For broadcasting a packet to an entire IPv4 subnet using the private IP address space 172.16.0.0/12, which has the subnet mask 255.240.0.0, the broadcast address is 172.16.0.0 | 0.15.255.255 = 172.31.255.255.

255.240.0.0=11111111.11110000.00000000.00000000
172.16.0.0=10101100.00010000.00000000.00000000
10101100.00011111.11111111.11111111=172.31.255.255

Ethernet

Broadcast is possible also on the underlying Data Link Layer in Ethernet networks. Frames are addressed to reach every computer on a given LAN segment if they are addressed to MAC address FF:FF:FF:FF:FF:FF. Ethernet frames that contain IP broadcast packages are usually sent to this address.

References :

https://en.wikipedia.org/wiki/Broadcast_address