Packets are not getting received at other interface - wireshark

I have a script which consists of 2 switches 2 hosts which are in different subnet connected to a single router. When I send packets from 1 host to the other packets are not getting received at another interface, I am using Wireshark at the other interface for the confirmation but no packets have arrived. Attaching the code and screenshot of the topology. Any help regarding this will be great.
The topology is like this
H1----S1-----R------S2------H2
from mininet.net import Mininet
from mininet.node import Controller, RemoteController,OVSKernelSwitch, UserSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.link import Link, TCLink
def topology():
net = Mininet( controller=RemoteController, link=TCLink, switch=OVSKernelSwitch )
# Add hosts and switches
h1 = net.addHost( 'h1', ip="10.0.1.10/24", mac="00:00:00:00:00:01" )
h2 = net.addHost( 'h2', ip="10.0.2.10/24", mac="00:00:00:00:00:02" )
r1 = net.addHost( 'r1')
s1 = net.addSwitch( 's1')
s2 = net.addSwitch( 's2')
c0 = net.addController( 'c0', controller=RemoteController, ip='127.0.0.1', port=6633 )
net.addLink( r1, s1 )
net.addLink( r1, s2 )
net.addLink( h1, s1 )
net.addLink( h2, s2 )
net.build()
c0.start()
s1.start( [c0] )
s2.start( [c0] )
r1.cmd("ifconfig r1-eth0 0")
r1.cmd("ifconfig r1-eth1 0")
r1.cmd("ifconfig r1-eth0 hw ether 00:00:00:00:01:01")
r1.cmd("ifconfig r1-eth1 hw ether 00:00:00:00:01:02")
r1.cmd("ip addr add 10.0.1.1/24 brd + dev r1-eth0")
r1.cmd("ip addr add 10.0.2.1/24 brd + dev r1-eth1")
r1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")
h1.cmd("ip route add default via 10.0.1.1")
h2.cmd("ip route add default via 10.0.2.1")
s1.cmd("ovs-ofctl add-flow s1 priority=1,arp,actions=flood")
s1.cmd("ovs-ofctl add-flow s1 priority=65535,ip,dl_dst=00:00:00:00:01:01,actions=output:1")
s1.cmd("ovs-ofctl add-flow s1 priority=10,ip,nw_dst=10.0.1.0/24,actions=output:2")
s2.cmd("ovs-ofctl add-flow s2 priority=1,arp,actions=flood")
s2.cmd("ovs-ofctl add-flow s2 priority=65535,ip,dl_dst=00:00:00:00:01:02,actions=output:1")
s2.cmd("ovs-ofctl add-flow s2 priority=10,ip,nw_dst=10.0.2.0/24,actions=output:2")
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
topology()

Related

PEC calculation in Lua

I am struggling to calculate the packet error code (PEC) of received data over I2C in order to know check if the data is valid.
PEC Definition
I used the code stated in a previous question but it does not work for me.
The data looks like this: 0x00, 0x07, 0x01, 0x12, 0x3b, 0xd5
PEC is 0xd5 which is based on the polynomial = x^8+ x^2+ x^1+ x^0 - 0x107
This works also fine with this calculator.
So my question is, where is the difference between the code from the website and the one from the linked question:
local function crc8(t)
local c = 0
for _, b in ipairs(t) do
for i = 0, 7 do
c = c >> 1 ~ ((c ~ b >> i) & 1) * 0xE0
end
end
return c
end
This definition of CRC uses reversed bits in all data bytes.
local function reverse(x)
-- reverse bits of a byte
local y = 0
for j = 1, 8 do
y = y * 2 + (x&1)
x = x >> 1
end
return y
end
local function crc8(t)
local c = 0
for _, b in ipairs(t) do
b = reverse(b)
for i = 0, 7 do
c = c >> 1 ~ ((c ~ b >> i) & 1) * 0xE0
end
end
c = reverse(c)
return c
end
print(tohex(crc8{0x00, 0x07, 0x01, 0x12, 0x3b})) --> 0xd5

How to print QrCode using Epson TM-T20 printer?

I´m trying to use EPSON TM-T20 to print Qr Code using ESC POS commands
I can print simple text, expanded, cut paper, but when I tried to print Qr Code....not success
I´m using Linux and my printer is at /dev/usb/lp1.
I believe the ESC POS commands it´s ok, because there is another printer ( TANCA TP650) that use the same commands to print Qr Code, and this another printer is ok.
This is my code in Qt C++
vetor.append(0x1D);// GS ( k pL pH cn fn n1 n2 (cn=49, fn=65)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x04);
vetor.append('\0');
vetor.append(0x31);//cn=49
vetor.append(0x41);//fn=65
vetor.append(50);//n1 48..49 ou 49..50 ????
vetor.append('\0');//n2
//f67 := #29+#40+#107+#03+#00+#49+#67 + Chr(tamanho mod 17);
vetor.append(0x1D);// GS ( k pL pH cn fn n (cn=49, fn=67)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x03);
vetor.append('\0');
vetor.append(0x31);//cn
vetor.append(0x43);//fn=67
vetor.append(3); //tamanho 1..16
//f69 := #29+#40+#107+#03+#00+#49+#69+#03;
vetor.append(0x1D);//GS ( k pL pH cn fn n (cn=49, fn=69)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x03);
vetor.append('\0');
vetor.append(49);//cn
vetor.append(69);//fn
vetor.append(48);// error correction level 48..51 ????
len+=3;
qDebug() << "qrcode epson " << len << str;
qDebug() << (len & 0xFF) << ((len & 0xFF00) >> 8);
//f80 := #29+#40+#107 + AnsiChar(l mod 256) + AnsiChar(l div 256) + #49+#80+#48;
vetor.append(0x1D);//GS ( k pL pH cn fn m d1...dk (cn=49, fn=80)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(len & 0xFF);
vetor.append((len & 0xFF00) >> 8);
vetor.append(0x31);//cn
vetor.append(0x50);//fn
vetor.append(0x30);//m
vetor.append(str);
//f81 := #29+#40+#107+#03+#00+#49+#81+#48;
vetor.append(0x1D);//GS ( k pL pH cn fn m (cn=49, fn=81)
vetor.append(0x28);
vetor.append(0x6B);
vetor.append(0x03);
vetor.append('\0');
vetor.append(49);//cn
vetor.append(81);//fn
vetor.append(48);//m
Thanks
I usualy print this receipt using serial line. But /dev/usb/lp1 is not a serial printer.
My code to print was:
fprintf(printer, pedidoprt); //pedidoprt is a byte array of qrcode
And the C compiler understand \0 like end of string!!!!
I change my code to:
FILE *printer = fopen(caminho.toUtf8(), "w");
fwrite ( pedidoprt, sizeof(char), pedidoprt.size(), printer);
fclose(printer);
This point is closed!

How can I ignore MOTD and Banner messages with my Python/Paramiko script?

I have a script that reads a host.csv file with IP addresses and connects to each server in turn and runs some commands. I want the output to go to a file name that I specify in a raw_input in the script. Right now I just print the output, but I want to save all of the output to a file, EXCEPT for the login information(BANNER / MOTD) and the timestamps that occur. I have been working on trying to make it only print the output of the actual commands that I am running on each box, but I haven't been able to make it work.
I've been programming with Python for about 3 months now, and I have had some success but sometimes I run into road blocks that I can't yet work my way through.
from __future__ import print_function
import threading
import paramiko
import getpass
import time
import os
import sys
os.system('clear')
class ssh(object):
shell = None
client = None
transport = None
def __init__(self, address, username, password):
print('Connecting to server on ip', str(address) + '.')
self.client = paramiko.client.SSHClient()
self.client.set_missing_host_key_policy(paramiko.client.AutoAddPolicy())
self.client.connect(address, username=username, password=password, look_for_keys=False)
self.transport = paramiko.Transport((address, 22))
self.transport.connect(username=username, password=password)
thread = threading.Thread(target=self.process)
thread.daemon = True
thread.start()
def close_connection(self):
if(self.client != None):
self.client.close()
self.transport.close()
def open_shell(self):
self.shell = self.client.invoke_shell()
#self.shell.recv(1000)
def send_shell(self, command):
if(self.shell):
self.shell.send(command + '\n')
else:
print("Shell not opened.")
def process(self):
while True:
# Print data when available
if self.shell is not None and self.shell.recv_ready():
alldata = self.shell.recv(1024)
while self.shell.recv_ready():
alldata += self.shell.recv(1024)
data = alldata.split(os.linesep)
for line in data:
print(line)
header = "################## WHAT DO YOU WANT TO DO?? ##################"
headlen = len(header) - 2
secondline = "|" + (" " * headlen) + "|"
thirdline = "|" + " 1. Run the daily ATM Script." + (" " * 30) + "|"
fourthline = "|" + " 2. Run a single command on the entire ATM network" + (" " * 9) + "|"
print(header)
print(secondline)
print(secondline)
print(thirdline)
print(fourthline)
print(secondline)
print(secondline)
print("#" * len(header))
choice = raw_input("Choose your destiny: ")
while choice:
if choice == "1":
print(' \n##### STARTING PROGRAM #####\n')
sshUsername = getpass.getpass(prompt='ENTER USERNAME: ')
sshPassword = getpass.getpass('ENTER PASSWORD: ')
filename = raw_input("What filename dost thou chooseth?")
writefile = open(filename, 'a')
def main():
with open("host.csv", "r") as r:
for address in r:
print(address)
try:
connection = ssh(address, sshUsername, sshPassword)
try:
connection.open_shell()
time.sleep(1)
connection.send_shell('hardware cecplus timing references show')
time.sleep(1)
connection.send_shell('power')
time.sleep(1)
connection.send_shell('hard port show')
time.sleep(1)
connection.send_shell('sig show')
time.sleep(1)
connection.send_shell('conn spvcc pp show')
time.sleep(1)
connection.send_shell('interface sonet path near total')
time.sleep(1)
except:
print('Failed to run commands on:', r)
except:
print('Failed connection to:', r)
time.sleep(5)
connection.close_connection()
main()
elif choice == "2":
COMMAND = raw_input("INPUT A SINGLE COMMAND TO RUN ON THE ENTIRE ATM NETWORK:" )
if __name__ == '__main__':
print(' \n##### STARTING PROGRAM #####\n')
sshUsername = getpass.getpass(prompt='ENTER USERNAME: ')
sshPassword = getpass.getpass('ENTER PASSWORD: ')
def main():
with open("host.csv", "r") as r:
for address in r:
print(address)
try:
connection = ssh(address, sshUsername, sshPassword)
try:
connection.open_shell()
time.sleep(1)
connection.send_shell(COMMAND)
time.sleep(1)
except:
print('Failed to run commands on:', r)
except:
print('Failed connection to:', r)
time.sleep(1)
connection.close_connection()
main()
else:
print("If thou dost not Enter 1 or 2 thou willest not proceed")
choice = input("Choose your destiny: ")
The current results just print everything, including the banner and motd. If I can get it to only print the output from the commands I know I can write those outputs to a file. I basically want to ignore the MOTD and Banner messages.

Adaptation of SHA2 512 gives incorrect results

I am trying to adapt the pure Lua implementation of the SecureHashAlgorithm found here for SHA2 512 instead of SHA2 256. When I try to use the adaptation, it does not give the correct answer.
Here is the adaptation:
--
-- UTILITY FUNCTIONS
--
-- transform a string of bytes in a string of hexadecimal digits
local function str2hexa (s)
local h = string.gsub(s, ".", function(c)
return string.format("%02x", string.byte(c))
end)
return h
end
-- transforms number 'l' into a big-endian sequence of 'n' bytes
--(coded as a string)
local function num2string(l, n)
local s = ""
for i = 1, n do
--most significant byte of l
local remainder = l % 256
s = string.char(remainder) .. s
--remove from l the bits we have already transformed
l = (l-remainder) / 256
end
return s
end
-- transform the big-endian sequence of eight bytes starting at
-- index 'i' in 's' into a number
local function s264num (s, i)
local n = 0
for i = i, i + 7 do
n = n*256 + string.byte(s, i)
end
return n
end
--
-- MAIN SECTION
--
-- FIRST STEP: INITIALIZE HASH VALUES
--(second 32 bits of the fractional parts of the square roots of the first 9th through 16th primes 23..53)
local HH = {}
local function initH512(H)
H = {0x6a09e667f3bcc908, 0xbb67ae8584caa73b, 0x3c6ef372fe94f82b, 0xa54ff53a5f1d36f1, 0x510e527fade682d1, 0x9b05688c2b3e6c1f, 0x1f83d9abfb41bd6b, 0x5be0cd19137e2179}
return H
end
-- SECOND STEP: INITIALIZE ROUND CONSTANTS
--(first 80 bits of the fractional parts of the cube roots of the first 80 primes 2..409)
local k = {
0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, 0x3956c25bf348b538,
0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, 0xd807aa98a3030242, 0x12835b0145706fbe,
0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235,
0xc19bf174cf692694, 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,
0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, 0x983e5152ee66dfab,
0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, 0xc6e00bf33da88fc2, 0xd5a79147930aa725,
0x06ca6351e003826f, 0x142929670a0e6e70, 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed,
0x53380d139d95b3df, 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,
0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, 0xd192e819d6ef5218,
0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, 0x19a4c116b8d2d0c8, 0x1e376c085141ab53,
0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373,
0x682e6ff3d6b2b8a3, 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,
0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, 0xca273eceea26619c,
0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, 0x06f067aa72176fba, 0x0a637dc5a2c898a6,
0x113f9804bef90dae, 0x1b710b35131c471b, 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc,
0x431d67c49c100d4c, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817
}
-- THIRD STEP: PRE-PROCESSING (padding)
local function preprocess(toProcess, len)
--append a single '1' bit
--append K '0' bits, where K is the minimum number >= 0 such that L + 1 + K = 896mod1024
local extra = 128 - (len + 9) % 128
len = num2string(8 * len, 8)
toProcess = toProcess .. "\128" .. string.rep("\0", extra) .. len
assert(#toProcess % 128 == 0)
return toProcess
end
local function rrotate(rot, n)
return (rot >> n) | ((rot << 64 - n))
end
local function digestblock(msg, i, H)
local w = {}
for j = 1, 16 do w[j] = s264num(msg, i + (j - 1)*4) end
for j = 17, 80 do
local v = w[j - 15]
local s0 = rrotate(v, 1) ~ rrotate(v, 8) ~ (v >> 7)
v = w[j - 2]
w[j] = w[j - 16] + s0 + w[j - 7] + ((rrotate(v, 19) ~ rrotate(v, 61)) ~ (v >> 6))
end
local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6], H[7], H[8]
for i = 1, 80 do
a, b, c, d, e, f, g, h = a , b , c , d , e , f , g , h
local s0 = rrotate(a, 28) ~ (rrotate(a, 34) ~ rrotate(a, 39))
local maj = ((a & b) ~ (a & c)) ~ (b & c)
local t2 = s0 + maj
local s1 = rrotate(e, 14) ~ (rrotate(e, 18) ~ rrotate(e, 41))
local ch = (e & f) ~ (~e & g)
local t1 = h + s1 + ch + k[i] + w[i]
h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2
end
H[1] = (H[1] + a)
H[2] = (H[2] + b)
H[3] = (H[3] + c)
H[4] = (H[4] + d)
H[5] = (H[5] + e)
H[6] = (H[6] + f)
H[7] = (H[7] + g)
H[8] = (H[8] + h)
end
local function finalresult512 (H)
-- Produce the final hash value:
return
str2hexa(num2string(H[1], 8)..num2string(H[2], 8)..num2string(H[3], 8)..num2string(H[4], 8)..
num2string(H[5], 8)..num2string(H[6], 8)..num2string(H[7], 8)..num2string(H[8], 8))
end
-- Returns the hash512 for the given string.
local function hash512 (msg)
msg = preprocess(msg, #msg)
local H = initH512(HH)
-- Process the message in successive 1024-bit (128 bytes) chunks:
for i = 1, #msg, 128 do
digestblock(msg, i, H)
end
return finalresult512(H)
end
Given hash512("a"):
Expect: 1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75
Actual: e0b9623f2194cb81f2a62616a183edbe390be0d0b20430cadc3371efc237fa6bf7f8b48311f2fa249131c347fee3e8cde6acfdab286d648054541f92102cfc9c
I know that I am creating a message of the correct bit size (1024 bits) and also working in 1024-bit chunks, or at least I believe I am.
I am not sure if it has to do with the handling of the integers (the standard requires unsigned integers) or whether I made a mistake in one of the utility functions, or both. If it is indeed an issue with the handling of the integers, how would I go about taking care of the problem. I was able to resolve this when working on the 256-bit version of the adaptation by using mod 2^32 when working with numbers in the digestblock method. I attempted to do mod 2^64 and 2^63 with the 512-bit version and it does not correct the problem. I am stumped.
I should mention that I cannot use one of the many library implementations as I am using a sandboxed Lua that does not provide this access, which is why I need a pure lua implementation. Thanks in advance.
Unfortunately, after introducing integers in Lua 5.3 writing scripts for Lua becomes a more complicated task.
You must always think about transformations between integers and floating point numbers.
ALWAYS. Yes, that's boring.
One of your mistakes is an excellent example of this "dark corner of Lua".
local remainder = l % 256
s = string.char(remainder) .. s
--remove from l the bits we have already transformed
l = (l-remainder) / 256
Your value l is initially a 64-bit integer.
After cutting off its first byte l contains (64-8) = 56 bits, but now it's a floating point-number (with 53-bit precision, of course).
Possible solution: use l = l >> 8 or l = l // 256 instead of l = (l-remainder) / 256
Another mistake is using s264num(msg, i + (j - 1) * 4) instead of s264num(msg, i + (j - 1) * 8)
One more mistake is in the following line:
local extra = 128 - (len + 9) % 128
The correct code is
local extra = - (len + 17) % 128 + 8
(Please note that -a%m+b is not the same as b-a%m due to operator precedence)
After fixing these 3 mistakes your code works correctly.

How to parse 802.1q triple tagged frames using Scapy?

Background:
I'm working with scapy to parse IEEE 802.1Q triple tagged frames. I'm generating test frames using scapy and capturing them to a pcap file.
The parsing is done in a separate script by reading in the pcap file. I can successfully work with the 1st 802.1q tag.
Problem:
It's not clear to me how to access at the 2nd and 3rd 802.1q tags. I'm attempting to use haslayer() and getlayer to conditionally examine the frame headers. haslayer(Dot1Q) returns the
values associated with the 1st Dot1Q tag.
Question:
If the type field of the 1st tag is 0x8100, then a 2nd tag is present. Is there a way to advance to the 2nd and 3rd tags? I've looked at the l2.py source and experimented, but no luck yet.
Code:
Send triple tag frame:
sendp(Ether(dst='78:2B:CB:33:4B:9F',src="D4:AE:52:89:BA:FA")/Dot1Q(vlan=1,id=3,prio=2)/Dot1Q(vlan=2,id=3,prio=2)/Dot1Q(vlan=3,id=3,prio=2)/IP(dst='10.25.222.222')/ICMP())
Frame display:
###[ Ethernet ]###
dst = 78:2b:cb:33:4b:9f
src = d4:ae:52:89:ba:fa
type = 0x8100
###[ 802.1Q ]###
prio = 2L
id = 1L
vlan = 1L
type = 0x8100
###[ 802.1Q ]###
prio = 2L
id = 1L
vlan = 2L
type = 0x8100
###[ 802.1Q ]###
prio = 2L
id = 1L
vlan = 3L
type = 0x800
###[ IP ]###
version = 4L
ihl = 5L
tos = 0x0
len = 28
id = 1
flags =
frag = 0L
ttl = 64
proto = icmp
chksum = 0xc55
src = 10.25.123.123
dst = 10.25.222.222
\options \
###[ ICMP ]###
type = echo-request
code = 0
chksum = 0xf7ff
id = 0x0
seq = 0x0
###[ Padding ]###
load = '\x00\x00\x00\x00\x00\x00'
Frame parsing:
pkts=rdpcap(self.file_name)
for pkt in pkts:
try:
if pkt.haslayer(Ether):
src = pkt.getlayer(Ether).src
dst = pkt.getlayer(Ether).dst
type = pkt.getlayer(Ether).type
# Do something
if pkt.haslayer(Dot1Q):
prio = pkt.getlayer(Dot1Q).prio
id = pkt.getlayer(Dot1Q).id
vlan = pkt.getlayer(Dot1Q).vlan
type = pkt.getlayer(Dot1Q).type
# Do something
except:
raise `
You can access the inner 802.1Q tags of pkt with pkt[Dot1Q:2], pkt[Dot1Q:3] and so on. If the packet doesn't have the specified layer, an appropriate IndexError exception is raised:
In [3]: pkt
Out[3]: <Ether dst=78:2B:CB:33:4B:9F src=D4:AE:52:89:BA:FA type=0x8100 |<Dot1Q prio=2 id=3 vlan=1 type=0x8100 |<Dot1Q prio=2 id=3 vlan=2 type=0x8100 |<Dot1Q prio=2 id=3 vlan=3 type=0x800 |<IP frag=0 proto=icmp dst=10.25.222.222 |<ICMP |>>>>>>
In [4]: pkt[Dot1Q:1]
Out[4]: <Dot1Q prio=2 id=3 vlan=1 type=0x8100 |<Dot1Q prio=2 id=3 vlan=2 type=0x8100 |<Dot1Q prio=2 id=3 vlan=3 type=0x800 |<IP frag=0 proto=icmp dst=10.25.222.222 |<ICMP |>>>>>
In [5]: pkt[Dot1Q:2]
Out[5]: <Dot1Q prio=2 id=3 vlan=2 type=0x8100 |<Dot1Q prio=2 id=3 vlan=3 type=0x800 |<IP frag=0 proto=icmp dst=10.25.222.222 |<ICMP |>>>>
In [6]: pkt[Dot1Q:3]
Out[6]: <Dot1Q prio=2 id=3 vlan=3 type=0x800 |<IP frag=0 proto=icmp dst=10.25.222.222 |<ICMP |>>>
In [7]: pkt[Dot1Q:4]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-7-a155defcb885> in <module>()
----> 1 pkt[Dot1Q:4]
/usr/local/lib/python2.7/dist-packages/scapy_real-2.2.0_dev-py2.7.egg/scapy/packet.pyc in __getitem__(self, cls)
770 elif type(lname) is not str:
771 lname = repr(lname)
--> 772 raise IndexError("Layer [%s] not found" % lname)
773 return ret
774
IndexError: Layer [Dot1Q] not found
Of course, you may check the type value and only after verifying that it is 0x8100, try accessing the inner layer.

Resources