Class for interacting with raw sockets of the real network interface.
More...
|
def | __init__ (self, dev, node_mac, topology_neighbors) |
| Constructor. More...
|
|
def | recv_data (self) |
| Receive and return source mac, dsr_header and upper layer data from the interface. More...
|
|
def | send_raw_frame (self, dst_mac, dsr_message, payload) |
| Send raw frame to the network. More...
|
|
def | gen_eth_header (self, src_mac, dst_mac) |
| Generate ethernet header. More...
|
|
def | recv_data_with_filter (self) |
| Receive frames with filtering. More...
|
|
def | recv_data_no_filter (self) |
| Receive all frames without filtering. More...
|
|
def | get_src_mac (self, eth_header) |
| Get source MAC address from the given ethernet header. More...
|
|
def | close_raw_recv_socket (self) |
| Stop reading from the receiving socket and close it. More...
|
|
Class for interacting with raw sockets of the real network interface.
def Transport.RawTransport.__init__ |
( |
|
self, |
|
|
|
dev, |
|
|
|
node_mac, |
|
|
|
topology_neighbors |
|
) |
| |
Constructor.
- Parameters
-
self | The object pointer. |
dev | Name of physical network interface. |
node_mac | The node's own MAC address. |
topology_neighbors | List of neighbors MAC addresses to be accepted if the filtering is On. |
- Returns
- None
def Transport.RawTransport.close_raw_recv_socket |
( |
|
self | ) |
|
Stop reading from the receiving socket and close it.
- Parameters
-
- Returns
- None
def Transport.RawTransport.gen_eth_header |
( |
|
self, |
|
|
|
src_mac, |
|
|
|
dst_mac |
|
) |
| |
Generate ethernet header.
- Parameters
-
self | The object pointer. |
src_mac | Source MAC address. |
dst_mac | Destination MAC address. |
- Returns
- Ethernet header in binary string representation.
def Transport.RawTransport.get_src_mac |
( |
|
self, |
|
|
|
eth_header |
|
) |
| |
Get source MAC address from the given ethernet header.
- Parameters
-
self | The object pointer. |
eth_header | Ethernet header in binary representation. |
- Returns
- MAC address in "xx:xx:xx:xx:xx:xx" format.
def Transport.RawTransport.recv_data |
( |
|
self | ) |
|
Receive and return source mac, dsr_header and upper layer data from the interface.
This method listens for any incoming raw frames from the interface, and outputs the list containing a source mac, dsr_header and the upper_raw_data of the frame received.
- Parameters
-
- Returns
- [src_mac, dsr_header_obj, upper_raw_data].
def Transport.RawTransport.recv_data_no_filter |
( |
|
self | ) |
|
Receive all frames without filtering.
Receive and return source mac, dsr_header and upper layer data from the interface from ANY mac address without filtering.
- Parameters
-
- Returns
- [src_mac, dsr_header_obj, upper_raw_data].
def Transport.RawTransport.recv_data_with_filter |
( |
|
self | ) |
|
Receive frames with filtering.
Receive and return source mac, dsr_header and upper layer data from the interface, filter out the mac addresses, which are not in the RawTransport.topology_neighbors list.
- Parameters
-
- Returns
- [src_mac, dsr_header_obj, upper_raw_data].
def Transport.RawTransport.send_raw_frame |
( |
|
self, |
|
|
|
dst_mac, |
|
|
|
dsr_message, |
|
|
|
payload |
|
) |
| |
Send raw frame to the network.
- Parameters
-
self | The object pointer. |
dst_mac | Destination MAC address. |
dsr_message | Message object from Messages module. |
payload | User/Service payload after the protocol's header. |
- Returns
- None
Transport.RawTransport.broadcast_mac |
Default value of the broadcast MAC address.
Transport.RawTransport.node_mac |
The node's own MAC address.
Transport.RawTransport.proto |
Custom protocol ID on L2 layer.
Transport.RawTransport.recv_data |
Transport.RawTransport.recv_socket |
For receiving incoming raw frames.
Transport.RawTransport.running |
Thread running state bool() flag.
Transport.RawTransport.send_socket |
Create a send raw socket.
Type 0x7777 corresponds to the chosen "protocol_type" in our custom ethernet frame. In this way, the socket can only receive packets with 0x7777 protocol type.
Transport.RawTransport.topology_neighbors |
List of neighbors MAC addresses to be accepted if the filtering is On.
The documentation for this class was generated from the following file: