{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'GLB_SIZE' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-4-fa687bfb8c42>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0midx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mGLB_SIZE\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      2\u001b[0m \u001b[0mpkg_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mfile_size\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0mprint_file_size\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfile_size\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'GLB_SIZE' is not defined"
     ]
    }
   ],
   "source": [
    "idx = GLB_SIZE\n",
    "pkg_list = []\n",
    "file_size = len(data)\n",
    "\n",
    "print_file_size(file_size)\n",
    "\n",
    "while idx < file_size:\n",
    "    pkg_length = get_pkg_length(data, idx)\n",
    "    pkg_list.append([idx + PKG_H_SIZE, pkg_length, data[idx+PKG_H_SIZE: idx+PKG_H_SIZE + pkg_length]])\n",
    "    idx = idx + PKG_H_SIZE + pkg_length\n",
    "    \n",
    "def print_layer_2(pkg_list, idx):\n",
    "    src_mac = pkg_list[idx][2][6:12].encode(\"hex\")\n",
    "    dst_mac = pkg_list[idx][2][0:6].encode(\"hex\")\n",
    "    ether_type = pkg_list[idx][2][12:14].encode(\"hex\")\n",
    "    \n",
    "    print (\"[%02d]th packet size  is: %d\" % (idx, pkg_list[idx][1]))\n",
    "    print (\"\")\n",
    "    print (\"---------- Layer2 ----------\")\n",
    "    print (\"src_mac is %s\" % src_mac)\n",
    "    print (\"dst_mac is %s\" % dst_mac)\n",
    "    print (\"ether_type is %s\" % ether_type)\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
